Subprocess: Pending read of stdout/stderr is discarded on Windows when process exits
Categories
(Toolkit :: Async Tooling, defect)
Tracking
()
| 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:
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).
Updated•1 year ago
|
| Assignee | ||
Updated•1 year ago
|
| Assignee | ||
Comment 1•1 year ago
|
||
Comment 3•1 year ago
|
||
| bugherder | ||
Updated•1 year ago
|
Description
•