Here, the undefined value is used somewhere inside the printf machinery of the C library. Use of uninitialised valuesįor example: Conditional jump or move depends on uninitialised value(s)Īn uninitialised-value use error is reported when your program uses a value which hasn’t been initialised – in other words, is undefined.
In this particular example, reading junk on the stack is non-fatal, and the program stays alive. So, if your program makes an access which normally would result in a segmentation fault, you program will still suffer the same fate – but you will get a message from Memcheck immediately prior to this. Note that Memcheck only tells you that your program is about to access memory at an illegal address. In this particular case it’s probably caused by GCC generating invalid code, a known bug in some ancient versions of GCC. Actually the address is on the stack, but, for some reason, this is not a valid stack address – it is below the stack pointer and that isn’t allowed. In this example, Memcheck can’t identify the address. If you use the -read-var-info option Memcheck will run more slowly but may give a more detailed description of any illegal address. Likewise, if it should turn out to be just off the end of a heap block, a common result of off-by-one-errors in array subscripting, you’ll be informed of this fact, and also where the block was allocated. So, if it points into a block of memory which has already been freed, you’ll be informed of this, and also where the block was freed. Memcheck tries to establish what the illegal address might relate to, since that’s often useful. In this example, the program did a 4-byte read at address 0xBFFFF0E0, somewhere within the system-supplied library libpng.so.2.1.0.9, which was called from somewhere else in the same library, called from line 326 of qpngio.cpp, and so on. This happens when your program reads or writes memory at a place which Memcheck reckons it shouldn’t.
The precise behaviour of the error-checking machinery is described in Details of Memcheck’s checking machinery. This section presents a quick summary of what error messages mean. Memcheck issues a range of error messages. Explanation of error messages from Memcheck