Bug 406360

Summary: memcheck/tests/libstdc++.supp needs more supression variants
Product: [Developer tools] valgrind Reporter: Mark Wielaard <mark>
Component: memcheckAssignee: Julian Seward <jseward>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: 3.15 SVN   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Mark Wielaard 2019-04-09 14:08:53 UTC
memcheck/tests/leak_cpp_interior might fail because depending on compiler and arch used the suppression file used doesn't catch some allocations through the DT_INIT_ARRAY functions.

That memory doesn't actually leak, it gets freed by the __gnu_cxx::__freeres hook. But since this testcase shows leaks while running, not after the program ends, it needs to suppress these allocations.

Proposed new variants (covers issues seen on fedora 30 with x86_64 and ppc64le):

diff --git a/memcheck/tests/libstdc++.supp b/memcheck/tests/libstdc++.supp
index fad537f..28ab182 100644
--- a/memcheck/tests/libstdc++.supp
+++ b/memcheck/tests/libstdc++.supp
@@ -49,6 +49,9 @@
 #    still reachable: 72,704 bytes in 1 blocks
 #         suppressed: 0 bytes in 0 blocks
 
+# All the following suppressions are variants of
+# _dl_init -> call_init which calls the DT_INIT_ARRAY functions
+
 {
    malloc-leaks-cxx-stl-string-classes
    Memcheck:Leak
@@ -61,6 +64,16 @@
    obj:*lib*/ld-2.*.so
 }
 {
+   malloc-leaks-cxx-stl-string-classes-2
+   Memcheck:Leak
+   match-leak-kinds: reachable
+   fun:malloc
+   obj:*lib*/libstdc++.so*
+   fun:call_init.part.0
+   fun:_dl_init
+   obj:*lib*/ld-2.*.so
+}
+{
   malloc-leaks-cxx-stl-string-classes-debug
   Memcheck:Leak
   match-leak-kinds: reachable
@@ -73,3 +86,13 @@
   fun:_dl_init
   obj:*lib*/ld-2.*.so
 }
+{
+   malloc-leaks-cxx-stl-string-classes-debug2
+   Memcheck:Leak
+   match-leak-kinds: reachable
+   fun:malloc
+   obj:*
+   fun:call_init
+   fun:_dl_init
+   fun:_dl_start_user
+}
Comment 1 Mark Wielaard 2019-04-10 15:05:32 UTC
commit 69cbd01e748d161daf5416e1bb969d3530f96335
Author: Mark Wielaard <mark@klomp.org>
Date:   Tue Apr 9 16:09:50 2019 +0200

    More memcheck/tests/libstdc++.supp suppressions
    
    memcheck/tests/leak_cpp_interior might fail because depending on compiler
    and arch used the suppression file used doesn't catch some allocations
    through the DT_INIT_ARRAY functions.
    
    That memory doesn't actually leak, it gets freed by the
    __gnu_cxx::__freeres hook. But since this testcase shows leaks while
    running, not after the program ends, it needs to suppress these allocations.
    
    https://bugs.kde.org/show_bug.cgi?id=406360