Confusing output from Valgrind shows indirectly lost memory leaks but no definitely lost or possibly lost

StackOverflow https://stackoverflow.com/questions/22670130

  •  22-06-2023
  •  | 
  •  

Question

I am running valgrind on the macos x 10.8. Valgrind says on startup

"==11312== WARNING: Support on MacOS 10.8 is experimental and mostly broken.
==11312== WARNING: Expect incorrect results, assertions and crashes.
==11312== WARNING: In particular, Memcheck on 32-bit programs will fail to
==11312== WARNING: detect any errors associated with heap-allocated data."

Valgrind is giving this leak summary:

"LEAK SUMMARY:
==11312==    definitely lost: 0 bytes in 0 blocks
==11312==    indirectly lost: 48 bytes in 2 blocks
==11312==      possibly lost: 0 bytes in 0 blocks
==11312==    still reachable: 45,857 bytes in 270 blocks
==11312==         suppressed: 16,805 bytes in 87 blocks"

According to valgrinds faq, http://valgrind.org/docs/manual/faq.html#faq.deflost, "indirectly lost" means your program is leaking memory in a pointer-based structure. (E.g. if the root node of a binary tree is "definitely lost", all the children will be "indirectly lost".) If you fix the "definitely lost" leaks, the "indirectly lost" leaks should go away.

I dont have any definitely lost leaks or even possibly lost leaks to fix. What am I supposed to fix? Could this report be a bug due to the experimental nature of valgrind in 10.8?

I believe i am compiling this as a 64 bit program since the compiler is a 64 bit compiler.

Was it helpful?

Solution

I feel weird answering my own question.

Yes the report by valgrind on mac is incorrect. According to valgrind on linux all heap blocks were freed so no leaks are possible.

I really hope valgrind fixes the issues with mac since I mainly am developing on mac now.

OTHER TIPS

Valgrind has been updated. Use (if you use homebrew):

brew unlink valgrind
brew install valgrind

And, lo and behold:

==23998== LEAK SUMMARY:
==23998==    definitely lost: 0 bytes in 0 blocks
==23998==    indirectly lost: 0 bytes in 0 blocks
==23998==      possibly lost: 0 bytes in 0 blocks
==23998==    still reachable: 76,800 bytes in 2 blocks
==23998==         suppressed: 58,420 bytes in 359 blocks
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top