Closed Bug 1993128 Opened 1 year ago Closed 1 year ago

Subprocess: Pending read of stdout/stderr is discarded on Windows when process exits

Categories

(Toolkit :: Async Tooling, defect)

defect

Tracking

()

RESOLVED FIXED
146 Branch
Tracking Status
firefox146 --- fixed

People

(Reporter: robwu, Assigned: robwu)

References

Details

(Whiteboard: [addons-jira])

Attachments

(1 external file)

When I added test coverage for various scenarios involving subprocess child and stdio pipe communication, I found that stdout is unreadable after process termination, on Windows:

https://searchfox.org/firefox-main/rev/1c6a8b56e6f5f5393ea5ea745ab63ecb67613c93/toolkit/modules/subprocess/test/xpcshell/test_subprocess_child.js#157-163

While reading code, I noticed that there is an implementation flaw in maybeClose: https://searchfox.org/firefox-main/rev/1c6a8b56e6f5f5393ea5ea745ab63ecb67613c93/toolkit/modules/subprocess/subprocess_win.worker.js#177-192

The method is documented as "Closes the pipe if there is a pending read operation with no more buffered data to be read.".
The implementation calls GetOverlappedResult and closes the pipe if it returns FALSE.
But GetOverlappedResult (MSDN) states:

If this parameter is FALSE and the operation is still pending, the function returns FALSE and the GetLastError function returns ERROR_IO_INCOMPLETE.

Since we use async IO, we should expect ERROR_IO_INCOMPLETE and not close the pipe prematurely. When I added the check, the test now behaves like other platforms (macOS/Linux).

See Also: → CVE-2025-11719
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 146 Branch
QA Whiteboard: [qa-triage-done-c147/b146]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: