What do the suppressed leaks mean in Valgrind?

Genba picture Genba · Dec 28, 2011 · Viewed 12.8k times · Source

I have developed a pure-C implementation of FIFO lists (queues) in files fifo.h and fifo.c, and have written a test programme testfifo.c which I compile to ./bin/testfifo. The node structure is defined in list.h.

I run my programme through Valgrind on OS X 10.6 like this

valgrind --tool=memcheck --leak-check=full --show-reachable=yes ./bin/testfifo

and get the following output

==54688== Memcheck, a memory error detector
==54688== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==54688== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==54688== Command: bin/testfifo
==54688== 
--54688-- bin/testfifo:
--54688-- dSYM directory is missing; consider using --dsymutil=yes
==54688== 
==54688== HEAP SUMMARY:
==54688==     in use at exit: 88 bytes in 1 blocks
==54688==   total heap usage: 11 allocs, 10 frees, 248 bytes allocated
==54688== 
==54688== LEAK SUMMARY:
==54688==    definitely lost: 0 bytes in 0 blocks
==54688==    indirectly lost: 0 bytes in 0 blocks
==54688==      possibly lost: 0 bytes in 0 blocks
==54688==    still reachable: 0 bytes in 0 blocks
==54688==         suppressed: 88 bytes in 1 blocks
==54688== 
==54688== For counts of detected and suppressed errors, rerun with: -v
==54688== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

According to the leak summary, there are no leaks, but I am still wondering what the "suppressed" leaks are. Besides, the number of alloc's and free's do not match, and hence I am unsure if there are leaks or not.

----EDIT----

Running

valgrind --tool=memcheck --leak-check=full --show-reachable=yes -v ./bin/testfifo

on OS X 10.6 produces a quite long and confusing output, but I have run

valgrind --tool=memcheck --leak-check=full --show-reachable=yes ./bin/testfifo

on a Linux machine an got this output:

==32688== Memcheck, a memory error detector
==32688== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==32688== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
==32688== Command: bin/testfifo
==32688== 
==32688== 
==32688== HEAP SUMMARY:
==32688==     in use at exit: 0 bytes in 0 blocks
==32688==   total heap usage: 10 allocs, 10 frees, 160 bytes allocated
==32688== 
==32688== All heap blocks were freed -- no leaks are possible
==32688== 
==32688== For counts of detected and suppressed errors, rerun with: -v
==32688== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 4)

alloc's and free's now match, so the extra alloc on OS X seems to be due to some system library, as has been suggested.

I have run the very same command with the -v option, in order to reveal the 4 suppressed errors, but I have not got any easily understandable new information.

Answer

cnicutar picture cnicutar · Dec 28, 2011

Those are leaks outside of your code, in (probably shared) libraries or known false positives. Running valgrind with -v should inform you about the suppressions used.