Skip to content

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

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

mrp1no wants to merge 9 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

@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).

@mrp1no

mrp1no commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main 0db7fed5 to clear conflicts in tools/crosslane_fuzz.py, tools/rdna2spirv.py and tools/spirv_gs_to_compute.py. Rather than merging the conflict hunks by hand, I regenerated the first two commits on the new main with the same ast insertion, then re-applied the guard commit unchanged.

  • Now 65 calls (was 62): 16 in make_game/scripts/GPU test shaders and 49 in tools/.
  • New on main since the first push: tools/bvh_gpu_smoke.py (2), tools/gen_gdk_runtime_classes.py (1) and tools/sandbox.py (1).
  • rdna2spirv: now 1 call, down from 2, because main changed its other one.
  • Checks: tests/test_subprocess_text_errors.py 3/3 OK and test_bary_fallback_gs 27 passed. The tests of every edited tool also pass (bvh_gpu_smoke, sandbox_*, gdk_runtime_calls, the fuzzers, the oracles, cf_diff, ab_control_flow, spirv_gs_to_compute: 520 passed). compileall is clean.

AI-assisted (Claude Code).

@JRamos1993

Copy link
Copy Markdown
Contributor

Tested 9e865f9 merged onto main 98fa503 on an RTX 5090 (driver 616.92), Windows 11, Vulkan SDK 1.4.363. The GPU test programs were built from the same tree:

  • scripts/run_gpu_tests.py: 170/217 passed, 47 skipped, 0 failed. main 98fa503 gives 170/217, 47 skipped, 0 failed. All 221 test shaders translate and pass spirv-val.
  • tests/test_bary_fallback_gs.py: ran 28 tests in 1.195s; OK.
  • tests/test_subprocess_text_errors.py: ran 3 tests in 0.082s; OK (skipped=1).

AI-assisted (Claude Code).

@kapitche

kapitche commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Tested 9e865f9 merged with main 594f348 on Linux (WSL Ubuntu, Python 3.12.16) and native Windows (Python 3.13.1): pass

  • python -I tests/test_subprocess_text_errors.py: Linux 3 OK; Windows 3 OK. tests/test_bary_fallback_gs.py: Linux 28 OK (1 skipped); Windows 28 OK (1 skipped).
  • Ran every tests/test_*.py on Linux with the PR merged: 20 files fail, and the same 20 fail on plain main (missing spirv-as/tools, no network in WSL), so no regressions from the mock signature changes.
  • Negative control: with main's versions of the 28 non-test files, `test_text_mode_child_output_names_errors` fails listing 67 text-mode calls without errors= (the other tests still pass), so the check does demonstrate the fix. In-test control `test_the_check_sees_a_missing_errors` flags exactly lines 2 and 5.
  • Read the full diff, no issues found.

@cxchhh

cxchhh commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 9e865f96 on Tesla V100-SXM2-32GB (Volta, subgroup 32..32), NVIDIA 580.95.05, Ubuntu 24.04 (kernel 6.14.11), Python 3.12: pass.

Scope: the 32-wide half only (NVIDIA Volta). The AMD / 64-wide half still needs someone with an AMD GPU. (This PR has no GPU-specific code. I ran the GPU suite because it edits the runner and fixture build.)

Setup: the PR diff applied to main 98fa503f (applies cleanly), Linux Vulkan test programs built from that tree, compared against untouched main 98fa503f built the same way. llvm-mc 23.1.6, SPIRV-Tools 2026.4.

  • scripts/run_gpu_tests.py with this branch's runner, build.py and check.py: native 161/217 passed, 56 skipped; emulated + barycentric fallback 194/217 passed, 23 skipped; the same per-test result as main.
  • tests/test_subprocess_text_errors.py: the guard reads git ls-files, so in a plain tarball it skips. In a git snapshot of the tree it gives 3 OK. Against main 98fa503f the guard fails and lists 65 calls. That is more than the 62 in the description because main has moved, and this branch covers all 65.
  • pytest tests --ignore=tests/semantic -n 12: main 6760 passed, 8 failed, 1 error; this branch 6763 passed, with the same 8 failed and 1 error (environment-specific here; identical lists on both trees).
  • python -m unittest discover -s tests/semantic: 6245 tests; the only failures are the five test_loop_ballot_barrier cases that also fail on main here.

