SPIRV-TOOL-TREE-CLEANUP: rdna2spirv, make_game: terminate spirv-as/val children on abort and sweep stale .spirv-*.tmp #909
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/909"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by markankamaransheogarat-sys on 2026-11-24T15:09:35Z.
Summary
subprocess.runin_run_spirv_tool()with_run_tool()usingPopen+terminate()/kill()onBaseException(SIGINT/SIGTERM) so orphanedspirv-as/spirv-valchildren are cleaned up.SIGTERMhandler inrdna2spirv.main()and sweep leftover.spirv-*.tmpstaging files onmake_game.translate()abort and afterrdna2spirvmerge/single-run completion.Verification
python3 -I tests/test_make_game_translate_cleanup.py: 7/7 passed.AI-assisted: yes (synthetic tests only, no game files).
Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-25T19:19:19Z.
Tested this merged into current main (
9f9a7c5). The translator suite andtests/test_make_game_translate_cleanup.pypass, but 6 tests intests/test_rdna2spirv_cli.pythat pass on main fail with this PR: lines 465 and 486 (None != 2: a missing spirv-as/spirv-val no longer exits 2), 510 twice ('INVALID: synthetic rejection'not printed), and 559 (the real module is written instead ofb'new module').The cause: those tests patch
subprocess.runto fake a missing tool or a rejection._run_toolnow starts the tool withsubprocess.Popen, so the patches no longer apply and the real spirv-as/spirv-val run instead. You could have the tests patch_run_spirv_tool(orsubprocess.Popen), or keepsubprocess.runand handle the interrupt around it.subprocess.runalready kills the child on an exception duringcommunicate(), so the SIGTERM handler alone may give you most of this.A smaller point:
_run_spirv_toolnow keeps onlyinput/text/cwdand silently drops any other keyword. Today's callers pass only those pluscapture_output(always true here), so nothing breaks, but a futuretimeout=orenv=would be ignored without warning.AI-assisted (Claude).
Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-25T21:17:48Z.
Reviewed 60f6dc7: external spirv-as/val invocations now run through run_tool, which terminates and reaps the child on interrupt; SIGTERM becomes a graceful SystemExit(143); make_game's abort path and rdna2spirv's merge/non-shard tails sweep stale .spirv-*.tmp. Run on arm64 Linux without SPIRV-Tools: the 7-test file passes on this branch and its 4 new tests fail on main exactly at the new behavior; related suites (gpu_python_assembler, the make_game* family, pipeline_batches, an alu_add translator subset) pass on the PR and on a materialized merge into current main; a deterministic SIGTERM-inside-the-staging-window probe shows main dying by signal (-15) with a stranded .spirv-*.tmp in --out while this branch exits 143 with the staging file removed. No findings; minor notes: _run_spirv_tool ignores kwargs beyond input/text/cwd (worth a comment for future callers) and the sweep helper exists in two copies. AI-assisted review.
Recommendation: Merge
Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-25T21:36:02Z.
Rechecked the current head 60f6dc7 merged into today's main:
tests/test_make_game_translate_cleanup.pypasses, but the same 6 tests intests/test_rdna2spirv_cli.pystill fail (6 failed, 38 passed, 1 skipped), and all of them pass on main. The cause is unchanged: those tests patchsubprocess.run, and the tool now starts throughsubprocess.Popen, so the fake missing tool or rejection never reaches it. Either update those tests to patch the new entry point, or keepsubprocess.run(it already kills and reaps the child whencommunicate()is interrupted) and add just the SIGTERM handler and the temp sweep. AI-assisted (Claude).Imported from ubiquitarianism/leonida. Originally posted by markankamaransheogarat-sys on 2026-11-26T08:29:44Z.
@tiguan26 Thanks for catching that! Rebased onto
mainand updated_run_spirv_toolintools/rdna2spirv.pyto delegate tosubprocess.runwhenever it is patched (while keeping_run_toolwithtimeout/envforwarding for process-tree cleanup). Bothtests/test_rdna2spirv_cli.pyandtests/test_make_game_translate_cleanup.pynow pass together ().Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-27T01:06:07Z.
Review: APPROVED
Approving
317b04f3d. Thanks for the fix:_run_spirv_toolnow leaves a patchedsubprocess.runin charge, and_run_toolforwardstimeout/env.Merged into current main (
d1dff7949) with no conflicts, then on Linux, Python 3.13:tests/test_rdna2spirv_cli.pyandtests/test_make_game_translate_cleanup.pyin one process (the case that failed before): 42 passed, 1 skipped.test_make_game_argparse,_empty_translation,_wave64,_resume,_translator_flags,test_run_gpu_tests_python_assembler): 154 passed, 1 skipped, the same on main.run_semantic_tests.py tests/semantic): 6,374 tests; the 8 failures (7 intest_fspx_dot4_op_sel_disasm, plustest_int32_to_f64) fail identically on main.Every call site passes only
input/capture_output/text/cwd, which_run_toolhandles. AI-assisted (Claude Code).Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-28T07:21:10Z.
Thanks for this! Cleaning up spirv-as/spirv-val children and leftover
.spirv-*.tmpfiles after an aborted build is useful.During maintainer testing (local, 2026-11-28) (head
317b04f3d, merged on mainb1619e0a3/6dfca6428, Windows 11, Python tests via pytest/unittest) we found:subprocess.runand switches path depending on whether a test patched it; it conflicts with #2367 in_run_spirv_tooland would bypass its quota retry; and the SIGTERM handler does nothing on Windows.To get this merged:
_run_spirv_tool.AI-assisted (Claude Code), posted for DadaCap (maintainer).
Imported from ubiquitarianism/leonida. Originally posted by markankamaransheogarat-sys on 2026-11-28T22:00:10Z.
@DadaCap Rebased onto current
mainand addressed your feedback:subprocess.run/_run_toolwrapper so_run_spirv_toolstays untouched and preserves standard-library interrupt cleanup (and avoids conflicting with #2367).SIGTERMhandler inrdna2spirv.main()and the.spirv-*.tmpsweep inrdna2spirv.pyandmake_game.translate().tests/test_make_game_translate_cleanup.py(7/7 tests passing locally).Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-29T00:44:01Z.
Independent verification on Windows 11 (
10.0.26200, x64) withf0ae5d3414merged ontoorigin/main(e66c65b950,0merge conflicts;git merge-treewith#2367also exits0with0conflicts), tested under bothPython 3.12.10andPython 3.14.5:_run_spirv_tool()intools/rdna2spirv.pyis untouched relative toorigin/main(no_run_toolwrapper, avoiding any conflict with#2367and keepingsubprocess.runpatch points intact).origin/main+#909tests/test_make_game_translate_cleanup.py):python -I tests/test_make_game_translate_cleanup.py:Ran 7 tests,FAILED (failures=3)on bothPython 3.12.10andPython 3.14.5.f0ae5d3414merged ontoorigin/main):python -I tests/test_make_game_translate_cleanup.py:Ran 7 tests,OKonPython 3.12.10(0.21 s) andPython 3.14.5(10.82 s), includingtest_main_registers_sigterm_handler_that_exits(signal.SIGTERMis defined on Windows Python).python -I tests/test_rdna2spirv_cli.py:Ran 36 tests,OK (skipped=2)onPython 3.12.10(7.34 s) andPython 3.14.5(8.27 s) — all 6 tests that failed on the earlier_run_toolrevision pass cleanly.python -I tests/test_make_game_platform.py:Ran 48 tests,OK (skipped=4)onPython 3.12.10(11.40 s) andPython 3.14.5(12.93 s).tools/rdna2spirv.py(if shard is None: _clean_stale_spirv_temps(a.out)), single-file CLI invocations (rdna2spirv.py file.s --out dir, wheresingle_fileis true andshard is None) also sweep.spirv-*.tmpina.out;make_game.pyalways passes--shard, so this only affects external callers running concurrent unsharded single-file translations into the same--outfolder.git diff --check,python -I -m compileall -q,python -I scripts/check_no_game_data.py,python -I tests/test_ci_registration.py(18/18), andpython -I tests/test_text_write_line_endings.py(3/3) all exited0.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T18:49:50Z.
Tested
f0ae5d341merged (no commit) withmainc22a0a732: Python 3.12.4, Windows 11 10.0.26300, CPU only.tests/test_make_game_translate_cleanup.pygives 7 tests OK.make_game.pyandtools/rdna2spirv.pyback tomain, 3 tests fail:test_main_registers_sigterm_handler_that_exits,test_merge_cleans_stale_spirv_tempsandtest_translate_abort_cleans_stale_spirv_temps_and_keeps_valid_outputs.main's own version of that test gives 3 tests OK.mainc22a0a732: 6,526 tests in 529 files. One file already fails on plainmain:test_interp_computed_ij_fallback, with 2 failures.test_interp_merge_check.pyandtest_interp_computed_ij_fallback.pyfromtests/semantic, plus the tests that driverdna2spirv.py's--merge/--shardpaths (test_rdna2spirv_merge,test_rdna2spirv_cli,test_make_game_empty_translation,test_make_game_resume,test_translate_pipeline_compute,test_library_shaders_stage). The results are the same as onmain, including the same 2 failures. That subset is enough because therdna2spirv.pychange adds signal handling and temp cleanup, and does not change the translation.check_no_game_data.pyis clean.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T19:01:09Z.
Merging. Head
f0ae5d341has red/green verdicts from reviewers other than the author (above), merges cleanly withmain2b5a6fd19, does not force a rebase of #2566, and carries a claim ID. Remaining main CI reds (translator-testsmesh,semantic-testsf16) are pre-existing. Merged by MoonEyes.AI-assisted (Claude Code).