From: Philippe Waroquiers Date: Fri, 22 Sep 2017 21:50:35 +0000 (+0200) Subject: Follow up to 345307 - Warning about "still reachable" memory when using libstdc... X-Git-Tag: VALGRIND_3_14_0~255 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f053756e2880dbb7291aac086aa48e1fd3b6f812;p=thirdparty%2Fvalgrind.git Follow up to 345307 - Warning about "still reachable" memory when using libstdc++ from gcc 5 The bug itself was solved in 3.12 by the addition of __gnu_cxx::__freeres in the libstdc++ and have valgrind calling it before exit. However, depending on the version of the libstdc++, the test leak_cpp_interior was giving different results. This commit adds some filtering specific to the test, so as to not depend anymore of the absolute number of bytes leaked, and adds a suppression entry to ignore the memory allocated by libstdc++. This allows to have only 2 .exp files, instead of 4 (or worse, if we would have to handle yet other .exp files depending on the libstdc++ version). --- diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index b8529f64c0..b9ba67b258 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -64,6 +64,7 @@ dist_noinst_SCRIPTS = \ filter_allocs \ filter_dw4 \ filter_leak_cases_possible \ + filter_leak_cpp_interior \ filter_stderr filter_xml \ filter_strchr \ filter_varinfo3 \ @@ -114,7 +115,6 @@ EXTRA_DIST = \ cond_st.stderr.exp-64bit-non-arm \ cond_st.stderr.exp-32bit-non-arm \ leak_cpp_interior.stderr.exp leak_cpp_interior.stderr.exp-64bit leak_cpp_interior.vgtest \ - leak_cpp_interior.stderr.exp-solaris leak_cpp_interior.stderr.exp-64bit-solaris \ custom_alloc.stderr.exp custom_alloc.vgtest \ custom_alloc.stderr.exp-s390x-mvc \ custom-overlap.stderr.exp custom-overlap.vgtest \ diff --git a/memcheck/tests/filter_leak_cpp_interior b/memcheck/tests/filter_leak_cpp_interior new file mode 100755 index 0000000000..ae090876f5 --- /dev/null +++ b/memcheck/tests/filter_leak_cpp_interior @@ -0,0 +1,13 @@ +#! /bin/sh +# +# Remove the suppressed line and the total heap usage line. +# Replace the absolute number of bytes different of 0 by x. +./filter_stderr "$@" | + sed -e '/ suppressed:/d'\ + -e '/ total heap usage:/d'\ + -e 's/[1-9][0-9,]* bytes/x bytes/' \ + -e 's/[1-9][0-9,]* (\([+-]\)[1-9][0-9,]*) bytes/x (\1x) bytes/' \ + -e 's/0 (\([+-]\)[1-9][0-9,]*) bytes/0 (\1x) bytes/' \ + -e 's/[1-9][0-9,]* (\([+-]\)0) bytes/x (\10) bytes/' + + diff --git a/memcheck/tests/leak_cpp_interior.stderr.exp b/memcheck/tests/leak_cpp_interior.stderr.exp index 70e2764f42..df6cad22ad 100644 --- a/memcheck/tests/leak_cpp_interior.stderr.exp +++ b/memcheck/tests/leak_cpp_interior.stderr.exp @@ -1,118 +1,110 @@ valgrind output will go to log VALGRIND_DO_LEAK_CHECK -4 bytes in 1 blocks are definitely lost in loss record ... of ... +x bytes in 1 blocks are definitely lost in loss record ... of ... by 0x........: doit() (leak_cpp_interior.cpp:116) by 0x........: main (leak_cpp_interior.cpp:131) LEAK SUMMARY: - definitely lost: 4 bytes in 1 blocks + definitely lost: x bytes in 1 blocks indirectly lost: 0 bytes in 0 blocks possibly lost: 0 bytes in 0 blocks - still reachable: 163 bytes in 8 blocks + still reachable: x bytes in 8 blocks of which reachable via heuristic: - stdstring : 56 bytes in 2 blocks - length64 : 31 bytes in 1 blocks - newarray : 28 bytes in 1 blocks - multipleinheritance: 24 bytes in 2 blocks - suppressed: 0 bytes in 0 blocks + stdstring : x bytes in 2 blocks + length64 : x bytes in 1 blocks + newarray : x bytes in 1 blocks + multipleinheritance: x bytes in 2 blocks Reachable blocks (those to which a pointer was found) are not shown. To see them, rerun with: --leak-check=full --show-leak-kinds=all leak_check summary heuristics multipleinheritance LEAK SUMMARY: - definitely lost: 4 (+0) bytes in 1 (+0) blocks + definitely lost: x (+0) bytes in 1 (+0) blocks indirectly lost: 0 (+0) bytes in 0 (+0) blocks - possibly lost: 115 (+115) bytes in 4 (+4) blocks - still reachable: 48 (-115) bytes in 4 (-4) blocks + possibly lost: x (+x) bytes in 4 (+4) blocks + still reachable: x (-x) bytes in 4 (-4) blocks of which reachable via heuristic: - stdstring : 0 (-56) bytes in 0 (-2) blocks - length64 : 0 (-31) bytes in 0 (-1) blocks - newarray : 0 (-28) bytes in 0 (-1) blocks - multipleinheritance: 24 (+0) bytes in 2 (+0) blocks - suppressed: 0 (+0) bytes in 0 (+0) blocks + stdstring : 0 (-x) bytes in 0 (-2) blocks + length64 : 0 (-x) bytes in 0 (-1) blocks + newarray : 0 (-x) bytes in 0 (-1) blocks + multipleinheritance: x (+0) bytes in 2 (+0) blocks To see details of leaked memory, give 'full' arg to leak_check leak_check summary any heuristics newarray LEAK SUMMARY: - definitely lost: 4 (+0) bytes in 1 (+0) blocks + definitely lost: x (+0) bytes in 1 (+0) blocks indirectly lost: 0 (+0) bytes in 0 (+0) blocks - possibly lost: 111 (-4) bytes in 5 (+1) blocks - still reachable: 52 (+4) bytes in 3 (-1) blocks + possibly lost: x (-x) bytes in 5 (+1) blocks + still reachable: x (+x) bytes in 3 (-1) blocks of which reachable via heuristic: - newarray : 28 (+28) bytes in 1 (+1) blocks - multipleinheritance: 0 (-24) bytes in 0 (-2) blocks - suppressed: 0 (+0) bytes in 0 (+0) blocks + newarray : x (+x) bytes in 1 (+1) blocks + multipleinheritance: 0 (-x) bytes in 0 (-2) blocks To see details of leaked memory, give 'full' arg to leak_check leak_check summary heuristics length64 LEAK SUMMARY: - definitely lost: 4 (+0) bytes in 1 (+0) blocks + definitely lost: x (+0) bytes in 1 (+0) blocks indirectly lost: 0 (+0) bytes in 0 (+0) blocks - possibly lost: 108 (-3) bytes in 5 (+0) blocks - still reachable: 55 (+3) bytes in 3 (+0) blocks + possibly lost: x (-x) bytes in 5 (+0) blocks + still reachable: x (+x) bytes in 3 (+0) blocks of which reachable via heuristic: - length64 : 31 (+31) bytes in 1 (+1) blocks - newarray : 0 (-28) bytes in 0 (-1) blocks - suppressed: 0 (+0) bytes in 0 (+0) blocks + length64 : x (+x) bytes in 1 (+1) blocks + newarray : 0 (-x) bytes in 0 (-1) blocks To see details of leaked memory, give 'full' arg to leak_check leak_check summary heuristics stdstring LEAK SUMMARY: - definitely lost: 4 (+0) bytes in 1 (+0) blocks + definitely lost: x (+0) bytes in 1 (+0) blocks indirectly lost: 0 (+0) bytes in 0 (+0) blocks - possibly lost: 83 (-25) bytes in 4 (-1) blocks - still reachable: 80 (+25) bytes in 4 (+1) blocks + possibly lost: x (-x) bytes in 4 (-1) blocks + still reachable: x (+x) bytes in 4 (+1) blocks of which reachable via heuristic: - stdstring : 56 (+56) bytes in 2 (+2) blocks - length64 : 0 (-31) bytes in 0 (-1) blocks - suppressed: 0 (+0) bytes in 0 (+0) blocks + stdstring : x (+x) bytes in 2 (+2) blocks + length64 : 0 (-x) bytes in 0 (-1) blocks To see details of leaked memory, give 'full' arg to leak_check leak_check summary heuristics multipleinheritance,newarray,stdstring,length64 LEAK SUMMARY: - definitely lost: 4 (+0) bytes in 1 (+0) blocks + definitely lost: x (+0) bytes in 1 (+0) blocks indirectly lost: 0 (+0) bytes in 0 (+0) blocks - possibly lost: 0 (-83) bytes in 0 (-4) blocks - still reachable: 163 (+83) bytes in 8 (+4) blocks + possibly lost: 0 (-x) bytes in 0 (-4) blocks + still reachable: x (+x) bytes in 8 (+4) blocks of which reachable via heuristic: - stdstring : 56 (+0) bytes in 2 (+0) blocks - length64 : 31 (+31) bytes in 1 (+1) blocks - newarray : 28 (+28) bytes in 1 (+1) blocks - multipleinheritance: 24 (+24) bytes in 2 (+2) blocks - suppressed: 0 (+0) bytes in 0 (+0) blocks + stdstring : x (+0) bytes in 2 (+0) blocks + length64 : x (+x) bytes in 1 (+1) blocks + newarray : x (+x) bytes in 1 (+1) blocks + multipleinheritance: x (+x) bytes in 2 (+2) blocks To see details of leaked memory, give 'full' arg to leak_check leak_check summary heuristics all LEAK SUMMARY: - definitely lost: 4 (+0) bytes in 1 (+0) blocks + definitely lost: x (+0) bytes in 1 (+0) blocks indirectly lost: 0 (+0) bytes in 0 (+0) blocks possibly lost: 0 (+0) bytes in 0 (+0) blocks - still reachable: 163 (+0) bytes in 8 (+0) blocks + still reachable: x (+0) bytes in 8 (+0) blocks of which reachable via heuristic: - stdstring : 56 (+0) bytes in 2 (+0) blocks - length64 : 31 (+0) bytes in 1 (+0) blocks - newarray : 28 (+0) bytes in 1 (+0) blocks - multipleinheritance: 24 (+0) bytes in 2 (+0) blocks - suppressed: 0 (+0) bytes in 0 (+0) blocks + stdstring : x (+0) bytes in 2 (+0) blocks + length64 : x (+0) bytes in 1 (+0) blocks + newarray : x (+0) bytes in 1 (+0) blocks + multipleinheritance: x (+0) bytes in 2 (+0) blocks To see details of leaked memory, give 'full' arg to leak_check leak_check summary heuristics none LEAK SUMMARY: - definitely lost: 4 (+0) bytes in 1 (+0) blocks + definitely lost: x (+0) bytes in 1 (+0) blocks indirectly lost: 0 (+0) bytes in 0 (+0) blocks - possibly lost: 139 (+139) bytes in 6 (+6) blocks - still reachable: 24 (-139) bytes in 2 (-6) blocks + possibly lost: x (+x) bytes in 6 (+6) blocks + still reachable: x (-x) bytes in 2 (-6) blocks of which reachable via heuristic: - stdstring : 0 (-56) bytes in 0 (-2) blocks - length64 : 0 (-31) bytes in 0 (-1) blocks - newarray : 0 (-28) bytes in 0 (-1) blocks - multipleinheritance: 0 (-24) bytes in 0 (-2) blocks - suppressed: 0 (+0) bytes in 0 (+0) blocks + stdstring : 0 (-x) bytes in 0 (-2) blocks + length64 : 0 (-x) bytes in 0 (-1) blocks + newarray : 0 (-x) bytes in 0 (-1) blocks + multipleinheritance: 0 (-x) bytes in 0 (-2) blocks To see details of leaked memory, give 'full' arg to leak_check -Searching for pointers pointing in 20 bytes from 0x........ -*0x........ interior points at 4 bytes inside 0x........ +Searching for pointers pointing in x bytes from 0x........ +*0x........ interior points at x bytes inside 0x........ Address 0x........ is 0 bytes inside data symbol "ptr" block at 0x........ considered reachable by ptr 0x........ using newarray heuristic destruct MyClass @@ -134,7 +126,6 @@ Finished! HEAP SUMMARY: in use at exit: 0 bytes in 0 blocks - total heap usage: 9 allocs, 9 frees, 167 bytes allocated All heap blocks were freed -- no leaks are possible diff --git a/memcheck/tests/leak_cpp_interior.stderr.exp-64bit b/memcheck/tests/leak_cpp_interior.stderr.exp-64bit index 612fa3e1ae..38997304f5 100644 --- a/memcheck/tests/leak_cpp_interior.stderr.exp-64bit +++ b/memcheck/tests/leak_cpp_interior.stderr.exp-64bit @@ -1,118 +1,110 @@ valgrind output will go to log VALGRIND_DO_LEAK_CHECK -8 bytes in 1 blocks are definitely lost in loss record ... of ... +x bytes in 1 blocks are definitely lost in loss record ... of ... by 0x........: doit() (leak_cpp_interior.cpp:116) by 0x........: main (leak_cpp_interior.cpp:131) LEAK SUMMARY: - definitely lost: 8 bytes in 1 blocks + definitely lost: x bytes in 1 blocks indirectly lost: 0 bytes in 0 blocks possibly lost: 0 bytes in 0 blocks - still reachable: 239 bytes in 8 blocks + still reachable: x bytes in 8 blocks of which reachable via heuristic: - stdstring : 80 bytes in 2 blocks - length64 : 31 bytes in 1 blocks - newarray : 32 bytes in 1 blocks - multipleinheritance: 48 bytes in 2 blocks - suppressed: 0 bytes in 0 blocks + stdstring : x bytes in 2 blocks + length64 : x bytes in 1 blocks + newarray : x bytes in 1 blocks + multipleinheritance: x bytes in 2 blocks Reachable blocks (those to which a pointer was found) are not shown. To see them, rerun with: --leak-check=full --show-leak-kinds=all leak_check summary heuristics multipleinheritance LEAK SUMMARY: - definitely lost: 8 (+0) bytes in 1 (+0) blocks + definitely lost: x (+0) bytes in 1 (+0) blocks indirectly lost: 0 (+0) bytes in 0 (+0) blocks - possibly lost: 143 (+143) bytes in 4 (+4) blocks - still reachable: 96 (-143) bytes in 4 (-4) blocks + possibly lost: x (+x) bytes in 4 (+4) blocks + still reachable: x (-x) bytes in 4 (-4) blocks of which reachable via heuristic: - stdstring : 0 (-80) bytes in 0 (-2) blocks - length64 : 0 (-31) bytes in 0 (-1) blocks - newarray : 0 (-32) bytes in 0 (-1) blocks - multipleinheritance: 48 (+0) bytes in 2 (+0) blocks - suppressed: 0 (+0) bytes in 0 (+0) blocks + stdstring : 0 (-x) bytes in 0 (-2) blocks + length64 : 0 (-x) bytes in 0 (-1) blocks + newarray : 0 (-x) bytes in 0 (-1) blocks + multipleinheritance: x (+0) bytes in 2 (+0) blocks To see details of leaked memory, give 'full' arg to leak_check leak_check summary any heuristics newarray LEAK SUMMARY: - definitely lost: 8 (+0) bytes in 1 (+0) blocks + definitely lost: x (+0) bytes in 1 (+0) blocks indirectly lost: 0 (+0) bytes in 0 (+0) blocks - possibly lost: 128 (-15) bytes in 4 (+0) blocks - still reachable: 111 (+15) bytes in 4 (+0) blocks + possibly lost: x (-x) bytes in 4 (+0) blocks + still reachable: x (+x) bytes in 4 (+0) blocks of which reachable via heuristic: - newarray : 63 (+63) bytes in 2 (+2) blocks - multipleinheritance: 0 (-48) bytes in 0 (-2) blocks - suppressed: 0 (+0) bytes in 0 (+0) blocks + newarray : x (+x) bytes in 2 (+2) blocks + multipleinheritance: 0 (-x) bytes in 0 (-2) blocks To see details of leaked memory, give 'full' arg to leak_check leak_check summary heuristics length64 LEAK SUMMARY: - definitely lost: 8 (+0) bytes in 1 (+0) blocks + definitely lost: x (+0) bytes in 1 (+0) blocks indirectly lost: 0 (+0) bytes in 0 (+0) blocks - possibly lost: 160 (+32) bytes in 5 (+1) blocks - still reachable: 79 (-32) bytes in 3 (-1) blocks + possibly lost: x (+x) bytes in 5 (+1) blocks + still reachable: x (-x) bytes in 3 (-1) blocks of which reachable via heuristic: - length64 : 31 (+31) bytes in 1 (+1) blocks - newarray : 0 (-63) bytes in 0 (-2) blocks - suppressed: 0 (+0) bytes in 0 (+0) blocks + length64 : x (+x) bytes in 1 (+1) blocks + newarray : 0 (-x) bytes in 0 (-2) blocks To see details of leaked memory, give 'full' arg to leak_check leak_check summary heuristics stdstring LEAK SUMMARY: - definitely lost: 8 (+0) bytes in 1 (+0) blocks + definitely lost: x (+0) bytes in 1 (+0) blocks indirectly lost: 0 (+0) bytes in 0 (+0) blocks - possibly lost: 111 (-49) bytes in 4 (-1) blocks - still reachable: 128 (+49) bytes in 4 (+1) blocks + possibly lost: x (-x) bytes in 4 (-1) blocks + still reachable: x (+x) bytes in 4 (+1) blocks of which reachable via heuristic: - stdstring : 80 (+80) bytes in 2 (+2) blocks - length64 : 0 (-31) bytes in 0 (-1) blocks - suppressed: 0 (+0) bytes in 0 (+0) blocks + stdstring : x (+x) bytes in 2 (+2) blocks + length64 : 0 (-x) bytes in 0 (-1) blocks To see details of leaked memory, give 'full' arg to leak_check leak_check summary heuristics multipleinheritance,newarray,stdstring,length64 LEAK SUMMARY: - definitely lost: 8 (+0) bytes in 1 (+0) blocks + definitely lost: x (+0) bytes in 1 (+0) blocks indirectly lost: 0 (+0) bytes in 0 (+0) blocks - possibly lost: 0 (-111) bytes in 0 (-4) blocks - still reachable: 239 (+111) bytes in 8 (+4) blocks + possibly lost: 0 (-x) bytes in 0 (-4) blocks + still reachable: x (+x) bytes in 8 (+4) blocks of which reachable via heuristic: - stdstring : 80 (+0) bytes in 2 (+0) blocks - length64 : 31 (+31) bytes in 1 (+1) blocks - newarray : 32 (+32) bytes in 1 (+1) blocks - multipleinheritance: 48 (+48) bytes in 2 (+2) blocks - suppressed: 0 (+0) bytes in 0 (+0) blocks + stdstring : x (+0) bytes in 2 (+0) blocks + length64 : x (+x) bytes in 1 (+1) blocks + newarray : x (+x) bytes in 1 (+1) blocks + multipleinheritance: x (+x) bytes in 2 (+2) blocks To see details of leaked memory, give 'full' arg to leak_check leak_check summary heuristics all LEAK SUMMARY: - definitely lost: 8 (+0) bytes in 1 (+0) blocks + definitely lost: x (+0) bytes in 1 (+0) blocks indirectly lost: 0 (+0) bytes in 0 (+0) blocks possibly lost: 0 (+0) bytes in 0 (+0) blocks - still reachable: 239 (+0) bytes in 8 (+0) blocks + still reachable: x (+0) bytes in 8 (+0) blocks of which reachable via heuristic: - stdstring : 80 (+0) bytes in 2 (+0) blocks - length64 : 31 (+0) bytes in 1 (+0) blocks - newarray : 32 (+0) bytes in 1 (+0) blocks - multipleinheritance: 48 (+0) bytes in 2 (+0) blocks - suppressed: 0 (+0) bytes in 0 (+0) blocks + stdstring : x (+0) bytes in 2 (+0) blocks + length64 : x (+0) bytes in 1 (+0) blocks + newarray : x (+0) bytes in 1 (+0) blocks + multipleinheritance: x (+0) bytes in 2 (+0) blocks To see details of leaked memory, give 'full' arg to leak_check leak_check summary heuristics none LEAK SUMMARY: - definitely lost: 8 (+0) bytes in 1 (+0) blocks + definitely lost: x (+0) bytes in 1 (+0) blocks indirectly lost: 0 (+0) bytes in 0 (+0) blocks - possibly lost: 191 (+191) bytes in 6 (+6) blocks - still reachable: 48 (-191) bytes in 2 (-6) blocks + possibly lost: x (+x) bytes in 6 (+6) blocks + still reachable: x (-x) bytes in 2 (-6) blocks of which reachable via heuristic: - stdstring : 0 (-80) bytes in 0 (-2) blocks - length64 : 0 (-31) bytes in 0 (-1) blocks - newarray : 0 (-32) bytes in 0 (-1) blocks - multipleinheritance: 0 (-48) bytes in 0 (-2) blocks - suppressed: 0 (+0) bytes in 0 (+0) blocks + stdstring : 0 (-x) bytes in 0 (-2) blocks + length64 : 0 (-x) bytes in 0 (-1) blocks + newarray : 0 (-x) bytes in 0 (-1) blocks + multipleinheritance: 0 (-x) bytes in 0 (-2) blocks To see details of leaked memory, give 'full' arg to leak_check -Searching for pointers pointing in 20 bytes from 0x........ -*0x........ interior points at 8 bytes inside 0x........ +Searching for pointers pointing in x bytes from 0x........ +*0x........ interior points at x bytes inside 0x........ Address 0x........ is 0 bytes inside data symbol "ptr" block at 0x........ considered reachable by ptr 0x........ using newarray heuristic destruct MyClass @@ -134,7 +126,6 @@ Finished! HEAP SUMMARY: in use at exit: 0 bytes in 0 blocks - total heap usage: 9 allocs, 9 frees, 247 bytes allocated All heap blocks were freed -- no leaks are possible diff --git a/memcheck/tests/leak_cpp_interior.stderr.exp-64bit-solaris b/memcheck/tests/leak_cpp_interior.stderr.exp-64bit-solaris deleted file mode 100644 index f7e1a0718c..0000000000 --- a/memcheck/tests/leak_cpp_interior.stderr.exp-64bit-solaris +++ /dev/null @@ -1,142 +0,0 @@ - -valgrind output will go to log -VALGRIND_DO_LEAK_CHECK -8 bytes in 1 blocks are definitely lost in loss record ... of ... - by 0x........: doit() (leak_cpp_interior.cpp:116) - by 0x........: main (leak_cpp_interior.cpp:131) - -LEAK SUMMARY: - definitely lost: 8 bytes in 1 blocks - indirectly lost: 0 bytes in 0 blocks - possibly lost: 0 bytes in 0 blocks - still reachable: 273 bytes in 8 blocks - of which reachable via heuristic: - stdstring : 114 bytes in 2 blocks - length64 : 31 bytes in 1 blocks - newarray : 32 bytes in 1 blocks - multipleinheritance: 48 bytes in 2 blocks - suppressed: 0 bytes in 0 blocks -Reachable blocks (those to which a pointer was found) are not shown. -To see them, rerun with: --leak-check=full --show-leak-kinds=all - -leak_check summary heuristics multipleinheritance -LEAK SUMMARY: - definitely lost: 8 (+0) bytes in 1 (+0) blocks - indirectly lost: 0 (+0) bytes in 0 (+0) blocks - possibly lost: 177 (+177) bytes in 4 (+4) blocks - still reachable: 96 (-177) bytes in 4 (-4) blocks - of which reachable via heuristic: - stdstring : 0 (-114) bytes in 0 (-2) blocks - length64 : 0 (-31) bytes in 0 (-1) blocks - newarray : 0 (-32) bytes in 0 (-1) blocks - multipleinheritance: 48 (+0) bytes in 2 (+0) blocks - suppressed: 0 (+0) bytes in 0 (+0) blocks -To see details of leaked memory, give 'full' arg to leak_check - -leak_check summary any heuristics newarray -LEAK SUMMARY: - definitely lost: 8 (+0) bytes in 1 (+0) blocks - indirectly lost: 0 (+0) bytes in 0 (+0) blocks - possibly lost: 162 (-15) bytes in 4 (+0) blocks - still reachable: 111 (+15) bytes in 4 (+0) blocks - of which reachable via heuristic: - newarray : 63 (+63) bytes in 2 (+2) blocks - multipleinheritance: 0 (-48) bytes in 0 (-2) blocks - suppressed: 0 (+0) bytes in 0 (+0) blocks -To see details of leaked memory, give 'full' arg to leak_check - -leak_check summary heuristics length64 -LEAK SUMMARY: - definitely lost: 8 (+0) bytes in 1 (+0) blocks - indirectly lost: 0 (+0) bytes in 0 (+0) blocks - possibly lost: 194 (+32) bytes in 5 (+1) blocks - still reachable: 79 (-32) bytes in 3 (-1) blocks - of which reachable via heuristic: - length64 : 31 (+31) bytes in 1 (+1) blocks - newarray : 0 (-63) bytes in 0 (-2) blocks - suppressed: 0 (+0) bytes in 0 (+0) blocks -To see details of leaked memory, give 'full' arg to leak_check - -leak_check summary heuristics stdstring -LEAK SUMMARY: - definitely lost: 8 (+0) bytes in 1 (+0) blocks - indirectly lost: 0 (+0) bytes in 0 (+0) blocks - possibly lost: 111 (-83) bytes in 4 (-1) blocks - still reachable: 162 (+83) bytes in 4 (+1) blocks - of which reachable via heuristic: - stdstring : 114 (+114) bytes in 2 (+2) blocks - length64 : 0 (-31) bytes in 0 (-1) blocks - suppressed: 0 (+0) bytes in 0 (+0) blocks -To see details of leaked memory, give 'full' arg to leak_check - -leak_check summary heuristics multipleinheritance,newarray,stdstring,length64 -LEAK SUMMARY: - definitely lost: 8 (+0) bytes in 1 (+0) blocks - indirectly lost: 0 (+0) bytes in 0 (+0) blocks - possibly lost: 0 (-111) bytes in 0 (-4) blocks - still reachable: 273 (+111) bytes in 8 (+4) blocks - of which reachable via heuristic: - stdstring : 114 (+0) bytes in 2 (+0) blocks - length64 : 31 (+31) bytes in 1 (+1) blocks - newarray : 32 (+32) bytes in 1 (+1) blocks - multipleinheritance: 48 (+48) bytes in 2 (+2) blocks - suppressed: 0 (+0) bytes in 0 (+0) blocks -To see details of leaked memory, give 'full' arg to leak_check - -leak_check summary heuristics all -LEAK SUMMARY: - definitely lost: 8 (+0) bytes in 1 (+0) blocks - indirectly lost: 0 (+0) bytes in 0 (+0) blocks - possibly lost: 0 (+0) bytes in 0 (+0) blocks - still reachable: 273 (+0) bytes in 8 (+0) blocks - of which reachable via heuristic: - stdstring : 114 (+0) bytes in 2 (+0) blocks - length64 : 31 (+0) bytes in 1 (+0) blocks - newarray : 32 (+0) bytes in 1 (+0) blocks - multipleinheritance: 48 (+0) bytes in 2 (+0) blocks - suppressed: 0 (+0) bytes in 0 (+0) blocks -To see details of leaked memory, give 'full' arg to leak_check - -leak_check summary heuristics none -LEAK SUMMARY: - definitely lost: 8 (+0) bytes in 1 (+0) blocks - indirectly lost: 0 (+0) bytes in 0 (+0) blocks - possibly lost: 225 (+225) bytes in 6 (+6) blocks - still reachable: 48 (-225) bytes in 2 (-6) blocks - of which reachable via heuristic: - stdstring : 0 (-114) bytes in 0 (-2) blocks - length64 : 0 (-31) bytes in 0 (-1) blocks - newarray : 0 (-32) bytes in 0 (-1) blocks - multipleinheritance: 0 (-48) bytes in 0 (-2) blocks - suppressed: 0 (+0) bytes in 0 (+0) blocks -To see details of leaked memory, give 'full' arg to leak_check - -Searching for pointers pointing in 20 bytes from 0x........ -*0x........ interior points at 8 bytes inside 0x........ - Address 0x........ is 0 bytes inside data symbol "ptr" -block at 0x........ considered reachable by ptr 0x........ using newarray heuristic -destruct MyClass -destruct MyClass -destruct MyClass -destruct Ce -destruct Be -destruct Ae -destruct Ce -destruct Be -destruct Ae -destruct C -destruct B -destruct A -destruct C -destruct B -destruct A -Finished! - -HEAP SUMMARY: - in use at exit: 0 bytes in 0 blocks - total heap usage: 9 allocs, 9 frees, 281 bytes allocated - -All heap blocks were freed -- no leaks are possible - -For counts of detected and suppressed errors, rerun with: -v -ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) diff --git a/memcheck/tests/leak_cpp_interior.stderr.exp-solaris b/memcheck/tests/leak_cpp_interior.stderr.exp-solaris deleted file mode 100644 index f9fc390bd7..0000000000 --- a/memcheck/tests/leak_cpp_interior.stderr.exp-solaris +++ /dev/null @@ -1,142 +0,0 @@ - -valgrind output will go to log -VALGRIND_DO_LEAK_CHECK -4 bytes in 1 blocks are definitely lost in loss record ... of ... - by 0x........: doit() (leak_cpp_interior.cpp:116) - by 0x........: main (leak_cpp_interior.cpp:131) - -LEAK SUMMARY: - definitely lost: 4 bytes in 1 blocks - indirectly lost: 0 bytes in 0 blocks - possibly lost: 0 bytes in 0 blocks - still reachable: 197 bytes in 8 blocks - of which reachable via heuristic: - stdstring : 90 bytes in 2 blocks - length64 : 31 bytes in 1 blocks - newarray : 28 bytes in 1 blocks - multipleinheritance: 24 bytes in 2 blocks - suppressed: 0 bytes in 0 blocks -Reachable blocks (those to which a pointer was found) are not shown. -To see them, rerun with: --leak-check=full --show-leak-kinds=all - -leak_check summary heuristics multipleinheritance -LEAK SUMMARY: - definitely lost: 4 (+0) bytes in 1 (+0) blocks - indirectly lost: 0 (+0) bytes in 0 (+0) blocks - possibly lost: 149 (+149) bytes in 4 (+4) blocks - still reachable: 48 (-149) bytes in 4 (-4) blocks - of which reachable via heuristic: - stdstring : 0 (-90) bytes in 0 (-2) blocks - length64 : 0 (-31) bytes in 0 (-1) blocks - newarray : 0 (-28) bytes in 0 (-1) blocks - multipleinheritance: 24 (+0) bytes in 2 (+0) blocks - suppressed: 0 (+0) bytes in 0 (+0) blocks -To see details of leaked memory, give 'full' arg to leak_check - -leak_check summary any heuristics newarray -LEAK SUMMARY: - definitely lost: 4 (+0) bytes in 1 (+0) blocks - indirectly lost: 0 (+0) bytes in 0 (+0) blocks - possibly lost: 145 (-4) bytes in 5 (+1) blocks - still reachable: 52 (+4) bytes in 3 (-1) blocks - of which reachable via heuristic: - newarray : 28 (+28) bytes in 1 (+1) blocks - multipleinheritance: 0 (-24) bytes in 0 (-2) blocks - suppressed: 0 (+0) bytes in 0 (+0) blocks -To see details of leaked memory, give 'full' arg to leak_check - -leak_check summary heuristics length64 -LEAK SUMMARY: - definitely lost: 4 (+0) bytes in 1 (+0) blocks - indirectly lost: 0 (+0) bytes in 0 (+0) blocks - possibly lost: 142 (-3) bytes in 5 (+0) blocks - still reachable: 55 (+3) bytes in 3 (+0) blocks - of which reachable via heuristic: - length64 : 31 (+31) bytes in 1 (+1) blocks - newarray : 0 (-28) bytes in 0 (-1) blocks - suppressed: 0 (+0) bytes in 0 (+0) blocks -To see details of leaked memory, give 'full' arg to leak_check - -leak_check summary heuristics stdstring -LEAK SUMMARY: - definitely lost: 4 (+0) bytes in 1 (+0) blocks - indirectly lost: 0 (+0) bytes in 0 (+0) blocks - possibly lost: 83 (-59) bytes in 4 (-1) blocks - still reachable: 114 (+59) bytes in 4 (+1) blocks - of which reachable via heuristic: - stdstring : 90 (+90) bytes in 2 (+2) blocks - length64 : 0 (-31) bytes in 0 (-1) blocks - suppressed: 0 (+0) bytes in 0 (+0) blocks -To see details of leaked memory, give 'full' arg to leak_check - -leak_check summary heuristics multipleinheritance,newarray,stdstring,length64 -LEAK SUMMARY: - definitely lost: 4 (+0) bytes in 1 (+0) blocks - indirectly lost: 0 (+0) bytes in 0 (+0) blocks - possibly lost: 0 (-83) bytes in 0 (-4) blocks - still reachable: 197 (+83) bytes in 8 (+4) blocks - of which reachable via heuristic: - stdstring : 90 (+0) bytes in 2 (+0) blocks - length64 : 31 (+31) bytes in 1 (+1) blocks - newarray : 28 (+28) bytes in 1 (+1) blocks - multipleinheritance: 24 (+24) bytes in 2 (+2) blocks - suppressed: 0 (+0) bytes in 0 (+0) blocks -To see details of leaked memory, give 'full' arg to leak_check - -leak_check summary heuristics all -LEAK SUMMARY: - definitely lost: 4 (+0) bytes in 1 (+0) blocks - indirectly lost: 0 (+0) bytes in 0 (+0) blocks - possibly lost: 0 (+0) bytes in 0 (+0) blocks - still reachable: 197 (+0) bytes in 8 (+0) blocks - of which reachable via heuristic: - stdstring : 90 (+0) bytes in 2 (+0) blocks - length64 : 31 (+0) bytes in 1 (+0) blocks - newarray : 28 (+0) bytes in 1 (+0) blocks - multipleinheritance: 24 (+0) bytes in 2 (+0) blocks - suppressed: 0 (+0) bytes in 0 (+0) blocks -To see details of leaked memory, give 'full' arg to leak_check - -leak_check summary heuristics none -LEAK SUMMARY: - definitely lost: 4 (+0) bytes in 1 (+0) blocks - indirectly lost: 0 (+0) bytes in 0 (+0) blocks - possibly lost: 173 (+173) bytes in 6 (+6) blocks - still reachable: 24 (-173) bytes in 2 (-6) blocks - of which reachable via heuristic: - stdstring : 0 (-90) bytes in 0 (-2) blocks - length64 : 0 (-31) bytes in 0 (-1) blocks - newarray : 0 (-28) bytes in 0 (-1) blocks - multipleinheritance: 0 (-24) bytes in 0 (-2) blocks - suppressed: 0 (+0) bytes in 0 (+0) blocks -To see details of leaked memory, give 'full' arg to leak_check - -Searching for pointers pointing in 20 bytes from 0x........ -*0x........ interior points at 4 bytes inside 0x........ - Address 0x........ is 0 bytes inside data symbol "ptr" -block at 0x........ considered reachable by ptr 0x........ using newarray heuristic -destruct MyClass -destruct MyClass -destruct MyClass -destruct Ce -destruct Be -destruct Ae -destruct Ce -destruct Be -destruct Ae -destruct C -destruct B -destruct A -destruct C -destruct B -destruct A -Finished! - -HEAP SUMMARY: - in use at exit: 0 bytes in 0 blocks - total heap usage: 9 allocs, 9 frees, 201 bytes allocated - -All heap blocks were freed -- no leaks are possible - -For counts of detected and suppressed errors, rerun with: -v -ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) diff --git a/memcheck/tests/leak_cpp_interior.vgtest b/memcheck/tests/leak_cpp_interior.vgtest index 4ecc219023..2fed646d34 100644 --- a/memcheck/tests/leak_cpp_interior.vgtest +++ b/memcheck/tests/leak_cpp_interior.vgtest @@ -1,2 +1,3 @@ prog: leak_cpp_interior -vgopts: --leak-check=summary --leak-check-heuristics=multipleinheritance,stdstring,newarray,length64 +vgopts: --leak-check=summary --leak-check-heuristics=multipleinheritance,stdstring,newarray,length64 --suppressions=libstdc++.supp +stderr_filter: filter_leak_cpp_interior diff --git a/memcheck/tests/libstdc++.supp b/memcheck/tests/libstdc++.supp new file mode 100644 index 0000000000..fad537f79f --- /dev/null +++ b/memcheck/tests/libstdc++.supp @@ -0,0 +1,75 @@ +# Below is a temporary patch (slightly modified) from +# 345307 - Warning about "still reachable" memory when using libstdc++ from gcc 5 +# This patch is not needed anymore if libstdc++ provides __gnu_cxx::__freeres +# but we still need to ignore these allocations during the leak_cpp_interior +# to have the test behaviour not depending on libstdc++ version. + + + +# Some programs are using 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. +# +# Many implementations of the C++ standard libraries use their own memory +# pool allocators. Memory for quite a number of destructed objects is not +# immediately freed and given back to the OS, but kept in the pool(s) for +# later re-use. The fact that the pools are not freed at the exit of the +# program cause Valgrind to report this memory as still reachable. +# +# The behavior not to free pools at the exit could be called a bug of the +# library though. +# +# Using GCC, you can force the STL to use malloc and to free memory as soon +# as possible by globally disabling memory caching. Beware! Doing so will +# probably slow down your program, sometimes drastically. +# +# There are other ways to disable memory pooling: using the malloc_alloc +# template with your objects (not portable, but should work for GCC) or +# even writing your own memory allocators. But beware: allocators belong +# to the more messy parts of the STL and people went to great lengths to +# make the STL portable across platforms. Chances are good that your +# solution will work on your platform, but not on others. +# +# 72,704 bytes in 1 blocks are still reachable in loss record 1 of 1 +# at 0x4C28D06: malloc (vg_replace_malloc.c:299) +# by 0x50C317F: ??? (in /usr/lib64/libstdc++.so.6.0.21) +# by 0x400F759: call_init.part.0 (dl-init.c:72) +# by 0x400F86A: call_init (dl-init.c:30) +# by 0x400F86A: _dl_init (dl-init.c:120) +# by 0x4000CB9: ??? (in /usr/lib64/ld-2.22.so) +# +# HEAP SUMMARY: +# in use at exit: 72,704 bytes in 1 blocks +# total heap usage: 4 allocs, 3 frees, 72,864 bytes allocated +# +# LEAK SUMMARY: +# definitely lost: 0 bytes in 0 blocks +# indirectly lost: 0 bytes in 0 blocks +# possibly lost: 0 bytes in 0 blocks +# still reachable: 72,704 bytes in 1 blocks +# suppressed: 0 bytes in 0 blocks + +{ + malloc-leaks-cxx-stl-string-classes + Memcheck:Leak + match-leak-kinds: reachable + fun:malloc + obj:*lib*/libstdc++.so* + fun:call_init.part.0 + fun:call_init + fun:_dl_init + obj:*lib*/ld-2.*.so +} +{ + malloc-leaks-cxx-stl-string-classes-debug + Memcheck:Leak + match-leak-kinds: reachable + fun:malloc + fun:pool + fun:__static_initialization_and_destruction_0 + fun:_GLOBAL__sub_I_eh_alloc.cc + fun:call_init.part.0 + fun:call_init + fun:_dl_init + obj:*lib*/ld-2.*.so +}