Closed
Bug 679524
Opened 14 years ago
Closed 14 years ago
Crash in NSS when using NSS_InitContext
Categories
(NSS :: Libraries, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
3.13
People
(Reporter: elio.maldonado.batiz, Assigned: rrelyea)
References
Details
Attachments
(3 files)
|
28.26 KB,
text/plain
|
Details | |
|
5.90 KB,
patch
|
elio.maldonado.batiz
:
superreview+
|
Details | Diff | Splinter Review |
|
866 bytes,
patch
|
rrelyea
:
review+
|
Details | Diff | Splinter Review |
As reported by Rich Meggison
This is with the latest NSS on RHEL 6.1
Name : nss Relocations: (not relocatable)
Version : 3.12.9 Vendor: Red Hat, Inc.
Release : 9.el6 Build Date: Thu 21 Apr 2011 03:10:06 PM MDT
The stack trace is attached. The code has two threads calling NSS_InitContext at the same time. The crash occurs in SECOID_Init. I don't believe this barrier is sufficient:
if (oidhash) {
return SECSuccess; /* already initialized */
}
The crash occurs here:
for ( i = 0; i < SEC_OID_TOTAL; i++ ) {
oid = &oids[i];
PORT_Assert ( oid->offset == i );
-> entry = PL_HashTableAdd( oidhash, &oid->oid, (void *)oid );
because there are two different threads accessing oidhash at the same time.
It's not easy to reproduce because it is a timing thing, but I suppose I could try to write a small test program.
| Assignee | ||
Comment 1•14 years ago
|
||
Traditionally NSS was initialized once for an application. This code still expects the application wide initialization to happen once. Now, however, various libraries can now initialize NSS on the fly. Often these libraries will initialize NSS use it, then shut it down (because the library doesn't have any forward carrying state). It's also possible that these libraries may be working on different threads, thus making it possible for NSS_Init and NSS_Shutdown to be called on different threads at the same time.
this code protects the various NSS initialization routines from multiple calls. The locks NSS uses to protect this are now leaked because it's not safe to free them at shutdown (as they may still be in use).
bob
Assignee: nobody → rrelyea
Status: NEW → ASSIGNED
Attachment #553640 -
Flags: superreview?(emaldona)
Attachment #553640 -
Flags: review?(wtc)
| Reporter | ||
Comment 2•14 years ago
|
||
Comment on attachment 553640 [details] [diff] [review]
Allow only one thread to init and shutdown at a time.
r+ from me.
Attachment #553640 -
Flags: superreview?(emaldona) → superreview+
| Assignee | ||
Comment 3•14 years ago
|
||
cvs commit: Examining .
Checking in nssinit.c;
/cvsroot/mozilla/security/nss/lib/nss/nssinit.c,v <-- nssinit.c
new revision: 1.109; previous revision: 1.108
done
wtc, you can still review this if you want. If you have any comments that need addressing just reopen the bug, otherwise you can just clear the review flag.
bob
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Comment 4•14 years ago
|
||
This fixes compilation error on Windows. I think it
should also fix some test failures on other platforms.
Patch checked in on the NSS trunk (NSS 3.13).
Checking in nssinit.c;
/cvsroot/mozilla/security/nss/lib/nss/nssinit.c,v <-- nssinit.c
new revision: 1.110; previous revision: 1.109
done
Attachment #556977 -
Flags: review?(rrelyea)
Comment 5•14 years ago
|
||
Bob: I didn't get your comment 3 because I was not
on the cc list. Sorry about the late review. I
will review your patch later.
Target Milestone: --- → 3.13
Comment 6•14 years ago
|
||
Comment on attachment 553640 [details] [diff] [review]
Allow only one thread to init and shutdown at a time.
This patch causes all the NSS "memleak" tinderboxes to fail
because it introduces two memory leaks:
NEW STACK: vfychain/main/NSS_Init/nss_Init/PR_CallOnce/nss_doLockInit/PR_NewCondVar/PR_Malloc/malloc
NEW STACK: vfychain/main/NSS_Init/nss_Init/PR_CallOnce/nss_doLockInit/PR_NewLock/PR_Calloc/calloc
Other examples:
NEW STACK: selfserv/main/NSS_Initialize/nss_Init/PR_CallOnce/nss_doLockInit/PR_NewCondVar/PR_Malloc/malloc
NEW STACK: selfserv/main/NSS_Initialize/nss_Init/PR_CallOnce/nss_doLockInit/PR_NewLock/PR_Calloc/calloc
NEW STACK: strsclnt/main/NSS_Initialize/nss_Init/PR_CallOnce/nss_doLockInit/PR_NewCondVar/PR_Malloc/malloc
NEW STACK: strsclnt/main/NSS_Initialize/nss_Init/PR_CallOnce/nss_doLockInit/PR_NewLock/PR_Calloc/calloc
NEW STACK: ocspclnt/main/NSS_Init/nss_Init/PR_CallOnce/nss_doLockInit/PR_NewCondVar/PR_Malloc/malloc
NEW STACK: ocspclnt/main/NSS_Init/nss_Init/PR_CallOnce/nss_doLockInit/PR_NewLock/PR_Calloc/calloc
We need to fix the memory leaks, or arrange for the "memleak"
tinderboxes to ignore these two memory leak call stacks.
| Assignee | ||
Comment 7•14 years ago
|
||
They should be on the ignore list. The introduction of a new one-time leak with this patch is already known.
The stack should be */nss_init/PR_CallOnce/nss_doLockInit/*
wtc, do you remember where the exclude stack files are?
bob
Comment 8•14 years ago
|
||
Bob: I don't remember. I always asked Slavo to exclude memory
leak call stacks for me. If the exclude stack files are in the
NSS CVS tree, they should be under mozilla/security/nss/tests.
I hope they are not just on the "memleak" tinderboxes' file
systems.
Comment 9•14 years ago
|
||
Bob: I found the file of ignored leak stacks:
http://mxr.mozilla.org/security/find?text=&string=leak
Could you add the stack to mozilla/security/nss/tests/memleak/ignored?
Thanks.
| Assignee | ||
Comment 10•14 years ago
|
||
dhcp-227.sjc.redhat.com(57) cvs commit
cvs commit: Examining .
Checking in ignored;
/cvsroot/mozilla/security/nss/tests/memleak/ignored,v <-- ignored
new revision: 1.81; previous revision: 1.80
done
Comment 11•14 years ago
|
||
Bob: the leak stack that you checked in has nss_init.
I think "init" needs to be capitalized: nss_Init.
Comment 12•14 years ago
|
||
The CVS commit message referenced the wrong bug number 679424.
(The bug number is the tests/memleak/ignored file is correct.)
Comment 13•14 years ago
|
||
Fixed typo nss_init => nss_Init.
Checking in ignored;
/cvsroot/mozilla/security/nss/tests/memleak/ignored,v <-- ignored
new revision: 1.82; previous revision: 1.81
done
| Assignee | ||
Comment 14•14 years ago
|
||
Comment on attachment 556977 [details] [diff] [review]
Add a missing return statement to NSS_Shutdown
r+ rrelyea
Attachment #556977 -
Flags: review?(rrelyea) → review+
| Assignee | ||
Comment 16•14 years ago
|
||
Comment on attachment 553640 [details] [diff] [review]
Allow only one thread to init and shutdown at a time.
clearing review request
Attachment #553640 -
Flags: review?(wtc)
You need to log in
before you can comment on or make changes to this bug.
Description
•