No game files. AI-assisted (Claude Code); I ran the commands above and checked the numbers against the logs.

@evilclanker9000

Copy link
Copy Markdown
Contributor

Tested 9e865f9 on Windows 11 (MSVC BuildTools 2022, Ninja, RelWithDebInfo, -j 4; no Vulkan validation layer installed), one GPU at a time, device line confirmed: AMD Radeon RDNA2 iGPU (driver 26.10.1) and NVIDIA RTX 5080 (driver 616.92). Ran the full run_gpu_tests.py (this PR changes the runner/test build; Radeon forced with VK_LOADER_DRIVERS_SELECT=*amd*): Radeon 201/217 passed, 16 skipped, 0 failed; RTX 5080 170/217 passed, 47 skipped, 0 failed (skips: "run by " and no 64-wide subgroup on the 5080). The CPU-side pytest files of this PR were not run. No game files.

AI-assisted.

@2309291758

Copy link
Copy Markdown

Verified #4426 on a different setup than the one in the description.

Environment: Windows 11 26200, Python 3.13.13 (not 3.15.2), AMD Radeon 860M
(RDNA 3.5, LLPC 25.20.32.06), LLVM_MC="wsl -d Ubuntu-24.04 -e /usr/lib/llvm-21/bin/llvm-mc".
On this machine wsl.exe writes its "localhost proxy not mirrored to WSL" warning to
stderr as UTF-16LE (77 00 73 00 6c 00 3a 00 ...), which is the trigger.

Before (main 3faac55): runtime/test/shaders/build.py on its own dies at line 143 with
TypeError: argument of type 'NoneType' is not iterable
exit 1, no shaders assembled. One UnicodeDecodeError traceback from the reader thread.

After (your branch, build-1265-subprocess-errors): build.py runs to completion,
242 shaders: 242 translated, 242 pass spirv-val
exit 0, zero UnicodeDecodeError tracebacks.

tests/test_subprocess_text_errors.py: 3 tests OK.
Negative control: with only the 4 runtime/test/shaders + run_gpu_tests.py files applied,
the guard still reports 62 calls (including all the tools/ ones), so it is really
checking rather than passing trivially. After applying all 30 files it is clean.

scripts/run_gpu_tests.py --build

with the patch, on the same 860M:
201/217 passed, 16 skipped, 0 failed, and no decode tracebacks in the run.
(16 skips: 15 are "SKIP (run by d3d12_*_test)", 1 is ps_w64x_readlane on a 32..64
subgroup device.)

One note: the guard test needs the tree to be a git checkout ("git ls-files"); in a
plain copied tree it skips rather than fails, so it can look green without checking
anything. Worth knowing for reviewers who test from an unzipped archive.

No game files. AI-assisted.

@bielfreedom

Copy link
Copy Markdown

Tested 9e865f96 (merge-base 0db7fed5) on AMD Radeon RX 9070 XT (RDNA4, subgroup 32..64), AMD Windows driver 32.0.32029.2010, Windows 11 Pro 26200, MSVC 14.51, Vulkan SDK 1.4.363, LEONIDA_VK_VALIDATION=1: pass for what this PR changes.

@nanyoudegege

Copy link
Copy Markdown

Non-blocking follow-up for 9e865f9: could tracked_python() read git ls-files -z as bytes and split on NUL? I reproduced the current parsing in a temporary Git checkout on Linux (Python 3.12.14, Git 2.56.1). With tools/plain.py, tools/with space.py, and tools/é.py tracked, the whitespace split yields tools/plain.py and the nonexistent tools/with; the quoted non-ASCII path is skipped by the prefix filter. NUL-delimited output returns all three paths intact. A small fixture covering both filename shapes would close that gap.

Separately, a synthetic-child comparison of the SDK probe’s subprocess options preserved valid output and exit status, and replaced invalid UTF-8 on both stdout and stderr instead of raising. This was a focused Linux check, not a Windows/GPU or full-suite run. No game files. AI-assisted.

