Open Bug 291225 Opened 20 years ago Updated 2 years ago

NSS_Init leaks memory in failure case

Categories

(NSS :: Libraries, defect, P2)

3.9.5

Tracking

(Not tracked)

People

(Reporter: julien.pierre, Unassigned)

Details

(Keywords: memory-leak, Whiteboard: [redacted:noise] FIPS)

When calling NSS_Init("directory_without_db"), which returns SECFailure, there
is a memory leak, as reported by dbx check leaks below :

Actual leaks report    (actual leaks:            2  total size:        208 bytes)

  Total     Num of  Leaked     Allocation call stack
  Size      Blocks  Block
                    Address
==========  ====== =========== =======================================
       176       1 0x1001111e8  calloc < PR_Calloc < PR_NewMonitor <
nsslowcert_OpenCertDB < sftk_OpenCertDB < sftk_DBInit < SFTK_SlotInit <
nsc_CommonInitialize < NSC_Initialize < secmod_ModuleInit <
SECMOD_LoadPKCS11Module < SECMOD_LoadModule < SECMOD_LoadModule < nss_Init <
NSS_Init < main 
        32       1 0x10010f978  calloc < PR_Calloc < PR_NewMonitor <
nsslowcert_OpenCertDB < sftk_OpenCertDB < sftk_DBInit < SFTK_SlotInit <
nsc_CommonInitialize < NSC_Initialize < secmod_ModuleInit <
SECMOD_LoadPKCS11Module < SECMOD_LoadModule < SECMOD_LoadModule < nss_Init <
NSS_Init < main 
 

Possible leaks report  (possible leaks:          8  total size:       1854 bytes)

  Total     Num of  Leaked     Allocation call stack
  Size      Blocks  Block
                    Address
==========  ====== =========== =======================================
       551       1 0x10010a7d8  PR_Malloc < PL_ArenaAllocate < PORT_ArenaAlloc <
secmod_NewModule < SECMOD_CreateModule < SECMOD_LoadModule < SECMOD_LoadModule <
nss_Init < NSS_Init < main 
       551       1 0x100109e18  PR_Malloc < PL_ArenaAllocate < PORT_ArenaAlloc <
secmod_NewModule < SECMOD_CreateModule < SECMOD_LoadModule < nss_Init < NSS_Init
< main 
       144       1 0x100109cb8  calloc < PR_Calloc < PR_NewLock < PORT_NewArena
< secmod_NewModule < SECMOD_CreateModule < SECMOD_LoadModule < nss_Init <
NSS_Init < main 
       144       1 0x10010a068  calloc < PR_Calloc < PR_NewLock <
secmod_NewModule < SECMOD_CreateModule < SECMOD_LoadModule < nss_Init < NSS_Init
< main 
       144       1 0x10010aa28  calloc < PR_Calloc < PR_NewLock <
secmod_NewModule < SECMOD_CreateModule < SECMOD_LoadModule < SECMOD_LoadModule <
nss_Init < NSS_Init < main 
       144       1 0x10010a728  calloc < PR_Calloc < PR_NewLock < PORT_NewArena
< secmod_NewModule < SECMOD_CreateModule < SECMOD_LoadModule < SECMOD_LoadModule
< nss_Init < NSS_Init < main 
        88       1 0x10010a6a8  calloc < PR_Calloc < PORT_ZAlloc < PORT_NewArena
< secmod_NewModule < SECMOD_CreateModule < SECMOD_LoadModule < SECMOD_LoadModule
< nss_Init < NSS_Init < main 
        88       1 0x100109c38  calloc < PR_Calloc < PORT_ZAlloc < PORT_NewArena
< secmod_NewModule < SECMOD_CreateModule < SECMOD_LoadModule < nss_Init <
NSS_Init < main 
 

execution completed, exit code is 1
(dbx)
Assigning to Neil.
Assignee: wtchang → neil.williams
QA Contact: bishakhabanerjee → jason.m.reid
QA Contact: jason.m.reid → libraries
Priority: -- → P2
Target Milestone: --- → 3.11.2
Retargetting all P2s to 3.11.3 .
Target Milestone: 3.11.2 → 3.11.3
Target Milestone: 3.11.3 → 3.11.8
This would seem like a good one to fix along with the new DB work.
This is not fixed.

My test case is :

1) mkdir nodb
2) certutil -d nodb -L under dbx with check -memuse

Here are the stacks :

Checking for memory leaks...

Actual leaks report    (actual leaks:            2  total size:        128 bytes)

  Total     Num of  Leaked     Allocation call stack
  Size      Blocks  Block
                    Address
==========  ====== =========== =======================================
       104       1  0x80b4b20  calloc < PR_Calloc < PR_NewMonitor < nsslowcert_OpenCertDB < lg_OpenCertDB < legacy_Open < sftkdbCall_open < sftk_DBInit < SFTK_SlotReInit < SFTK_SlotInit < nsc_CommonInitialize < NSC_Initialize < secmod_ModuleInit < SECMOD_LoadPKCS11Module < SECMOD_LoadModule < SECMOD_LoadModule
        24       1  0x808ec68  calloc < PR_Calloc < PR_NewMonitor < nsslowcert_OpenCertDB < lg_OpenCertDB < legacy_Open < sftkdbCall_open < sftk_DBInit < SFTK_SlotReInit < SFTK_SlotInit < nsc_CommonInitialize < NSC_Initialize < secmod_ModuleInit < SECMOD_LoadPKCS11Module < SECMOD_LoadModule < SECMOD_LoadModule


