Valgrind detects possibly lost memory despite suppressions
I am using GLib 2.66.4 on Fedora 33.
On this machine, I created a very simple C program, compiled it using GCC 10.2.1, and linked it to the GObject library:
$ cat main.c
int main() {
return 0;
}
$ gcc main.c `pkg-config --libs gobject-2.0` -o main
Without suppressions, Valgrind detects a large amount of possibly lost memory:
$ valgrind --leak-check=full ./main
==19032== Memcheck, a memory error detector
==19032== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==19032== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==19032== Command: ./main
==19032==
==19032==
==19032== HEAP SUMMARY:
==19032== in use at exit: 36,860 bytes in 232 blocks
==19032== total heap usage: 288 allocs, 56 frees, 45,284 bytes allocated
==19032==
==19032== 16 bytes in 1 blocks are possibly lost in loss record 89 of 232
==19032== at 0x483BAE9: calloc (vg_replace_malloc.c:760)
==19032== by 0x491DFA0: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.6600.4)
==19032== by 0x489A776: ??? (in /usr/lib64/libgobject-2.0.so.0.6600.4)
==19032== by 0x489B27E: g_type_register_fundamental (in /usr/lib64/libgobject-2.0.so.0.6600.4)
==19032== by 0x4878558: ??? (in /usr/lib64/libgobject-2.0.so.0.6600.4)
==19032== by 0x40108ED: call_init.part.0 (in /usr/lib64/ld-2.32.so)
==19032== by 0x40109D7: _dl_init (in /usr/lib64/ld-2.32.so)
==19032== by 0x40010C9: ??? (in /usr/lib64/ld-2.32.so)
[...]
==19032==
==19032== LEAK SUMMARY:
==19032== definitely lost: 0 bytes in 0 blocks
==19032== indirectly lost: 0 bytes in 0 blocks
==19032== possibly lost: 1,352 bytes in 18 blocks
==19032== still reachable: 35,508 bytes in 214 blocks
==19032== of which reachable via heuristic:
==19032== newarray : 1,536 bytes in 16 blocks
==19032== suppressed: 0 bytes in 0 blocks
==19032== Reachable blocks (those to which a pointer was found) are not shown.
==19032== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==19032==
==19032== For lists of detected and suppressed errors, rerun with: -s
==19032== ERROR SUMMARY: 18 errors from 18 contexts (suppressed: 0 from 0)
Applying the GLib suppressions file takes care of most of the errors. However, one such error remains:
$ valgrind --suppressions=/usr/share/glib-2.0/valgrind/glib.supp --leak-check=full ./main
==19244== Memcheck, a memory error detector
==19244== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==19244== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==19244== Command: ./main
==19244==
==19244==
==19244== HEAP SUMMARY:
==19244== in use at exit: 36,860 bytes in 232 blocks
==19244== total heap usage: 288 allocs, 56 frees, 45,284 bytes allocated
==19244==
==19244== 96 bytes in 1 blocks are possibly lost in loss record 212 of 232
==19244== at 0x483BAE9: calloc (vg_replace_malloc.c:760)
==19244== by 0x491DFA0: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.6600.4)
==19244== by 0x488FA8F: ??? (in /usr/lib64/libgobject-2.0.so.0.6600.4)
==19244== by 0x48908F2: ??? (in /usr/lib64/libgobject-2.0.so.0.6600.4)
==19244== by 0x4877E3C: ??? (in /usr/lib64/libgobject-2.0.so.0.6600.4)
==19244== by 0x40108ED: call_init.part.0 (in /usr/lib64/ld-2.32.so)
==19244== by 0x40109D7: _dl_init (in /usr/lib64/ld-2.32.so)
==19244== by 0x40010C9: ??? (in /usr/lib64/ld-2.32.so)
==19244==
==19244== LEAK SUMMARY:
==19244== definitely lost: 0 bytes in 0 blocks
==19244== indirectly lost: 0 bytes in 0 blocks
==19244== possibly lost: 96 bytes in 1 blocks
==19244== still reachable: 25,798 bytes in 44 blocks
==19244== of which reachable via heuristic:
==19244== newarray : 1,536 bytes in 16 blocks
==19244== suppressed: 10,966 bytes in 187 blocks
==19244== Reachable blocks (those to which a pointer was found) are not shown.
==19244== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==19244==
==19244== For lists of detected and suppressed errors, rerun with: -s
==19244== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 17 from 17)
Is this a false positive? And if it is: Can it be fixed by an additional rule in the suppressions file?
Edited by Ghost User