mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-23 18:26:15 +00:00
Checking in Feng Qian's <feng.qian.moz@gmail.com> patch to make XPConnect eagerly attach its thread private data before the JS engine does, ensuring good ordering when the thread (and thus both XPConnect on that thread and the JS runtime) shuts down, thus preventing racing and use of deleted memory. bug 335018, r=brendan
This commit is contained in:
parent
40a16f74c9
commit
da84573ed8
@ -137,6 +137,23 @@ nsJSRuntimeServiceImpl::GetRuntime(JSRuntime **runtime)
|
||||
|
||||
if(!mRuntime)
|
||||
{
|
||||
// Call XPCPerThreadData::GetData to initialize
|
||||
// XPCPerThreadData::gTLSIndex before initializing
|
||||
// JSRuntime::threadTPIndex in JS_NewRuntime.
|
||||
//
|
||||
// XPConnect uses a thread local storage (XPCPerThreadData) indexed by
|
||||
// XPCPerThreadData::gTLSIndex, and SpiderMonkey GC uses a thread local
|
||||
// storage indexed by JSRuntime::threadTPIndex.
|
||||
//
|
||||
// The destructor for XPCPerThreadData::gTLSIndex may access
|
||||
// thread local storage indexed by JSRuntime::threadTPIndex.
|
||||
// Thus, the destructor for JSRuntime::threadTPIndex must be called
|
||||
// later than the one for XPCPerThreadData::gTLSIndex.
|
||||
//
|
||||
// We rely on the implementation of NSPR that calls destructors at
|
||||
// the same order of calling PR_NewThreadPrivateIndex.
|
||||
XPCPerThreadData::GetData();
|
||||
|
||||
mRuntime = JS_NewRuntime(gGCSize);
|
||||
if(!mRuntime)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
Loading…
Reference in New Issue
Block a user