Thread: Warning message from Valgrind

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    7

    Warning message from Valgrind

    I would like to ask whether the following message will pose a potential bug to the program.

    Syscall param pwrite(64) points to uninitialised bytes.

    What is this problem about and more importantly, will it cause segmentation fault?

  2. #2
    Registered User
    Join Date
    May 2010
    Location
    Naypyidaw
    Posts
    1,314
    Can you post relevant minimal code?

  3. #3
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    Are you calling write/pwrite, or some other function that could be using it? Find out what part of your source code it comes from, valgrind should report a trace. Then look at what you're attempting to write: you seem to be writing data from the buffer that hasn't been changed, so either you forgot to assign it all with a value or you're passing a wrong length argument...

    That's my guess, but that's all I can do without code.

    Will it segfault? It might do worse than that. The computer might explode or attack you. The funs of undefined behaviour.

  4. #4
    Registered User
    Join Date
    Nov 2010
    Posts
    7
    http://219.78.202.86:8080/him.c
    http://219.78.202.86:8080/testcase.c (the code with main function)
    here is the code. However, since I will power off my computer around 0000(HKT), so it will be not acessible from that time.
    Than You.

    ==4328== Syscall param pwrite64(buf) points to uninitialised byte(s)
    ==4328== at 0x40DC488: pwrite (pwrite.c:57)
    ==4328== by 0x8048BFF: swaptocache (in /home/cowcow/Desktop/test)
    ==4328== by 0x804926E: real_him (in /home/cowcow/Desktop/test)
    ==4328== by 0x80494B0: case3 (in /home/cowcow/Desktop/test)
    ==4328== by 0x80494ED: main (in /home/cowcow/Desktop/test)
    ==4328== Address 0x804d062 is 8194 bytes inside data symbol "buffer"

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    And is that your internal network?

    Not Found
    The requested URL /him.c was not found on this server.
    Apache/2.2.8 (Win32) PHP/5.2.6 Server at 219.78.202.86 Port 8080

    > ==4328== Address 0x804d062 is 8194 bytes inside data symbol "buffer"
    Interesting, because 8192 is a popular buffer size.
    Seems to me like you overran it.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    The pwrite64() function accepts a pointer (or address) and writes out whatever is at that address.

    Writing such data out requires that the data pointed to is initialised (accessing the value of anything that is uninitialised is formally undefined behaviour, according to the C standard). You have presumably passed an uninitialised pointer or array hence the complaint by valgrind.

    It's also possible, as Salem suggested, you are writing out more than the buffer (eg buffer is some length, you are outputting more than that length).
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. GradeInfo
    By kirksson in forum C Programming
    Replies: 23
    Last Post: 07-16-2008, 03:27 PM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM
  5. warning message
    By potbelle in forum C Programming
    Replies: 11
    Last Post: 04-03-2002, 10:20 PM