Closed
Bug 1278608
Opened 8 years ago
Closed 8 years ago
Handle attempts to instantiate JS components on non-main threads somewhat better
Categories
(Core :: XPConnect, defect)
Core
XPConnect
Tracking
()
RESOLVED
FIXED
mozilla50
Tracking | Status | |
---|---|---|
firefox50 | --- | fixed |
People
(Reporter: bzbarsky, Assigned: bzbarsky)
Details
(Whiteboard: btpp-backlog)
Attachments
(1 file)
1.07 KB,
patch
|
bholley
:
review+
|
Details | Diff | Splinter Review |
This came up in bug 1278605, where PSM tries to instantiate a JS-implemented service on some socket thread. We end up crashing with a stack like this: 0 XUL!mozilla::dom::workers::GetCurrentThreadJSContext() [CycleCollectedJSRuntime.h:b0310cb90fd0 : 317 + 0x0] 1 XUL!<name omitted> [ScriptSettings.cpp:b0310cb90fd0 : 381 + 0x5] 2 XUL!mozJSComponentLoader::LoadModule(mozilla::FileLocation&) [mozJSComponentLoader.cpp:b0310cb90fd0 : 370 + 0x8] 3 XUL!nsFactoryEntry::GetFactory() [nsComponentManager.cpp:b0310cb90fd0 : 861 + 0x3] 4 XUL!nsComponentManagerImpl::CreateInstanceByContractID(char const*, nsISupports*, nsID const&, void**) [nsComponentManager.cpp:b0310cb90fd0 : 1200 + 0x8] 5 XUL!nsComponentManagerImpl::GetServiceByContractID(char const*, nsID const&, void**) [nsComponentManager.cpp:b0310cb90fd0 : 1559 + 0x11] Now we got lucky. This was a non-main thread, so when we tried to set up an AutoJSAPI we went to workers::GetCurrentThreadJSContext() which does GetCurrentThreadWorkerPrivate(), which does: 1291 CycleCollectedJSRuntime* ccrt = CycleCollectedJSRuntime::Get(); 1274 JSRuntime* rt = ccrt->Runtime(); etc. I'm not sure where we end up with null here, but it doesn't matter here too much: at some point we do and crash. But we could have gotten unlucky: if someone tried to instantiate a JS-implemented component on a _worker_ thread, this would all work and we'd just press on here. Is there a reason we can't just make mozJSComponentLoader::LoadModule bail out if !NS_IsMainThread()?
Assignee | ||
Updated•8 years ago
|
Flags: needinfo?(bzbarsky)
ccrt will be null on any thread that isn't running the cycle collector, which should be all non-DOM threads.
Assignee | ||
Comment 2•8 years ago
|
||
Right, what I'm not sure is why the crash stack claims we crash under the ccrt->Runtime() call given the null -check. But that's really pretty incidental to the main point of this bug. ;)
Ah, I see. But yes, largely irrelevant. I agree we should be smarter here.
Comment 4•8 years ago
|
||
Feel free to change this from backlog if you disagree.
Whiteboard: btpp-backlog
Assignee | ||
Comment 5•8 years ago
|
||
Bobby, see comment 0?
Flags: needinfo?(bzbarsky) → needinfo?(bobbyholley)
Comment 6•8 years ago
|
||
(In reply to Boris Zbarsky [:bz] from comment #0) > Is there a reason we can't just make mozJSComponentLoader::LoadModule bail > out if !NS_IsMainThread()? SGTM.
Flags: needinfo?(bobbyholley)
Assignee | ||
Comment 7•8 years ago
|
||
Attachment #8765010 -
Flags: review?(bobbyholley)
Assignee | ||
Updated•8 years ago
|
Assignee: nobody → bzbarsky
Status: NEW → ASSIGNED
Comment 8•8 years ago
|
||
Comment on attachment 8765010 [details] [diff] [review] Just bail out of mozJSComponentLoader::LoadModule if it's called on a non-main thread Review of attachment 8765010 [details] [diff] [review]: ----------------------------------------------------------------- Thanks.
Attachment #8765010 -
Flags: review?(bobbyholley) → review+
Pushed by bzbarsky@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/2b7c2618bc03 Just bail out of mozJSComponentLoader::LoadModule if it's called on a non-main thread. r=bholley
Comment 10•8 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/2b7c2618bc03
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
status-firefox50:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla50
You need to log in
before you can comment on or make changes to this bug.
Description
•