Skip to content

Text-mode child processes decode with errors="replace", plus a guard test (BUILD-1265) - #4426

Open
mrp1no wants to merge 3 commits into
ItsNotRexed:mainfrom
mrp1no:build-1265-subprocess-errors
Open

mrp1no wants to merge 3 commits into
ItsNotRexed:mainfrom
mrp1no:build-1265-subprocess-errors

Conversation

@mrp1no

@mrp1no mrp1no commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

BUILD-1265 (@AirKyzzZ's finding). Claim: #4257 (comment)

A text-mode subprocess call (text=True, universal_newlines=True or encoding=) decodes with errors="strict". When a child prints bytes the code page can't decode, the output is lost. The bytes can be a localized Windows console message in the OEM code page (cmd.exe's "non \x8a riconosciuto" in Italian), wsl.exe's UTF-16LE errors, or a path in another encoding. The failure looks different per platform, and on Windows it's quiet:

  • POSIX: run() raises UnicodeDecodeError, so the tool dies with a traceback instead of its own error.
  • Windows: capture_output reads through threads. The decode error kills the reader thread, which prints a traceback to stderr, and r.stdout comes back as None with no exception in the caller. The tool then treats it as "no output". Checked here with Python 3.15.2 on Windows 11.

Commits

  1. make_game.py, scripts/run_gpu_tests.py, scripts/bench_wave64.py, runtime/test/shaders/ (build.py, check.py, w64_graphics.py): 16 calls get errors="replace".
    • Contrary to the finding, make_game.py's own five did not have it: dotnet --list-sdks, the two vk_subgroup_info probes, the rpf9-explorer pin and the runtime probe.
  2. tools/: the other 46 calls get the same.
    • The files: the fuzzers, ps_oracle, hw_oracle, ab_control_flow, cf_diff, spirv_gs_to_compute, bary_fallback_gs, fma_mix_probe, isa_coverage, mesh_compute_vs, probe_gfx1036_vcmp16, turing_atlas, bink_index and two in rdna2spirv.
    • mc_command.run forwards **kwargs to subprocess.run, so its 7 calls take the keyword as-is.
    • tools/shader_disasm.py is left to shader_disasm: decode llvm-mc's output with errors="replace" (BUILD-1245) #4395 (BUILD-1245), which fixes it with its own test.
    • The stand-in subprocess.run in tests/test_bary_fallback_gs.py takes the new keyword.
  3. tests/test_subprocess_text_errors.py, a stdlib guard. It parses the tracked Python under tools/, scripts/, make_game.py and runtime/test/shaders/ with ast, and fails on a run/check_output/Popen/call/check_call call that decodes text without errors=.

All 62 edits are the same insertion, made with ast right after the existing text-mode keyword, so nothing else changes. compileall is clean.

The guard is scoped to code that runs on the user's machine. tests/ has about 450 more such calls, but they decode our own Python children's output; changing them would touch dozens of open PRs.

Tested (Windows 11, Python 3.15.2)

No game files. AI-assisted (Claude Code).

🤖 Generated with Claude Code

mrp1no and others added 3 commits November 23, 2026 02:22
…="replace" (BUILD-1265)

A text-mode subprocess call decodes with errors="strict". When a child
prints bytes the code page can't decode (a localized Windows console
message in the OEM code page, wsl.exe's UTF-16LE errors, a path in
another encoding), the output is lost: on POSIX run() raises
UnicodeDecodeError; on Windows capture_output reads through threads, the
reader thread dies with a traceback and stdout comes back as None with no
exception in the caller.

make_game.py (dotnet --list-sdks, the two vk_subgroup_info probes, the
rpf9-explorer pin, the runtime probe), scripts/run_gpu_tests.py,
scripts/bench_wave64.py and runtime/test/shaders/ (build.py, check.py,
w64_graphics.py) now pass errors="replace", as make_game's other calls
already did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The same change for the tools that run llvm-mc, spirv-as/spirv-val,
vk_compute_test and other children in text mode: the fuzzers
(crosslane, lds, valu, image, valu_int_diff), ps_oracle, the hw_oracle
runner and DRM probe, ab_control_flow, cf_diff, spirv_gs_to_compute,
bary_fallback_gs, fma_mix_probe, isa_coverage, mesh_compute_vs,
probe_gfx1036_vcmp16, turing_atlas, bink_index and rdna2spirv's two
tool calls; mc_command.run forwards the keyword to subprocess.run.
tools/shader_disasm.py is left to ItsNotRexed#4395 (BUILD-1245), which fixes it
with its own test.

tests/test_bary_fallback_gs.py's stand-in subprocess.run functions take
the new keyword.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…D-1265)

test_subprocess_text_errors.py parses the tracked Python under tools/,
scripts/, make_game.py and runtime/test/shaders/ with ast and fails on a
run/check_output/Popen/call/check_call call that decodes text (text= or
universal_newlines= not False, or encoding=) without errors=. A negative
control checks that the checker flags exactly the calls missing it, and a
third test shows what is at stake: a child printing 0x8a (an OEM
code-page letter) comes back replaced with errors="replace", and is lost
without it (UnicodeDecodeError on POSIX, stdout None on Windows).
tools/shader_disasm.py is skipped until ItsNotRexed#4395 lands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ran this at 0d062f28 on Windows 11: tests/test_subprocess_text_errors.py -> 3 tests, OK; tests/test_bary_fallback_gs.py -> 27 tests, OK; git diff --check clean.

Every text-mode child process now names errors= explicitly (the guard test scans for it), so a child's non-UTF-8 output cannot crash a tool with a decode traceback. No blocking issue.

@molodayamama

Copy link
Copy Markdown

Independent Windows check of 0d062f28ef8da41abb29f9d80dc2884c371b7f15 (Windows 10 22H2, CPython 3.12.12, default CP1251). test_subprocess_text_errors.py: 3/3 passed.

I exercised the actual changed isa_coverage.probe_llvm_mc with a native helper that emits byte 0x98 (undefined in CP1251), followed by an ordinary error: instruction not supported on this GPU line on stderr. On 03b09a08, the stderr-reader thread raises UnicodeDecodeError and the caller then raises TypeError because stderr was lost. On this PR the same process is correctly classified LLVM: other GPU only (not gfx1013). The useful compiler diagnostic survives without changing the system locale. Synthetic helper only. AI-assisted (Codex).

@CaravelaLabs

Copy link
Copy Markdown
Contributor

Automated test: 0d062f28 merged onto main 03b09a08 on AMD Radeon 8060S (RADV GFX1151, RDNA 3.5), Mesa 25.2.8, Ubuntu 24.04, runtime rebuilt from this branch in a clean sandbox. Result: pass.

Same machine and setup as my earlier manual reports. AI-assisted (Claude Code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants