"MessageChannel destroyed without being closed" / Intermittent PROCESS-CRASH | Main app process exited normally | application crashed [@ mozilla::BlockingResourceBase::CheckAcquire()]
Categories
(Core :: IPC, defect, P2)
Tracking
()
People
(Reporter: intermittent-bug-filer, Unassigned)
References
Details
(Keywords: crash, intermittent-failure, sec-moderate)
Crash Data
Comment 1•8 years ago
|
||
Comment 3•8 years ago
|
||
Comment 4•8 years ago
|
||
Comment 5•8 years ago
|
||
Updated•8 years ago
|
Updated•8 years ago
|
Comment 6•8 years ago
|
||
Comment 7•7 years ago
|
||
Updated•7 years ago
|
Comment 8•7 years ago
|
||
Comment 9•7 years ago
|
||
Comment 14•7 years ago
|
||
The signature in Bug 1547654 which is a dupe of this bug is now the top crash on 68 nightly, even though it appears there are only 64 installs/3954 crashes.
Updated•7 years ago
|
Comment 16•7 years ago
|
||
The signature in Bug 1547654 which is a dupe of this bug is now the top crash on 68 nightly, even though it appears there are only 64 installs/3954 crashes.
It looks like there's only 3 machines involved, and 97% of the crashes are from an iMac in Finland, which I presume is running some script or has a really persistent owner. Might be Flash related.
Comment 17•7 years ago
|
||
Adding a signature seen during nightly triage, all on Mac 10.15. This machine appears to be a MBP, and there are 2 unique users crashing with the same Moz Crash reason as seen in Comment 4.
Comment 18•7 years ago
|
||
We talked about this at the IPC meeting a few weeks ago. The current idea is to make the Unsound_IsClosed sound, using locking, and move the check up into the IToplevelProtocol destructor to crash before the object is torn down enough to cause undefined behavior if there's a race. We'd still crash, but it won't be security sensitive anymore, and the patch should be less invasive (more upliftable) than trying to fix this fully.
Longer-term I guess we should move away from things caring about destruction order like this, especially in ways that cause memory unsafety (or require deliberate crashing to avoid the unsafety): clearly we don't have enough testing to even understand why those invariants are being violated, let alone catch it before release.
Updated•7 years ago
|
Updated•7 years ago
|
Comment 21•6 years ago
|
||
I don't understand why bug 1498648 was considered to be related to this.
Comment 24•6 years ago
|
||
I've been looking at this again, and I'm wondering if we could just (in addition to making the IsClosed flag atomic) call MessageChannel::Clear in the IToplevelProtocol destructor, before dispatching the runnable to delete the channel… or, to similar effect, dispatch the deletion to the current event loop and then re-dispatch to the I/O thread, to ensure it happens-after the rest of the IToplevelProtocol/MessageChannel destructor (which, in the bad case, will crash).
Comment 27•6 years ago
|
||
I've figured out a reliable "STR": comment out the Clear() call in MessageChannel::NotifyMaybeChannelError, then kill a content process (e.g. with the shell command kill). I combined this with a sleep in ~IToplevelProtocol to ensure the use would happen after the free.
With this, I've discovered that the second idea from comment #24 doesn't work, because VRManagerParent seems to be destroyed while the actor thread is shutting down and it's not possible to self-dispatch when the nsThread::mEventTarget has already been cleared.
Comment 28•6 years ago
|
||
…and calling MessageChannel::Clear directly from ~IToplevelProtocol has the slight problem that HangMonitorParent is deleted on the main thread and not its own actor thread. This is a problem if it means that MessageChannel::Clear does the mWorkerLoop->RemoveDestructionObserver call on the wrong thread.
That seems to not happen normally because it would already have been cleared by the error handling that I commented out to reproduce the bug, but I wonder whether that's strictly necessary or if it happens rarely in actual use; the thread check in RemoveDestructionObserver is debug-only so we wouldn't notice.
Comment 29•6 years ago
|
||
(In reply to Jed Davis [:jld] ⟨⏰|UTC-7⟩ ⟦he/him⟧ from comment #28)
HangMonitorParentis deleted on the main thread and not its own actor thread.
Also the PBackground parent actor.
I tried commenting out the debug assertion in RemoveDestructionObserver to see what would happen, and now I have a new crash that doesn't make much sense: a ContentParent where mTrans is never set to non-null, and the channel pointed to by the ProcessLink is freed by the GeckoChildProcessHost destructor and then used by MessageChannel::Clear when the ContentParent is destroyed.
Comment 30•6 years ago
|
||
From looking into bug 1608466, I think there is a fundamental race with this method on the shutdown of many toplevel actors.
When an actor is destroyed, it dispatches a message to the IO thread to destroy the IPC::Channel transport object in it's destructor (either directly within ~IToplevelProtocol, or through the GeckoChildProcessHost::Destroy method). This destructor is called before the destructors of base classes & members, so the message is dispatched before the ~MessageChannel destructor is run. The ~MessageChannel destructor will then try to call Unsound_IsClosed here, but that method calls through a raw pointer to access a property of IPC::Channel, which may have already been freed on the IO thread.
So, in effect, we have two tightly connected objects, the MessageChannel and IPC::Channel, which have completely unrelated lifecycles and don't keep track of one another, so it's somewhat unsurprising that we frequently crash here.
We probably want to make the lifecycle relationship between the ProcessLink object and the IPC::Channel more explicit, perhaps by transferring ownership of the IPC::Channel object into the MessageChannel when we create it, and away from the ProcessHost (or IPDL actor via ManagedEndpoint) which initially opened it.
Updated•6 years ago
|
Comment 33•4 years ago
|
||
This is a few years old, and we've had lots of improvements by Nika to channel lifetimes in the meanwhile.
Updated•3 years ago
|
Description
•