Closed
Bug 1174381
Opened 9 years ago
Closed 9 years ago
ServiceWorkerManager shutdown violates XPCOM threading rules and leaks
Categories
(Core :: DOM: Service Workers, defect)
Core
DOM: Service Workers
Tracking
()
RESOLVED
FIXED
mozilla41
Tracking | Status | |
---|---|---|
firefox41 | --- | fixed |
People
(Reporter: jesup, Assigned: baku)
References
Details
(Keywords: memory-leak)
Attachments
(1 file)
(deleted),
patch
|
nsm
:
review+
|
Details | Diff | Splinter Review |
Since the recent landing of bug 1155153 (I think), the ServiceWorkerManager code is using DispatchToMainThread() from nsComponentManagerImpl::gComponentManager->FreeServices() in XPCOM shutdown - this happens after xpcom-shutdown-threads, nsThreadManager shutdown, etc. At this point DispatchToMainThread() will always fail and leak, which is what I've been seeing with some dispatch changes I've been working on.
This is trying to send a Shutdown message via mActor (i.e. PBackground IPC). Of course, it's way too late to do so at this point. Likely this needs to occur at xpcom-shutdown or even xpcom-will-shutdown (earlier?).
It's especially ironic as the DispatchToMainThread call is being made from Mainthread.
Compare https://treeherder.mozilla.org/#/jobs?repo=try&revision=16d4ff3305c8 to https://treeherder.mozilla.org/#/jobs?repo=try&revision=1c1a548aac7a, which are the same code under 'try' sitting on top of a different base (first is the 'after' shot; second Try link is the 'first' Try link.
Reporter | ||
Comment 1•9 years ago
|
||
Even slightly more ironically, if the Dispatch had succeeded I think it would have asserted, as SendShutdown() (in TeardownRunnable) is worker-thread-only (I tried replacing the Dispatch with just a call to the SendShutdown() directly and it asserted). I'd previously verified (at least in a non-e10s run) that ~ServiceWorkerManager() runs on MainThread() (per comment 0 here).
Side note: AssertWorkerThread() called that late in shutdown causes an ASAN hit as well. Of course, one shouldn't be doing that. (NI-ing bent on this - something in "MOZ_RELEASE_ASSERT(mWorkerLoopID == MessageLoop::current()->id(), "...."); is reading freed memory in that case, perhaps MessageLoop::current() is returning a stale ptr.
Flags: needinfo?(bent.mozilla)
Updated•9 years ago
|
Blocks: ServiceWorkers-v1
Updated•9 years ago
|
Component: DOM: Workers → DOM: Service Workers
Flags: needinfo?(nsm.nikhil)
Flags: needinfo?(bkelly)
Flags: needinfo?(bent.mozilla)
Comment 2•9 years ago
|
||
Andrea, Nikhil, do you have any ideas here? I'm not that familiar with the ServiceWorkerManager threading model.
Flags: needinfo?(bkelly) → needinfo?(amarchesini)
Assignee | ||
Updated•9 years ago
|
Assignee: nobody → amarchesini
Flags: needinfo?(amarchesini)
Assignee | ||
Updated•9 years ago
|
Flags: needinfo?(nsm.nikhil)
Assignee | ||
Comment 3•9 years ago
|
||
Attachment #8623715 -
Flags: review?(nsm.nikhil)
Assignee | ||
Comment 4•9 years ago
|
||
Comment on attachment 8623715 [details] [diff] [review]
patch
Review of attachment 8623715 [details] [diff] [review]:
-----------------------------------------------------------------
::: dom/workers/ServiceWorkerManager.cpp
@@ +4425,5 @@
> }
>
> RemoveAllRegistrations(principal);
> } else if (strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) {
> + mShuttingdown = true;
This is mShuttingDown
Comment on attachment 8623715 [details] [diff] [review]
patch
Review of attachment 8623715 [details] [diff] [review]:
-----------------------------------------------------------------
::: dom/workers/ServiceWorkerManager.cpp
@@ +2352,5 @@
> registration->Clear();
> swm->RemoveRegistration(registration);
> }
>
> + // Could it be that we are shutting down.
"We could be shutting down."
Attachment #8623715 -
Flags: review?(nsm.nikhil) → review+
Assignee | ||
Comment 6•9 years ago
|
||
Comment 7•9 years ago
|
||
Backed out for widespread assertion failures.
https://treeherder.mozilla.org/logviewer.html#?job_id=11003275&repo=mozilla-inbound
https://hg.mozilla.org/integration/mozilla-inbound/rev/557cd9bb68b6
Assignee | ||
Comment 8•9 years ago
|
||
Comment 9•9 years ago
|
||
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla41
You need to log in
before you can comment on or make changes to this bug.
Description
•