Hide Forgot
Description of problem: When running reproducer for bug 769616, valgrind reports a memory leak. Version-Release number of selected component (if applicable): nss-3.15.1-3.el6.s390x How reproducible: Always Steps to Reproduce: cat <<EOF > ckfw_leaks_memory.c #include <assert.h> #include <nss.h> #include <secmod.h> #include <stdlib.h> int main() { if (0 != NSS_NoDB_Init(NULL)) assert(0); for (int i = 0; i < 256; ++i) { SECMODModule* mod = SECMOD_LoadUserModule("library=libnsspem.so name=PEM", NULL, PR_FALSE); if(!mod || !mod->loaded) assert(0); SECMOD_UnloadUserModule(mod); SECMOD_DestroyModule(mod); } NSS_Shutdown(); return EXIT_SUCCESS; } EOF gcc ckfw_leaks_memory.c -o ckfw_leaks_memory -g -std=c99 -pedantic -W -Wall -I/usr/include/nss3 -I/usr/include/nspr4 -lnss3 LD_PRELOAD=libnsspem.so valgrind --leak-check=full --error-exitcode=7 ./ckfw_leaks_memory Actual results: ==15960== Memcheck, a memory error detector ==15960== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al. ==15960== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info ==15960== Command: ./ckfw_leaks_memory ==15960== ==15960== ==15960== HEAP SUMMARY: ==15960== in use at exit: 10,585 bytes in 89 blocks ==15960== total heap usage: 83,922 allocs, 83,833 frees, 35,332,256 bytes allocated ==15960== ==15960== 272 bytes in 1 blocks are definitely lost in loss record 68 of 75 ==15960== at 0x402BA84: calloc (vg_replace_malloc.c:593) ==15960== by 0x43ADCB3: _PR_InitThreads (ptthread.c:939) ==15960== by 0x439D517: _PR_InitStuff (prinit.c:180) ==15960== by 0x439D7AD: PR_CallOnce (prinit.c:219) ==15960== by 0x408E9C9: nss_Init (nssinit.c:548) ==15960== by 0x408F943: NSS_NoDB_Init (nssinit.c:874) ==15960== by 0x800008DD: main (ckfw_leaks_memory.c:7) ==15960== ==15960== LEAK SUMMARY: ==15960== definitely lost: 272 bytes in 1 blocks ==15960== indirectly lost: 0 bytes in 0 blocks ==15960== possibly lost: 0 bytes in 0 blocks ==15960== still reachable: 10,313 bytes in 88 blocks ==15960== suppressed: 0 bytes in 0 blocks ==15960== Reachable blocks (those to which a pointer was found) are not shown. ==15960== To see them, rerun with: --leak-check=full --show-reachable=yes ==15960== ==15960== For counts of detected and suppressed errors, rerun with: -v ==15960== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 264 from 8) Expected results: No memory leaks Additional info: This bug might have been introduced by errata 12964, but couldn't be detected because of bug 823005 and issues described in bug 700359. This is NOT a regresion from 6.4.z.
As marked in Hardware section, the issue is s390x specific.
This request was not resolved in time for the current release. Red Hat invites you to ask your support representative to propose this request, if still desired, for consideration in the next release of Red Hat Enterprise Linux.
*** Bug 888720 has been marked as a duplicate of this bug. ***
Still present in nss-3.15.3-2.el6_5.s390x
This is actually a test case error. Your testcase needs to call PR_Cleanup() if you want to test for memory leaks. The leaks are nspr globals, which get allocated once the first NSPR use and stay in use until PR_Cleanup(). bob
As said in Comment #7, issue in test case. After changes: ==38193== LEAK SUMMARY: ==38193== definitely lost: 0 bytes in 0 blocks ==38193== indirectly lost: 0 bytes in 0 blocks ==38193== possibly lost: 0 bytes in 0 blocks ==38193== still reachable: 1,447 bytes in 10 blocks ==38193== suppressed: 0 bytes in 0 blocks
I have pushed a fix upstream for the curl tool (does not affect libcurl): https://github.com/bagder/curl/commit/24c3cdce
(In reply to Kamil Dudka from comment #9) > I have pushed a fix upstream for the curl tool (does not affect libcurl): > > https://github.com/bagder/curl/commit/24c3cdce I'm not sure if the first one is needed, but we settled in for two cleanup commands from nspr: PL_ArenaFinish(); PR_Cleanup();
(In reply to Hubert Kario from comment #10) > I'm not sure if the first one is needed, but we settled in for two cleanup > commands from nspr: > > PL_ArenaFinish(); > PR_Cleanup(); Thanks! I have added the call to PL_ArenaFinish(): https://github.com/bagder/curl/commit/d343033f It eliminates some of the "still reachable" memory reported by valgrind.