Closed Bug 2082990 Opened 1 month ago Closed 6 days ago

Utility process launch never settles if the child doesn't finish starting up

Categories

(Core :: IPC, defect)

defect

Tracking

()

RESOLVED FIXED
162 Branch
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.

See Also: → 2082265

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):

  • InitAfterConnect
  • connected - resolving launch promise
  • connection failed - rejecting launch promise

Analysis

  1. An error before connect never reaches the host.
  2. UtilityProcessHost has no failure path or timeout after the process handle is ready.
  3. A child that's alive but stuck is never caught. SandboxBroker::LaunchApp() ignores the result of ResumeThread(). Only a timeout catches this, or any other stall before connect.

Suggested fixes

  1. Forward channel errors that happen before connect from NodeChannel to its GeckoChildProcessHost. The process hosts then reject their launch promise, and the manager drops its keep-alive so a later launch can retry.
  2. Add a connect timeout to UtilityProcessHost, and keep RDDProcessHost's timeout armed until connect.
  3. Check ResumeThread() in SandboxBroker::LaunchApp()
Blocks: 2082265, 2082946
See Also: 2082265 → 1838906, 2083650
See Also: → 2069379
Assignee: nobody → azebrowski

The severity field is not set for this bug.
:jld, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(jld)

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.

Attachment #9669159 - Attachment description: Bug 2082990 - Part 2: Test that an abandoned utility process launch rejects, then recovers. r=padenot → Bug 2082990 - Part 2: Test abandoned utility process launches and launch timeouts. r=padenot
Attachment #9669162 - Attachment description: Bug 2082990 - Part 5: Tell unbound utility actors when their launch fails. r=padenot → Bug 2082990 - Part 3: Tell unbound utility actors when their launch fails. r=padenot
Attachment #9669160 - Attachment is obsolete: true
Attachment #9669161 - Attachment is obsolete: true
Pushed by azebrowski@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/f058fdc2abaf https://hg.mozilla.org/integration/autoland/rev/350e1ba2894d Part 1: Abandon a utility process launch that does not complete in time. r=ipc-reviewers,nika https://github.com/mozilla-firefox/firefox/commit/118a6e050fd7 https://hg.mozilla.org/integration/autoland/rev/39c841bc2af0 Part 2: Test abandoned utility process launches and launch timeouts. r=ipc-reviewers,nika https://github.com/mozilla-firefox/firefox/commit/955a88d7c96d https://hg.mozilla.org/integration/autoland/rev/f29e7bd9f2e4 Part 3: Tell unbound utility actors when their launch fails. r=ipc-reviewers,win-reviewers,ai-platform-reviewers,gstoll,valentinp,nika
Status: NEW → RESOLVED
Closed: 6 days ago
Resolution: --- → FIXED
Target Milestone: --- → 162 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: