Subprocess leaks the parent's pipe ends when launching the child process fails
Categories
(Toolkit :: Async Tooling, defect)
Tracking
()
People
(Reporter: spohl, Assigned: spohl)
References
Details
(Keywords: webext)
Attachments
(3 external files)
When IOUtils.launchProcess() throws inside subprocess_unix.worker.js, for example because the executable's interpreter is missing or posix_spawn refuses to start the program, spawn() disposes only the child's ends of the pipes it created. The parent's ends of stdin, stdout, stderr and the exit-sentinel pipe stay open until the worker happens to garbage-collect them. The Windows worker closes its pipes on failure; the Unix worker does not.
Measured with a script whose shebang points at a missing interpreter: 100 failed Subprocess.call() attempts grow the process from 11 to 413 open descriptors (four per attempt), while 100 successful launches grow it from 11 to 13.
An extension that keeps retrying a native messaging host whose launch fails leaks four descriptors per attempt. That appears to be the pipe leak behind the macOS 27 crashes in bug 2026491, where the parent process accumulates about one pipe pair per second.
The fix is to close the parent's pipe ends when the launch fails, with a regression test.
| Assignee | ||
Comment 1•2 months ago
|
||
When IOUtils.launchProcess() throws, spawn() disposed only the child's ends of the pipes it had just created. The parent's ends of stdin, stdout, stderr and the exit sentinel stayed open until the worker garbage-collected them, four descriptors per failed launch. An extension that keeps retrying a native messaging host whose launch fails can exhaust the process's descriptors this way. The Windows worker already closes its pipes on failure.
Updated•2 months ago
|
Comment 2•2 months ago
|
||
Could you request an uplift to ESR 153? As noted at https://bugzilla.mozilla.org/show_bug.cgi?id=2026491#c38 macOS 27 Golden Gate is much more prone to trigger this bug due to native messaging binaries that are suddenly incompatible due to the default ommission of Rosetta.
Comment 4•2 months ago
|
||
firefox-esr153 Uplift Approval Request
- User impact if declined/Reason for urgency: Users who have extensions that rely on Intel-based binaries and upgrade to macOS 27 may crash in less than an hour of uptime due to the fact that macOS 27 has removed Rosetta by default. While it can be manually installed, this failure is not visible to the user and it isn't obvious that installing Rosetta would address it.
- Code covered by automated testing?: yes
- Fix verified in Nightly?: no
- Needs manual QE testing?: no
- Steps to reproduce for manual QE testing:
- Risk associated with taking this patch: low
- Explanation of risk level: This simply closes pipes when a child failed to launch. There is no behavior change in the successful case and the patch adds a test.
- String changes made/needed?: none
- Is Android affected?: no
| Assignee | ||
Comment 5•2 months ago
|
||
When IOUtils.launchProcess() throws, spawn() disposed only the child's ends of the pipes it had just created. The parent's ends of stdin, stdout, stderr and the exit sentinel stayed open until the worker garbage-collected them, four descriptors per failed launch. An extension that keeps retrying a native messaging host whose launch fails can exhaust the process's descriptors this way. The Windows worker already closes its pipes on failure.
Original Revision: https://phabricator.services.mozilla.com/D327609
Comment 6•2 months ago
|
||
| bugherder | ||
Updated•2 months ago
|
Updated•2 months ago
|
Comment 8•2 months ago
|
||
firefox-beta Uplift Approval Request
- User impact if declined/Reason for urgency: Users who have extensions that rely on Intel-based binaries and upgrade to macOS 27 may crash in less than an hour of uptime due to the fact that macOS 27 has removed Rosetta by default. While it can be manually installed, this failure is not visible to the user and it isn't obvious that installing Rosetta would address it. This was found following a user report and debugging at https://bugzilla.mozilla.org/show_bug.cgi?id=2026491#c38
- Code covered by automated testing?: yes
- Fix verified in Nightly?: no
- Needs manual QE testing?: no
- Steps to reproduce for manual QE testing:
- Risk associated with taking this patch: low
- Explanation of risk level: This simply closes pipes when a child failed to launch. There is no behavior change in the successful case and the patch adds a test.
- String changes made/needed?: None
- Is Android affected?: no
Comment 9•2 months ago
|
||
When IOUtils.launchProcess() throws, spawn() disposed only the child's ends of the pipes it had just created. The parent's ends of stdin, stdout, stderr and the exit sentinel stayed open until the worker garbage-collected them, four descriptors per failed launch. An extension that keeps retrying a native messaging host whose launch fails can exhaust the process's descriptors this way. The Windows worker already closes its pipes on failure.
Original Revision: https://phabricator.services.mozilla.com/D327609
Updated•2 months ago
|
Updated•2 months ago
|
Comment 10•2 months ago
|
||
| uplift | ||
Description
•