Error in Valgrind output?

I saw part of the valgrind post, but not one post helped me understand the interpretation of valgrind output. I ran two programs with valgrind (both have memory leaks)

Sample for test 1

==20422== LEAK SUMMARY: ==20422== definitely lost: 448 bytes in 3 blocks ==20422== indirectly lost: 786,460 bytes in 1 blocks ==20422== possibly lost: 1,576,052 bytes in 46 blocks ==20422== still reachable: 1,077,107 bytes in 2,333 blocks ==20422== suppressed: 0 bytes in 0 blocks ==20422== Rerun with --leak-check=full to see details of leaked memory ==20422== ==20422== For counts of detected and suppressed errors, rerun with: -v ==20422== ERROR SUMMARY: 98307 errors from 5 contexts (suppressed: 2 from 2) Killed 

Test Output 2

 ==20875== HEAP SUMMARY: ==20875== in use at exit: 1,059,198 bytes in 2,047 blocks ==20875== total heap usage: 3,019 allocs, 972 frees, 4,496,090 bytes allocated ==20875== ==20875== LEAK SUMMARY: ==20875== definitely lost: 328 bytes in 2 blocks ==20875== indirectly lost: 0 bytes in 0 blocks ==20875== possibly lost: 1,600 bytes in 5 blocks ==20875== still reachable: 1,057,270 bytes in 2,040 blocks ==20875== suppressed: 0 bytes in 0 blocks ==20875== Rerun with --leak-check=full to see details of leaked memory ==20875== ==20875== For counts of detected and suppressed errors, rerun with: -v ==20875== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2) 

If you look at the summary of errors, one of them says that there are errors, while the others say that there are no errors (in the end, both have leaks)

My question is - what is considered a valgrind error? (valgrind manual didn't help me)

+6
source share
1 answer

Memory leaks are not considered errors, they do not affect the program logic.

Errors - things like invalid reads and writes.

Updated as a result of the comment: Invalid reads and writes in test 1 relate to 5 different memory areas that are accessed 98307 times.

Looking at leaks, the large indirect losses in test 1 may indicate a related data structure where only the root is deleted.

Leaks in test 2 are not so bad. Since valgrind suggests repeating with -leak-check = full, which should indicate which bit of code is causing the problem.

A full description of the errors can be found here.

+6
source

Source: https://habr.com/ru/post/948451/


All Articles