RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1007762 - Memory leak in nss_Init
Summary: Memory leak in nss_Init
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: nss
Version: 6.5
Hardware: s390x
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Elio Maldonado Batiz
QA Contact: BaseOS QE Security Team
URL:
Whiteboard:
: 888720 (view as bug list)
Depends On:
Blocks: 1071861
TreeView+ depends on / blocked
 
Reported: 2013-09-13 09:32 UTC by Alicja Kario
Modified: 2014-07-03 18:33 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1071861 (view as bug list)
Environment:
Last Closed: 2014-07-02 13:42:19 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 700359 1 None None None 2021-01-20 06:05:38 UTC
Red Hat Bugzilla 769616 0 high CLOSED CKFW leaks memory when loading libnsspem.so after upgrade of nss 2021-02-22 00:41:40 UTC
Red Hat Bugzilla 772628 0 high CLOSED nss_Init() leaks memory 2021-02-22 00:41:40 UTC
Red Hat Bugzilla 823005 1 None None None 2021-01-20 06:05:38 UTC

Internal Links: 700359 769616 772628 823005

Description Alicja Kario 2013-09-13 09:32:17 UTC
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.

Comment 1 Alicja Kario 2013-09-13 09:34:25 UTC
As marked in Hardware section, the issue is s390x specific.

Comment 2 RHEL Program Management 2013-10-14 02:12:19 UTC
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.

Comment 3 Alicja Kario 2013-10-18 11:24:00 UTC
*** Bug 888720 has been marked as a duplicate of this bug. ***

Comment 4 Alicja Kario 2013-12-06 13:41:03 UTC
Still present in nss-3.15.3-2.el6_5.s390x

Comment 7 Bob Relyea 2014-06-25 18:34:00 UTC
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

Comment 8 Alicja Kario 2014-07-02 13:42:19 UTC
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

Comment 9 Kamil Dudka 2014-07-02 16:28:37 UTC
I have pushed a fix upstream for the curl tool (does not affect libcurl):

https://github.com/bagder/curl/commit/24c3cdce

Comment 10 Alicja Kario 2014-07-03 08:51:11 UTC
(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();

Comment 11 Kamil Dudka 2014-07-03 18:33:33 UTC
(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.


Note You need to log in before you can comment on or make changes to this bug.