Bug 557586 - XPCPerThreadData::~XPCPerThreadData race leading to possible crash r=timeless

This commit is contained in:
Julian Seward 2010-04-22 14:58:41 +02:00
parent a9bd025310
commit 9d2ca11113

View File

@ -387,6 +387,11 @@ XPCPerThreadData::Cleanup()
XPCPerThreadData::~XPCPerThreadData()
{
/* Be careful to ensure that both any update to |gThreads| and the
decision about whether or not to destroy the lock, are done
atomically. See bug 557586. */
PRBool doDestroyLock = PR_FALSE;
MOZ_COUNT_DTOR(xpcPerThreadData);
Cleanup();
@ -410,9 +415,11 @@ XPCPerThreadData::~XPCPerThreadData()
cur = cur->mNextThread;
}
}
if (!gThreads)
doDestroyLock = PR_TRUE;
}
if(gLock && !gThreads)
if(gLock && doDestroyLock)
{
PR_DestroyLock(gLock);
gLock = nsnull;