Possible leaks report  (possible leaks:          8  total size:       1510 bytes)

  Total     Num of  Leaked     Allocation call stack
  Size      Blocks  Block
                    Address
==========  ====== =========== =======================================
       535       1  0x808e740  PR_Malloc < PL_ArenaAllocate < PORT_ArenaAlloc_Moved < secmod_NewModule < SECMOD_CreateModule < SECMOD_LoadModule < nss_Init < NSS_Initialize < certutil_main < main
       535       1  0x808edc0  PR_Malloc < PL_ArenaAllocate < PORT_ArenaAlloc_Moved < secmod_NewModule < SECMOD_CreateModule < SECMOD_LoadModule < SECMOD_LoadModule < nss_Init < NSS_Initialize < certutil_main < main
        88       1  0x808e660  calloc < PR_Calloc < PR_NewLock < PORT_NewArena_Moved < secmod_NewModule < SECMOD_CreateModule < SECMOD_LoadModule < nss_Init < NSS_Initialize < certutil_main < main
        88       1  0x808e970  calloc < PR_Calloc < PR_NewLock < secmod_NewModule < SECMOD_CreateModule < SECMOD_LoadModule < nss_Init < NSS_Initialize < certutil_main < main
        88       1  0x808eff0  calloc < PR_Calloc < PR_NewLock < secmod_NewModule < SECMOD_CreateModule < SECMOD_LoadModule < SECMOD_LoadModule < nss_Init < NSS_Initialize < certutil_main < main
        88       1  0x808eb68  calloc < PR_Calloc < PR_NewLock < PORT_NewArena_Moved < secmod_NewModule < SECMOD_CreateModule < SECMOD_LoadModule < SECMOD_LoadModule < nss_Init < NSS_Initialize < certutil_main < main
        44       1  0x808ec10  calloc < PR_Calloc < PORT_ZAlloc_Moved < PORT_NewArena_Moved < secmod_NewModule < SECMOD_CreateModule < SECMOD_LoadModule < SECMOD_LoadModule < nss_Init < NSS_Initialize < certutil_main < main
        44       1  0x808e618  calloc < PR_Calloc < PORT_ZAlloc_Moved < PORT_NewArena_Moved < secmod_NewModule < SECMOD_CreateModule < SECMOD_LoadModule < nss_Init < NSS_Initialize < certutil_main < main

Checking for memory use...

Blocks in use report   (blocks in use:         484  total size:      14999 bytes)

  Total    % of Num of  Avg    Allocation call stack
  Size      All Blocks  Size