@mrp1no

mrp1no commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

@nanyoudegege Good catch, thanks. Fixed in aba286a6: tracked_python() now reads git ls-files -z as bytes and splits on NUL. A new test tracks tools/plain.py, tools/with space.py and tools/é.py in a scratch repository and expects all three. With the old parsing it gets ['tools/plain.py', 'tools/with'], as you found. tests/test_subprocess_text_errors.py: 4/4 OK on Windows 11, Python 3.15.2. AI-assisted (Claude Code).

@nanyoudegege

Copy link
Copy Markdown

One more non-blocking question on aba286a: should the disassembly in spirv_gs_to_compute.py use explicit UTF-8 at both subprocess boundaries? The spirv-dis stdout is assembly source, not just a log: rewrite() preserves the quoted OpEntryPoint name, and the result goes back to spirv-as through stdin. Python applies errors="replace" to stdin as well as stdout/stderr.

In a focused Linux Python 3.12.14 test with synthetic child processes and an explicitly selected CP1252 codec, the UTF-8 bytes for the entry-point name 李 (e6 9d 8e) raised on strict CP1252 decoding, but with the PR’s replacement policy they reached the mock assembler as e6 3f 8e. Explicit UTF-8 on both legs preserved the name. Could we keep replacement for diagnostics while decoding and encoding the assembly itself as UTF-8, preferably without silently replacing source bytes? This was not a Windows or real SPIRV-Tools run. No game files. AI-assisted.

@mrp1no

mrp1no commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

@nanyoudegege Agreed, done in 0fa5dac7. In tools/spirv_gs_to_compute.py, both the spirv-dis read and the spirv-as write now pass encoding="utf-8", errors="strict". The assembly text, entry-point name included, goes through exactly, and a byte that doesn't decode is an error instead of a silent replacement. Diagnostics elsewhere keep errors="replace". tests/test_spirv_gs_to_compute.py (real spirv-dis/spirv-as), test_bary_fallback_gs.py and the guard: 54 passed. AI-assisted (Claude Code).

@ricardotanaka

Copy link
Copy Markdown

Re-tested the current head 0fa5dac7 (after the checks above, on 9e865f96) merged onto main 3faac557, on Windows 11 Pro 26200 pt-BR (console OEM code page 850, ANSI 1252), Python 3.12, with TEMP/TMP and the build.py output set to a folder whose name has a space and a ç; AMD Radeon RX 7600 (RDNA3, AMD driver 26.11.2): pass.

  • python -I tests/test_subprocess_text_errors.py: 4 tests OK. python -I tests/test_bary_fallback_gs.py: 28 tests OK.
  • runtime/test/shaders/build.py: 242 shaders, 242 translated, 242 pass spirv-val. check.py: 185 of 188 pass, 3 skipped. Same counts as main on this machine.
  • scripts/run_gpu_tests.py with LEONIDA_VK_VALIDATION=1: 202/217, 15 skipped (same as main here), no VUID lines.
  • No Traceback or UnicodeDecodeError in any of these logs.

AI-assisted (Claude Code).

@shdann

shdann commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Tested 0fa5dac7 on NVIDIA GeForce RTX 4090 (driver 621.01) and AMD Radeon(TM) Graphics (integrated, driver 32.0.21043.5001, subgroup 32..64), Windows 11, CPython 3.14.7: pass. An AI tool helped me to do these tests. No game files. The earlier reports are for 9e865f96; this is a check of the two newer commits.

I merged the head onto main (3faac557), without conflicts. The merge changes no C++ file, thus I built the test programs one time from main (MSVC 14.51, Ninja, RelWithDebInfo, Vulkan SDK 1.4.363.1, llvm-mc 21.1.8).

scripts/run_gpu_tests.py RTX 4090 AMD Radeon
main 170 of 217 passed, 47 skipped, 0 failed 195 of 217 passed, 22 skipped, 0 failed
This head on main 170 of 217 passed, 47 skipped, 0 failed 195 of 217 passed, 22 skipped, 0 failed

The status of each test (pass or skip) is the same as on main, on the two GPUs.

  • python -I tests/test_subprocess_text_errors.py: 4 tests OK.
  • python -I tests/test_bary_fallback_gs.py: 28 tests OK (the same as on main).

