Valgrind - Suppression file too general?

530 views Asked by At

I'm new to valgrind and the first thing to notice was, that the standard C-Library on OS X El Capitan seems to leak memory (possibly lost). After a little bit more reading this isn't the case and it is possible to exclude the system-lib from the valgrind leak summary with a suppression file.

I generated one such suppression file (by running a simplistic program) and adding the errors to the suppression file. It looks like this:

osx_el_capitan_c_lib.supp

{
  <osx_el_capitan_c_lib>
   Memcheck:Leak
   match-leak-kinds: possible
   fun:malloc_zone_malloc
   fun:_objc_copyClassNamesForImage
   fun:_ZL9protocolsv
   fun:_Z9readClassP10objc_classbb
   fun:gc_init
   fun:_ZL33objc_initializeClassPair_internalP10objc_classPKcS0_S0_
   fun:layout_string_create
   fun:_ZL12realizeClassP10objc_class
   fun:_ZL22copySwiftV1MangledNamePKcb
   fun:_ZL22copySwiftV1MangledNamePKcb
   fun:_ZL22copySwiftV1MangledNamePKcb
   fun:_ZL22copySwiftV1MangledNamePKcb
}

Now I have a few questions:

  • Is it possible that this file will suppress leaks of my actual code (not system-libs)? I tested a little bit with definitely leaking/not leaking code and it seems to work fine. But how can I be sure?
  • A default output current looks like this (definitely not leaking):

    
        ==37004== Memcheck, a memory error detector
        ==37004== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
        ==37004== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
        ==37004== Command: ./val.o
        ==37004== 
        ==37004== 
        ==37004== HEAP SUMMARY:
        ==37004==     in use at exit: 22,100 bytes in 187 blocks
        ==37004==   total heap usage: 271 allocs, 84 frees, 28,340 bytes allocated
        ==37004== 
        ==37004== LEAK SUMMARY:
        ==37004==    definitely lost: 0 bytes in 0 blocks
        ==37004==    indirectly lost: 0 bytes in 0 blocks
        ==37004==      possibly lost: 0 bytes in 0 blocks
        ==37004==    still reachable: 0 bytes in 0 blocks
        ==37004==         suppressed: 22,100 bytes in 187 blocks
        ==37004== 
        ==37004== For counts of detected and suppressed errors, rerun with: -v
        ==37004== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 18 from 18)
    
    
    As you can see the suppression file works pretty good for now (no bytes shown as lost, etc.). But the heap summary doesn't get affected by the suppression file it seems (allocs/mallocs are shown - they happen outside my code) and the leak summary shows suppressed as it's own field. Is there a way I can disable this field (a flag or something) and to suppress the (allocs/mallocs outside my code) in the heap summary as well?
0

There are 0 answers