Utility process launch never settles if the child doesn't finish starting up
Categories
(Core :: IPC, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox162 | --- | fixed |
People
(Reporter: az, Assigned: az, NeedInfo)
References
(Blocks 1 open bug)
Details
Attachments
(3 external files, 2 obsolete files)
UtilityProcessHost::LaunchPromise() resolves when the child sends InitCompleted, and rejects only if creating the process fails, on shutdown, or if the channel closes after connecting. If the child never connects, or connects but never finishes init, nothing seems to settle the promise. There's no startup timeout, and channel errors before connecting never reach the host so callers wait forever.
It looks like the launch promise should be resolved "once the channel has connected (or failed to)", but the InitAfterConnect comment state it is never called with false.
https://searchfox.org/firefox-main/rev/751f5671de2d327ff436154dfca6ed1733809163/ipc/glue/UtilityProcessHost.cpp#147-149
https://searchfox.org/firefox-main/rev/751f5671de2d327ff436154dfca6ed1733809163/ipc/glue/UtilityProcessHost.cpp#177-179
Seen in bug 2082265 with the MF media engine CDM utility process on a Windows 10 machine. The launch there never resolved or rejected, and every video decodingInfo() call waiting on it hung. Why that child fails to start there is not known yet.
Comment 1•1 month ago
|
||
I asked an LLM to investigate based on the profiles in bug 2082265 and reasoning about code, why the Media Engine CDM UtilityProcess' launch promise is left hanging when the process fails to start. Suggestion 2 seems like wallpapering to me but the others seem worth a look:
Description
If a utility process child fails before connecting to its IPC channel, the parent never notices. UtilityProcessHost's launch promise stays pending, its consumers hang, and UtilityProcessManager hands the same pending promise to every later launch of that sandbox kind until the browser restarts.
This turned the MF Media Engine CDM process failing under LPAC (bug 2083650) into the endless decodingInfo() hang in bug 2082265. MFMediaEngineChild::Init() still waits on that same launch.
Evidence
In the 158, LPAC on and Nightly, LPAC on profiles from bug 2082265 comment 21, the last line logged for sandboxingKind=2 is UtilityProcessHost::Launch launching async. The following never appear for the rest of the recordings (45 s and 67 s):
InitAfterConnectconnected - resolving launch promiseconnection failed - rejecting launch promise
Analysis
- An error before connect never reaches the host.
ChannelWin::Connect()reads the pipe right away.PerformAsyncLaunch()drops the parent's copy of the client handle.- So a child that exits early causes
NodeChannel::OnChannelError()→NodeController::DropPeer(). NodeChannelonly notifies itsGeckoChildProcessHoston connect, never on error.- Bug 1838906 (D181282) removed the hosts'
OnChannelError()handlers. That diff suggests errors weren't being forwarded even before it. A stale comment inAsyncLaunch()is left over from that.
UtilityProcessHosthas no failure path or timeout after the process handle is ready.LaunchPromise()waits only forOnChannelConnected().InitAfterConnect()is never called withfalse.UtilityProcessManager::LaunchProcess()keeps returning the pending promise.RDDProcessHost's startup timeout is defused once the process handle is ready, before connect.
- A child that's alive but stuck is never caught.
SandboxBroker::LaunchApp()ignores the result ofResumeThread(). Only a timeout catches this, or any other stall before connect.
Suggested fixes
- Forward channel errors that happen before connect from
NodeChannelto itsGeckoChildProcessHost. The process hosts then reject their launch promise, and the manager drops its keep-alive so a later launch can retry. - Add a connect timeout to
UtilityProcessHost, and keepRDDProcessHost's timeout armed until connect. - Check
ResumeThread()inSandboxBroker::LaunchApp()
Comment 2•29 days ago
|
||
The severity field is not set for this bug.
:jld, could you have a look please?
For more information, please visit BugBot documentation.
UtilityProcessHost's launch promise only settled once the child reported
that its init completed, or once the channel closed. A launch that stalled
in between was never detected, and everything waiting on that process
waited until shutdown. Abandon the launch after
dom.ipc.utilityProcess.startup_timeout_ms by reporting it to the listener as
an unexpected shutdown, which rejects the launch and shuts the host down. A
child that has not connected yet has no channel to be asked to shut down
over, so it is terminated once its host goes away.
The 10 s default leaves room for slow machines: process launches reach about
5 s at the 99.9th percentile (bug 1994984), and this timeout also covers the
child's init.
Launch failures are now an expected outcome, so the asserts claiming they
can't happen in StartPKCS11Module and CreateWinFileDialogActor are removed.
Based on padenot's D323643.
The 1 ms timeout normally abandons the launch before the child connects. Add
a testing pref that makes the child skip SendInitCompleted(), so the launch
stays connected but never completes, and cover that case too. The 1 ms test
sets it as well, so its launch cannot complete however the timeout is
scheduled.
A launch that completes must outlive its own timeout. A launch that is shut
down before its timeout fires must also leave the next launch's process alone
when that timeout expires.
A launch failure was only reported to whoever held the StartUtility()
promise, so an actor waiting to be bound had no way to know it never would
be. UtilityProcessManager now calls BindToUtilityProcess(nullptr) on an
actor that is still unbound when the launch fails, so every primary utility
actor learns about it the same way.
No actor acts on the notification yet. HWInferenceParent starts to in
bug 2069379, whose test covers this path.
Updated•21 days ago
|
Updated•21 days ago
|
Updated•21 days ago
|
Updated•21 days ago
|
https://hg.mozilla.org/mozilla-central/rev/350e1ba2894d
https://hg.mozilla.org/mozilla-central/rev/39c841bc2af0
https://hg.mozilla.org/mozilla-central/rev/f29e7bd9f2e4
Description
•