Closed
Bug 1509362
Opened 6 years ago
Closed 6 years ago
Don't crash when attempting to construct actor in dying process
Categories
(Core :: IPC, enhancement)
Core
IPC
Tracking
()
RESOLVED
FIXED
mozilla65
Tracking | Status | |
---|---|---|
firefox65 | --- | fixed |
People
(Reporter: nika, Assigned: nika)
References
Details
Attachments
(1 file)
(deleted),
text/x-phabricator-request
|
Details |
When shutting down a content process, we call `Close` on the `IToplevelProtocol`. This causes the MessageChannel to be `Close`-ed, which in turn sends a `GOODBYE_MESSAGE`: https://searchfox.org/mozilla-central/rev/876022232b15425bb9efde189caf747823b39567/ipc/glue/MessageChannel.cpp#2852
This message is intercepted on the I/O thread in the content process, before any code is informed in content, and used to set the `mChannelState` property to `ChannelClosing`: https://searchfox.org/mozilla-central/rev/876022232b15425bb9efde189caf747823b39567/ipc/glue/MessageChannel.cpp#1176
Once this state has been set, which is performed as soon as the message is received, whether or not other messages have been processed yet, no messages can be sent back to the parent process. This is usually what causes the 'Too late to send/recv' message spam in the console, as we're still trying to send messages at this time.
Usually this is fine - the message send fails, but we gracefully recover, and the process begins shutting down like normal. Unfortunately, child actor constructors currently have code automatically generated in them which causes a process crash if the send fails. As it's impossible for the main thread to know that the channel has been closed ahead of time (due to this happening out-of-band), we can then cause random content process crashes during shutdown due to actor construction.
The obvious fix which I'm taking in this patch is to relax this assertion to instead gracefully fail & destroy the actor if the message send failed on both sides, rather than just content.
This caused the crashes in bug 1487249.
Assignee | ||
Comment 1•6 years ago
|
||
When shutting down a content process, we call `Close` on the
`IToplevelProtocol`. This causes the MessageChannel to be `Close`-ed,
which in turn sends a `GOODBYE_MESSAGE`:
https://searchfox.org/mozilla-central/rev/876022232b15425bb9efde189caf747823b39567/ipc/glue/MessageChannel.cpp#2852
This message is intercepted on the I/O thread in the content process,
before any code is informed in content, and used to set the
`mChannelState` property to `ChannelClosing`:
https://searchfox.org/mozilla-central/rev/876022232b15425bb9efde189caf747823b39567/ipc/glue/MessageChannel.cpp#1176
Once this state has been set, which is performed as soon as the
message is received, whether or not other messages have been processed
yet, no messages can be sent back to the parent process. This is
usually what causes the 'Too late to send/recv' message spam in the
console, as we're still trying to send messages at this time.
Usually this is fine - the message send fails, but we gracefully
recover, and the process begins shutting down like normal.
Unfortunately, child actor constructors currently have code
automatically generated in them which causes a process crash if the
send fails. As it's impossible for the main thread to know that the
channel has been closed ahead of time (due to this happening
out-of-band), we can then cause random content process crashes
during shutdown due to actor construction.
The obvious fix which I'm taking in this patch is to relax this
assertion to instead gracefully fail & destroy the actor if the
message send failed on both sides, rather than just content.
Updated•6 years ago
|
Attachment #9027034 -
Attachment description: Bug 1509362 - Don't crash when constructing actor during content shutdown → Bug 1509362 - Don't crash when constructing actor during content shutdown,
Pushed by nika@thelayzells.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/c3fe435e473a
Don't crash when constructing actor during content shutdown, r=jld
Comment 3•6 years ago
|
||
Backed out 13 changesets (bug 1500948, bug 1509362, bug 1509591, bug 1448426, bug 1500949, bug 1487249, bug 1509930, bug 1500950, bug 1500944) for causing crashes and assertion failures on PBackgroundParent.cpp:696 CLOSED TREE
Backout revision https://hg.mozilla.org/integration/mozilla-inbound/rev/9bfe29337ffe3d93cd060077e2e999e72bb9b7cf
Failed push https://treeherder.mozilla.org/#/jobs?repo=mozilla-inbound&resultStatus=testfailed%2Cbusted%2Cexception&classifiedState=unclassified&selectedJob=214255312&revision=c3fe435e473a463fbc22d4afa531bdedb757079c
Failure logs: https://treeherder.mozilla.org/logviewer.html#?job_id=214255312&repo=mozilla-inbound
https://treeherder.mozilla.org/logviewer.html#?job_id=214255794&repo=mozilla-inbound
https://treeherder.mozilla.org/logviewer.html#?job_id=214249038&repo=mozilla-inbound
https://treeherder.mozilla.org/logviewer.html#?job_id=214249630&repo=mozilla-inbound
:Nika Layzell Could you please take a look?
Flags: needinfo?(nika)
Pushed by nika@thelayzells.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/7e23a1b90335
Don't crash when constructing actor during content shutdown, r=jld
Assignee | ||
Updated•6 years ago
|
Flags: needinfo?(nika)
Pushed by nika@thelayzells.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/1c1f445a9b6a
Don't crash when constructing actor during content shutdown, r=jld
Comment 6•6 years ago
|
||
bugherder |
Status: NEW → RESOLVED
Closed: 6 years ago
status-firefox65:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla65
You need to log in
before you can comment on or make changes to this bug.
Description
•