Correction (added later): in the AMD column of the run_gpu_tests.py table, the two tests ps_tex and ps_imgatomic ran on the RTX 4090, not on the AMD GPU. They use vk_bindless_test, which ignores LEONIDA_VK_DEVICE (finding: #5781 (comment)). All other tests in that column ran on the AMD GPU.

@gertify

gertify commented Nov 23, 2026

Copy link
Copy Markdown

Tested 0fa5dac on Intel UHD 630 (Coffee Lake GT2), Mesa 25.2.8 ANV, Ubuntu 24.04: the full build succeeds, and test_subprocess_text_errors (4 tests), test_run_gpu_tests (41) and test_bary_fallback_gs (28) pass. The full GPU suite with LEONIDA_VK_DEVICE=Intel gives 154/217 passed, 61 skipped, with only cs_fmt_int_narrow and cs_signed_zero_nan failing, the same counts and failures as the recorded main 3faac55 run on this GPU. cs_barrier_early_end passes 1/1 on Intel and fails with "no Vulkan physical device matches" under a nonexistent device name, so the filter applied.

AI-assisted.

@mrp1no

mrp1no commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto 561b65a8 (now c33d23f5), with two new commits.

Rebase. Main's newer code had changed the same subprocess.run lines in four files: the Defender check in hw_oracle/runner.py, the probe timeout in isa_coverage.py, --format in ps_oracle.py and the GPU timeout in valu_fuzz.py. Main's lines are kept, with errors="replace" added.

a9a6fa1b. The guard test found 8 text-mode calls that main added since. They are in f64_diff.py (3), hw_oracle/runner.py (clang --version), ps_sweep.py (2), xcl_compare.py and runtime/test/shaders/w64_graphics.py. Each reads its output only for messages, so each gets errors="replace".

c33d23f5, @nanyoudegege's follow-up on spirv-dis. spirv-dis now runs in binary mode. Its stdout is decoded as strict UTF-8 on the caller's thread, not on CPython's reader threads. A disassembly that isn't UTF-8 exits 2 with spirv-dis output is not UTF-8 (...), followed by spirv-dis's stderr decoded with errors="replace", instead of the TypeError from the version regex. spirv-as keeps its strict UTF-8 stdin. test_cli_reports_disassembly_that_is_not_utf8 runs a stand-in spirv-dis through SPIRV_DIS that writes non-UTF-8 stdout and a CP936 warning on stderr, and it fails with the traceback without this change.

Tests:

  • pytest tests --ignore=tests/semantic -n 10: the same 8 failures as main 561b65a8, none new.
  • The semantic suite at a9a6fa1b had no failures. The last commit touches only tools/spirv_gs_to_compute.py and its test.
  • test_spirv_gs_to_compute*.py and test_subprocess_text_errors.py: 38 passed with SPIRV-Tools on PATH.

AI-assisted (Claude Code).

mrp1no added a commit to mrp1no/Leonida that referenced this pull request Nov 23, 2026
…d here

In text mode CPython decodes captured output on the reader threads. A byte that
isn't UTF-8 there loses that stream: a console-code-page warning on stderr came
back as None, and a bad stdout left text None, so the version regex raised a
TypeError that hid the cause (@nanyoudegege on ItsNotRexed#4426, CP936). spirv-dis now runs
in binary mode. Its stdout is decoded as strict UTF-8 on the caller's thread, and
a failure exits 2 with "spirv-dis output is not UTF-8", plus spirv-dis's stderr
with errors="replace". spirv-as keeps its strict UTF-8 stdin.

test_cli_reports_disassembly_that_is_not_utf8 runs a stand-in spirv-dis through
SPIRV_DIS (non-UTF-8 stdout, a CP936 warning on stderr). It fails before this
change with the traceback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mrp1no
mrp1no force-pushed the build-1265-subprocess-errors branch from 0fa5dac to c33d23f Compare November 23, 2026 12:50

@shayderrr shayderrr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review

Reviewed test coverage in PR #4426: Text-mode child processes decode with errors="replace", plus a guard test (BUILD-1265).

Scope: make_game.py, runtime/test/shaders/build.py, runtime/test/shaders/check.py, +31 more
Diff: +232 / -75 across 34 file(s).

The change stays inside the stated scope and the touched files line up with the description. No unrelated production paths are pulled in, and the stated behavior is directly exercised by the diff. I'm approving this one.

Reviewed by shayderrr via automated batch review.

@shayderrr

Copy link
Copy Markdown
Collaborator

Thanks @mrp1no - I went through Text-mode child processes decode with errors="replace", plus a guard test (BUILD-1265) and the diff around make_game.py. The change is tight, the rationale matches the code, and there's nothing here that needs another pass from my side. Approved and squash-merging it into main now. Nice work.

@nicknickalive

Copy link
Copy Markdown

Tested c33d23f (trial-merged onto main 561b65a) on NVIDIA GeForce RTX 5090 (610.88, subgroup 32..32) and AMD Radeon iGPU (RDNA2, AMD 32.0.21036.18, subgroup 32..64), Windows 11 Pro 26200: pass.

  • pytest test_bary_fallback_gs.py test_spirv_gs_to_compute.py test_subprocess_text_errors.py: 60 passed
  • run_gpu_tests.py smoke, --filter cs_scc_mask32: pass on both

No game files. AI-assisted.

@mrp1no

mrp1no commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto 1cc6e3c1 (now 51b0fed96). There were conflicts in tools/hw_oracle/runner.py and tools/rdna2spirv.py. I kept main's newer lines (the -m elf64_amdgpu link, the spirv-val flags) and added errors="replace" to them.

Two new commits:

  • tools/vk_fuzz_run.py: this file reached main after the last rebase. Its three text-mode calls (llvm-mc, the translator and the GPU runner) are read only for messages and the error: check, so they get errors="replace". The guard test lists them.
  • tests/test_hw_oracle.py: test_the_hip_linker_uses_amdgpu_elf_emulation, new on main, asserts the exact ld.lld call, which now has errors="replace".

Tests against a 1cc6e3c1 baseline on the same machine:

  • pytest tests --ignore=tests/semantic -n 8: the same 14 failures as main, no new ones.
  • test_hw_oracle.py and test_subprocess_text_errors.py: 61 passed.

AI-assisted (Claude Code).

@mrp1no
mrp1no force-pushed the build-1265-subprocess-errors branch from c33d23f to 51b0fed Compare November 23, 2026 14:38
mrp1no added a commit to mrp1no/Leonida that referenced this pull request Nov 23, 2026
…d here

In text mode CPython decodes captured output on the reader threads. A byte that
isn't UTF-8 there loses that stream: a console-code-page warning on stderr came
back as None, and a bad stdout left text None, so the version regex raised a
TypeError that hid the cause (@nanyoudegege on ItsNotRexed#4426, CP936). spirv-dis now runs
in binary mode. Its stdout is decoded as strict UTF-8 on the caller's thread, and
a failure exits 2 with "spirv-dis output is not UTF-8", plus spirv-dis's stderr
with errors="replace". spirv-as keeps its strict UTF-8 stdin.

test_cli_reports_disassembly_that_is_not_utf8 runs a stand-in spirv-dis through
SPIRV_DIS (non-UTF-8 stdout, a CP936 warning on stderr). It fails before this
change with the traceback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mrp1no and others added 9 commits November 23, 2026 16:49
…="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, bvh_gpu_smoke,
gen_gdk_runtime_classes, sandbox and rdna2spirv's assembler call;
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>
tracked_python() split git ls-files' text output on whitespace, so a path with a space was cut in two and a path
with a non-ASCII letter (which git prints quoted) was dropped by the prefix filter: neither file was checked
(@nanyoudegege's review). It now reads `git ls-files -z` as bytes and splits on NUL. A new test tracks
tools/plain.py, "tools/with space.py" and tools/é.py in a scratch repository and expects all three; with the old
parsing it gets ['tools/plain.py', 'tools/with'].

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
spirv-dis's output is assembly source that goes back to spirv-as through stdin, and its OpEntryPoint/OpName
strings are UTF-8 in SPIR-V. errors="replace" in the locale's code page could turn a non-ASCII name into other
bytes on the way back (@nanyoudegege's review). Both calls now pass encoding="utf-8" and errors="strict": the text
is exact, and a byte that doesn't decode is an error instead of a silent replacement. The guard test still sees an
explicit errors= on both.

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

The rebase onto 561b65a brought eight new subprocess.run calls that decode
child output (glslc, spirv-as, vk_harness, clang --version, glslangValidator,
the ps_sweep runs, git rev-parse, the w64 graphics harness) without errors=;
the guard test lists them. They only read the output for messages, so they
take errors="replace" like the others.

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

In text mode CPython decodes captured output on the reader threads. A byte that
isn't UTF-8 there loses that stream: a console-code-page warning on stderr came
back as None, and a bad stdout left text None, so the version regex raised a
TypeError that hid the cause (@nanyoudegege on ItsNotRexed#4426, CP936). spirv-dis now runs
in binary mode. Its stdout is decoded as strict UTF-8 on the caller's thread, and
a failure exits 2 with "spirv-dis output is not UTF-8", plus spirv-dis's stderr
with errors="replace". spirv-as keeps its strict UTF-8 stdin.

test_cli_reports_disassembly_that_is_not_utf8 runs a stand-in spirv-dis through
SPIRV_DIS (non-UTF-8 stdout, a CP936 warning on stderr). It fails before this
change with the traceback.

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

tools/vk_fuzz_run.py came to main after the last rebase. It reads llvm-mc, the
translator and the GPU runner output only for messages and the "error:" check,
so those calls take errors="replace" like the others. The guard test lists them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test came with main after the last rebase. It asserts the exact
subprocess.run call of the ld.lld step in Oracle._assemble, which this PR gives
errors="replace" like every other text-mode child process.

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

Copy link
Copy Markdown

Tested 51b0fed9 merged onto main d0835dd9 on an AMD Radeon 760M (RDNA3 iGPU, gfx1103, subgroup 32..64), RADV Mesa 26.3.1, CachyOS Linux: pass

  • Setup: the head already contains main 1cc6e3c1, so the merge onto d0835dd9 was a fast-forward. The runtime test programs were built from this tree (RelWithDebInfo). The comparison run is 1cc6e3c1 without this PR, using the same binaries.
  • scripts/run_gpu_tests.py with this branch's runner and build.py: native 219/235 passed, 16 skipped, 0 failed; LEONIDA_W64_EMULATE=1 the same.
    • build.py: 241 shaders, 241 translated, 241 pass spirv-val.
    • No Traceback or UnicodeDecodeError in either log.
  • Per-test comparison:
    • Against 1cc6e3c1 without the PR: identical in both modes (219/235, 16 skipped).
    • Against d0835dd9 without the PR (196/210, 14 skipped): every test in that run has the same result. The 25 newer tests (23 pass, 2 skipped as "run by ...") come from main since then; this PR adds no fixtures.
  • tests/test_subprocess_text_errors.py: 4 OK. The guard ran; it did not skip.
  • Other test files:
    • tests/test_bary_fallback_gs.py: 28 OK.
    • pytest tests/test_spirv_gs_to_compute.py: 28 passed, with real spirv-dis/spirv-as.
    • pytest tests/test_run_gpu_tests.py: 49 passed.
    • pytest tests/test_hw_oracle.py: 56 passed, 10 skipped (9 need LEONIDA_HW_DRM_NODE, 1 is cmd.exe-only). test_the_hip_linker_uses_amdgpu_elf_emulation passed.

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

@mrp1no
mrp1no force-pushed the build-1265-subprocess-errors branch from 51b0fed to c0e750b Compare November 23, 2026 15:50
@mrp1no

mrp1no commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @lunarminus. Rebased again onto 2c72b0d2 (now c0e750b35). The only conflict was runtime/test/shaders/check.py's run(), which gained cwd= on main (#6833); it now has both cwd=cwd and errors="replace". tests/test_shader_checks.py fails 15 tests on main itself since #6833 (its mock harness takes no cwd), identically with this branch. @richardsenra has claimed that fix. 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.