========== ==== ====== ======  =======================================
      4816  32%    301     16  PR_Malloc < DefaultAllocEntry < PL_HashTableRawAdd < PL_HashTableAdd < secoid_Init < nsc_CommonInitialize < NSC_Initialize < secmod_ModuleInit < SECMOD_LoadPKCS11Module < SECMOD_LoadModule < SECMOD_LoadModule < nss_Init < NSS_Initialize < certutil_main < main
      2048  13%      1   2048  PR_Malloc < DefaultAllocTable < PL_HashTableRawAdd < PL_HashTableAdd < secoid_Init < nsc_CommonInitialize < NSC_Initialize < secmod_ModuleInit < SECMOD_LoadPKCS11Module < SECMOD_LoadModule < SECMOD_LoadModule < nss_Init < NSS_Initialize < certutil_main < main
       832   5%     52     16  PR_Malloc < DefaultAllocEntry < PL_HashTableRawAdd < PL_HashTableAdd < secoid_Init < nsc_CommonInitialize < NSC_Initialize < secmod_ModuleInit < SECMOD_LoadPKCS11Module < SECMOD_LoadModule < SECMOD_LoadModule < nss_Init < NSS_Initialize < certutil_main < main
       832   5%      8    104  calloc < PR_Calloc < PR_NewMonitor < ExpandMonitorCache < _PR_InitCMon < _PR_InitStuff < _PR_ImplicitInitialization < PR_GetSpecialFD < certutil_main < main
       512   3%      1    512  calloc < PR_Calloc < _PR_InitTPD < _PR_InitStuff < _PR_ImplicitInitialization < PR_GetSpecialFD < certutil_main < main
       256   1%      1    256  PR_Malloc < DefaultAllocTable < PL_HashTableRawAdd < PL_HashTableAdd < secoid_Init < nsc_CommonInitialize < NSC_Initialize < secmod_ModuleInit < SECMOD_LoadPKCS11Module < SECMOD_LoadModule < SECMOD_LoadModule < nss_Init < NSS_Initialize < certutil_main < main
       192   1%      8     24  calloc < PR_Calloc < PR_NewMonitor < ExpandMonitorCache < _PR_InitCMon < _PR_InitStuff < _PR_ImplicitInitialization < PR_GetSpecialFD < certutil_main < main
       128  <1%      1    128  calloc < PR_Calloc < ExpandMonitorCache < _PR_InitCMon < _PR_InitStuff < _PR_ImplicitInitialization < PR_GetSpecialFD < certutil_main < main
       104  <1%      1    104  calloc < PR_Calloc < PR_NewMonitor < _PR_UnixInit < _PR_InitStuff < _PR_ImplicitInitialization < PR_GetSpecialFD < certutil_main < main
       104  <1%      1    104  calloc < PR_Calloc < PR_NewMonitor < OCSP_InitGlobal < nss_Init < NSS_Initialize < certutil_main < main
       104  <1%      1    104  calloc < PR_Calloc < PR_NewMonitor < PR_NewNamedMonitor < _PR_InitLinker < _PR_InitStuff < _PR_ImplicitInitialization < PR_GetSpecialFD < certutil_main < main
        88  <1%      1     88  calloc < PR_Calloc < PR_NewLock < __nss_InitLock_Moved < nsslowcert_InitLocks < legacy_Open < sftkdbCall_open < sftk_DBInit < SFTK_SlotReInit < SFTK_SlotInit < nsc_CommonInitialize < NSC_Initialize < secmod_ModuleInit < SECMOD_LoadPKCS11Module < SECMOD_LoadModule < SECMOD_LoadModule
        88  <1%      1     88  calloc < PR_Calloc < PR_NewLock < pk11_InitSlotListStatic < PK11_InitSlotLists < SECMOD_Init < SECMOD_LoadModule < nss_Init < NSS_Initialize < certutil_main < main
        88  <1%      1     88  calloc < PR_Calloc < PR_NewLock < __nss_InitLock_Moved < nsslowcert_InitLocks < legacy_Open < sftkdbCall_open < sftk_DBInit < SFTK_SlotReInit < SFTK_SlotInit < nsc_CommonInitialize < NSC_Initialize < secmod_ModuleInit < SECMOD_LoadPKCS11Module < SECMOD_LoadModule < SECMOD_LoadModule
        88  <1%      1     88  calloc < PR_Calloc < PR_NewLock < __nss_InitLock_Moved < certdb_InitDBLock < nsslowcert_OpenCertDB < lg_OpenCertDB < legacy_Open < sftkdbCall_open < sftk_DBInit < SFTK_SlotReInit < SFTK_SlotInit < nsc_CommonInitialize < NSC_Initialize < secmod_ModuleInit < SECMOD_LoadPKCS11Module
        88  <1%      1     88  calloc < PR_Calloc < PR_NewLock < __nss_InitLock_Moved < nsslowcert_InitLocks < legacy_Open < sftkdbCall_open < sftk_DBInit < SFTK_SlotReInit < SFTK_SlotInit < nsc_CommonInitialize < NSC_Initialize < secmod_ModuleInit < SECMOD_LoadPKCS11Module < SECMOD_LoadModule < SECMOD_LoadModule
        88  <1%      1     88  calloc < PR_Calloc < PR_NewLock < rng_init < PR_CallOnce < RNG_RNGInit < RNG_RNGInit < nsc_CommonInitialize < NSC_Initialize < secmod_ModuleInit < SECMOD_LoadPKCS11Module < SECMOD_LoadModule < SECMOD_LoadModule < nss_Init < NSS_Initialize < certutil_main
        88  <1%      1     88  calloc < PR_Calloc < PR_NewLock < pk11_InitSlotListStatic < PK11_InitSlotLists < SECMOD_Init < SECMOD_LoadModule < nss_Init < NSS_Initialize < certutil_main < main
        88  <1%      1     88  calloc < PR_Calloc < PR_NewLock < PORT_NewArena_Moved < secoid_InitDynOidData < secoid_Init < nsc_CommonInitialize < NSC_Initialize < secmod_ModuleInit < SECMOD_LoadPKCS11Module < SECMOD_LoadModule < SECMOD_LoadModule < nss_Init < NSS_Initialize < certutil_main < main
        88  <1%      1     88  calloc < PR_Calloc < PR_NewLock < NSSRWLock_New_Moved < nssRWLock_AtomicCreate < secoid_InitDynOidData < secoid_Init < nsc_CommonInitialize < NSC_Initialize < secmod_ModuleInit < SECMOD_LoadPKCS11Module < SECMOD_LoadModule < SECMOD_LoadModule < nss_Init < NSS_Initialize < certutil_main

(note that my tree has the util patch, so move functions in the stack have the word _Moved in them).
I have marked many comments in this bug as "private", which hides them.
It seems that those comments are about a separate issue from the leaks 
reported in comment 0 and comment 12, and their presence in this bug 
caused confusion.  So I am attempting to reduce the confusion, and give
this bug a single clear subject again.  
Assignee: neil.williams → nobody
Target Milestone: 3.11.8 → ---
Whiteboard: [redacted:noise]
We should try to fix this long-standing bug before the next FIPS evaluation.
Whiteboard: [redacted:noise] → [redacted:noise] FIPS
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.