user2024014
user2024014

Reputation: 33

valgrind leaks detected no matter what

Even when I compile and run a program like this:

int main() {
    return 0;
}

I get the following valgrind errors when I run valgrind --leak-check=yes ./a.out

==26391== LEAK SUMMARY:
==26391==    definitely lost: 0 bytes in 0 blocks
==26391==    indirectly lost: 0 bytes in 0 blocks
==26391==      possibly lost: 72 bytes in 3 blocks
==26391==    still reachable: 200 bytes in 6 blocks
==26391==         suppressed: 18,528 bytes in 153 blocks
==26391== Reachable blocks (those to which a pointer was found) are not shown.
==26391== To see them, rerun with: --leak-check=full --show-leak-kinds=all

I am compiling with clang++ test.cpp. I am at a total loss for how to fix this.

Thank you!

Upvotes: 3

Views: 282

Answers (1)

dlmeetei
dlmeetei

Reputation: 10391

Valgrind manual has the following about possibly lost

This means that a chain of one or more pointers to the block has been found, but at least one of the pointers is an interior-pointer. This could just be a random value in memory that happens to point into a block, and so you shouldn’t consider this ok unless you know you have interior-pointers.

This implies that all reported possibly lost occurrence are not leak. This need to be confirmed by code perusal to check leak.

For your particular case, we know there is no leak happening in your code. You might like to rerun valgrind again with --leak-check=full --show-leak-kinds=all

Upvotes: 1

Related Questions