Package: libc6 Version: 2.3.1-17 Severity: normal Tags: upstream When I dlopen() libcrypt.so, call crypt() and then dlclose() it, memory leak occur. I think, crypt() use static pointer initialized on first call to crypt() with malloc, but it isn't freed on _fini()
Here is a test code: #include <dlfcn.h> typedef const char* (*func)(const char*, const char*); int main() { for( int i=0; i<100; i++ ) { void * handle = dlopen( "libcrypt.so", RTLD_LAZY ); func crypt = (func)dlsym( handle, "crypt" ); crypt( "vasq", "$1$" ); dlclose( handle ); } } Here is a valgrind output for this code: % c++ test.cc -ldl % valgrind --leak-check=yes --show-reachable=yes ./a.out ==30343== Memcheck, a.k.a. Valgrind, a memory error detector for x86-linux. ==30343== Copyright (C) 2002, and GNU GPL'd, by Julian Seward. ==30343== Using valgrind-1.9.6, a program instrumentation system for x86-linux. ==30343== Copyright (C) 2000-2002, and GNU GPL'd, by Julian Seward. ==30343== Estimated CPU clock rate is 1003 MHz ==30343== For more details, rerun with: -v ==30343== ==30343== ==30343== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) ==30343== malloc/free: in use at exit: 3400 bytes in 100 blocks. ==30343== malloc/free: 600 allocs, 500 frees, 73200 bytes allocated. ==30343== For counts of detected errors, rerun with: -v ==30343== searching for pointers to 100 not-freed blocks. ==30343== checked 4104836 bytes. ==30343== ==30343== 3400 bytes in 100 blocks are definitely lost in loss record 1 of 1 ==30343== at 0x4015D414: malloc (vg_clientfuncs.c:103) ==30343== by 0x4015D904: realloc (vg_clientfuncs.c:268) ==30343== by 0x4120526F: ??? ==30343== by 0x41204B47: ??? ==30343== ==30343== LEAK SUMMARY: ==30343== definitely lost: 3400 bytes in 100 blocks. ==30343== possibly lost: 0 bytes in 0 blocks. ==30343== still reachable: 0 bytes in 0 blocks. ==30343== suppressed: 0 bytes in 0 blocks. ==30343== -- System Information: Debian Release: testing/unstable Architecture: i386 Kernel: Linux forward 2.4.20-forward #1 SMP ðÔÎ ñÎ× 24 16:19:36 MSK 2003 i686 Locale: LANG=ru_RU.KOI8-R, LC_CTYPE=ru_RU.KOI8-R Versions of packages libc6 depends on: ii libdb1-compat 2.1.3-7 The Berkeley database routines [gl -- no debconf information