Valgrind Frequently Asked Questions
Valgrind Frequently Asked Questions
1. Background
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
1.1. How do you pronounce "Valgrind"?
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
1.2. Where does the name "Valgrind" come from?
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
2. Compiling, installing and configuring
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2
2.1. When building Valgrind, ’make’ dies partway with an assertion failure, something like this:
. . . . . . . . .
2
2.2. When building Valgrind, ’make’ fails with this:
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2
3. Valgrind aborts unexpectedly
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2
3.1.
Programs run OK on Valgrind, but at exit produce a bunch of errors involving
__libc_freeres
and
then die with a segmentation fault.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3
3.2. My (buggy) program dies like this:
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3
3.3. My program dies, printing a message like this along the way:
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3
3.4. I tried running a Java program (or another program that uses a just-in-time compiler) under Valgrind but
something went wrong. Does Valgrind handle such programs?
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3
4. Valgrind behaves unexpectedly
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4
4.1.
My program uses the C++ STL and string classes.
Valgrind reports ’still reachable’ memory leaks
involving these classes at the exit of the program, but there should be none.
. . . . . . . . . . . . . . . . . . . . . .
4
4.2. The stack traces given by Memcheck (or another tool) aren’t helpful. How can I improve them?
. . . .
4
4.3.
The stack traces given by Memcheck (or another tool) seem to have the wrong function name in them.
What’s happening?
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6
4.4. My program crashes normally, but doesn’t under Valgrind, or vice versa. What’s happening?
. . . . . . .
6
4.5.
Memcheck doesn’t report any errors and I know my program has errors.
. . . . . . . . . . . . . . . . . . . . . . . . . .
6
4.6. Why doesn’t Memcheck find the array overruns in this program?
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7
5. Miscellaneous
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7
5.1. I tried writing a suppression but it didn’t work. Can you write my suppression for me?
. . . . . . . . . . . . .
7
5.2. With Memcheck’s memory leak detector, what’s the difference between "definitely lost", "indirectly lost",
"possibly lost", "still reachable", and "suppressed"?
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7
5.3. Memcheck’s uninitialised value errors are hard to track down, because they are often reported some time
after they are caused. Could Memcheck record a trail of operations to better link the cause to the effect?
Or maybe just eagerly report any copies of uninitialised memory values?
. . . . . . . . . . . . . . . . . . . . . . . .
8
5.4. Is it possible to attach Valgrind to a program that is already running?
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8
6. How To Get Further Assistance
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8
1. Background
1.1.
How do you pronounce "Valgrind"?
The "Val" as in the world "value". The "grind" is pronounced with a short ’i’ -- ie. "grinned" (rhymes with
"tinned") rather than "grined" (rhymes with "find").
Don’t feel bad: almost everyone gets it wrong at first.
1.2.
Where does the name "Valgrind" come from?
1