Skip to content

馃悰 fix(subprocess): stop hanging on undecodable backend output - #311

Merged
gaborbernat merged 3 commits into
tox-dev:mainfrom
xiehuanyi:fix/replace-invalid-backend-output
Oct 7, 2026
Merged

gaborbernat merged 3 commits into
tox-dev:mainfrom
xiehuanyi:fix/replace-invalid-backend-output

Conversation

@xiehuanyi

@xiehuanyi xiehuanyi commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

A build backend, or a compiler it runs, can write bytes that the frontend's locale encoding cannot decode. Popen.communicate() decodes the captured output after the child exits, so it raises UnicodeDecodeError inside the output collection thread. Since #282 the frontend waits for that thread to store the output before it reads the backend result, so one bad byte leaves the frontend polling forever. 馃悰 Before that change the same input crashed with a TypeError.

The frontend now decodes the backend's stdout and stderr with errors="backslashreplace". Those streams carry diagnostics; the backend result travels through a separate JSON file, so the lossy decode cannot touch it. Backslash escapes keep the original byte visible as before\xffafter, where replace would show a U+FFFD placeholder and hide which byte broke the log. 馃攳

The request sent over stdin is ASCII JSON, so the error handler changes nothing on the encode side. An exception other than a decode error inside the output collection thread still hangs the frontend; this PR fixes the decode case.

Copilot AI balanced review requested due to automatic review settings October 6, 2026 19:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@gaborbernat
gaborbernat requested a balanced review from Copilot October 7, 2026 19:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃煝 Approval recommended

The focused fix correctly prevents decoding failures, with regression coverage for both diagnostic streams.

0 open findings

馃 Review effort: Balanced

@gaborbernat gaborbernat added the bug Something isn't working label Oct 7, 2026
@gaborbernat gaborbernat changed the title Avoid hanging on undecodable backend diagnostic output 馃悰 fix(subprocess): stop hanging on undecodable backend output Oct 7, 2026

@gaborbernat gaborbernat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gaborbernat
gaborbernat enabled auto-merge (squash) October 7, 2026 20:17
@gaborbernat
gaborbernat merged commit 346cb66 into tox-dev:main Oct 7, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants