Hello, I am fixing leaks in one of my software projects that embeds libltdl 2.4.2 to load plugins. I noticed that when the plugin depends on the dynamic library that the main program doesn't depend on, valgrind reports some leaks.
We created a small testcase reproducing the problem. It's available at http://www.open-mpi.org/~jsquyres/ltdl-valgrind-leaks/ Just download it, ./configure, make, make install and then run valgrind as shown below. If we remove the reference to pthread in the plugin, the leaks go away. I assume that libltdl doesn't unload these dependency libraries when the plugin is unloaded. But I'd like to know if these leaks are expected or not. The good news is that these leaks do not depend on the number of times this code is executed within the program, so the leaked size should be constant. Regards Brice Goglin $ valgrind --leak-check=full --show-reachable=yes ./runme ==1446== Memcheck, a memory error detector ==1446== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al. ==1446== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info ==1446== Command: ./runme ==1446== ==1446== ==1446== HEAP SUMMARY: ==1446== in use at exit: 1,748 bytes in 6 blocks ==1446== total heap usage: 52 allocs, 46 frees, 7,393 bytes allocated ==1446== ==1446== 32 bytes in 1 blocks are still reachable in loss record 1 of 6 ==1446== at 0x402894D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==1446== by 0x4013197: _dl_close_worker (dl-close.c:374) ==1446== by 0x401371D: _dl_close (dl-close.c:754) ==1446== by 0x400D925: _dl_catch_error (dl-error.c:178) ==1446== by 0x4E2D2EB: _dlerror_run (dlerror.c:164) ==1446== by 0x4E2D00E: dlclose (dlclose.c:48) ==1446== by 0x4C297BB: ??? (in /usr/lib/x86_64-linux-gnu/libltdl.so.7.3.0) ==1446== by 0x4C276EC: lt_dlclose (in /usr/lib/x86_64-linux-gnu/libltdl.so.7.3.0) ==1446== by 0x400C6F: main (runme.c:31) ==1446== ==1446== 38 bytes in 1 blocks are still reachable in loss record 2 of 6 ==1446== at 0x402894D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==1446== by 0x4004E21: local_strdup (dl-load.c:162) ==1446== by 0x4007929: _dl_map_object (dl-load.c:2373) ==1446== by 0x400CF61: openaux (dl-deps.c:65) ==1446== by 0x400D925: _dl_catch_error (dl-error.c:178) ==1446== by 0x400C02B: _dl_map_object_deps (dl-deps.c:247) ==1446== by 0x4011EB7: dl_open_worker (dl-open.c:263) ==1446== by 0x400D925: _dl_catch_error (dl-error.c:178) ==1446== by 0x4011899: _dl_open (dl-open.c:633) ==1446== by 0x4E2CF65: dlopen_doit (dlopen.c:67) ==1446== by 0x400D925: _dl_catch_error (dl-error.c:178) ==1446== by 0x4E2D2EB: _dlerror_run (dlerror.c:164) ==1446== ==1446== 38 bytes in 1 blocks are still reachable in loss record 3 of 6 ==1446== at 0x402894D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==1446== by 0x400AA85: _dl_new_object (dl-object.c:161) ==1446== by 0x4005FB5: _dl_map_object_from_fd (dl-load.c:957) ==1446== by 0x40076B7: _dl_map_object (dl-load.c:2468) ==1446== by 0x400CF61: openaux (dl-deps.c:65) ==1446== by 0x400D925: _dl_catch_error (dl-error.c:178) ==1446== by 0x400C02B: _dl_map_object_deps (dl-deps.c:247) ==1446== by 0x4011EB7: dl_open_worker (dl-open.c:263) ==1446== by 0x400D925: _dl_catch_error (dl-error.c:178) ==1446== by 0x4011899: _dl_open (dl-open.c:633) ==1446== by 0x4E2CF65: dlopen_doit (dlopen.c:67) ==1446== by 0x400D925: _dl_catch_error (dl-error.c:178) ==1446== ==1446== 56 bytes in 1 blocks are still reachable in loss record 4 of 6 ==1446== at 0x402894D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==1446== by 0x400C0DC: _dl_map_object_deps (dl-deps.c:470) ==1446== by 0x4011EB7: dl_open_worker (dl-open.c:263) ==1446== by 0x400D925: _dl_catch_error (dl-error.c:178) ==1446== by 0x4011899: _dl_open (dl-open.c:633) ==1446== by 0x4E2CF65: dlopen_doit (dlopen.c:67) ==1446== by 0x400D925: _dl_catch_error (dl-error.c:178) ==1446== by 0x4E2D2EB: _dlerror_run (dlerror.c:164) ==1446== by 0x4E2CEE0: dlopen@@GLIBC_2.2.5 (dlopen.c:88) ==1446== by 0x4C29806: ??? (in /usr/lib/x86_64-linux-gnu/libltdl.so.7.3.0) ==1446== by 0x4C26919: ??? (in /usr/lib/x86_64-linux-gnu/libltdl.so.7.3.0) ==1446== by 0x4C26B97: ??? (in /usr/lib/x86_64-linux-gnu/libltdl.so.7.3.0) ==1446== ==1446== 408 bytes in 1 blocks are still reachable in loss record 5 of 6 ==1446== at 0x4027034: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==1446== by 0x400F4D3: _dl_check_map_versions (dl-version.c:299) ==1446== by 0x401238E: dl_open_worker (dl-open.c:269) ==1446== by 0x400D925: _dl_catch_error (dl-error.c:178) ==1446== by 0x4011899: _dl_open (dl-open.c:633) ==1446== by 0x4E2CF65: dlopen_doit (dlopen.c:67) ==1446== by 0x400D925: _dl_catch_error (dl-error.c:178) ==1446== by 0x4E2D2EB: _dlerror_run (dlerror.c:164) ==1446== by 0x4E2CEE0: dlopen@@GLIBC_2.2.5 (dlopen.c:88) ==1446== by 0x4C29806: ??? (in /usr/lib/x86_64-linux-gnu/libltdl.so.7.3.0) ==1446== by 0x4C26919: ??? (in /usr/lib/x86_64-linux-gnu/libltdl.so.7.3.0) ==1446== by 0x4C26B97: ??? (in /usr/lib/x86_64-linux-gnu/libltdl.so.7.3.0) ==1446== ==1446== 1,176 bytes in 1 blocks are still reachable in loss record 6 of 6 ==1446== at 0x4027034: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==1446== by 0x400A80E: _dl_new_object (dl-object.c:77) ==1446== by 0x4005FB5: _dl_map_object_from_fd (dl-load.c:957) ==1446== by 0x40076B7: _dl_map_object (dl-load.c:2468) ==1446== by 0x400CF61: openaux (dl-deps.c:65) ==1446== by 0x400D925: _dl_catch_error (dl-error.c:178) ==1446== by 0x400C02B: _dl_map_object_deps (dl-deps.c:247) ==1446== by 0x4011EB7: dl_open_worker (dl-open.c:263) ==1446== by 0x400D925: _dl_catch_error (dl-error.c:178) ==1446== by 0x4011899: _dl_open (dl-open.c:633) ==1446== by 0x4E2CF65: dlopen_doit (dlopen.c:67) ==1446== by 0x400D925: _dl_catch_error (dl-error.c:178) ==1446== ==1446== LEAK SUMMARY: ==1446== definitely lost: 0 bytes in 0 blocks ==1446== indirectly lost: 0 bytes in 0 blocks ==1446== possibly lost: 0 bytes in 0 blocks ==1446== still reachable: 1,748 bytes in 6 blocks ==1446== suppressed: 0 bytes in 0 blocks ==1446== ==1446== For counts of detected and suppressed errors, rerun with: -v ==1446== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 4) _______________________________________________ https://lists.gnu.org/mailman/listinfo/libtool