sdwa_diff: guard asm.family() oracle leak, validate oracle/CLI/reference inputs, and restore KNOWN #1653
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!1653
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/sdwa-diff-oracle-cli-and-ref"
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?
Pull request successfully merged and closed
Item ID:
SDWA-DIFF-ORACLE-CLI-AND-REFClaim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7155622653
Summary
tools/sdwa_diff.py): catchValueErrorfromasm.family(oracle.arch)(e.g.gfx900or unsupported arch strings), closeoracle, printhardware oracle unavailable: ..., and return exit77instead of crashing and leaking the oracle handle.KNOWNinmain()'sfinallyblock (and handle--list-ops/--self-testbefore mutating it) so in-process calls do not permanently leakKNOWN = True.oracle is not None, exact result-list length inhw_prepare(), and 4-word tuples/lists in_diff()(turning short/malformed oracle or shrink responses into cleanRuntimeError-> exit2instead ofAttributeError/IndexError). Catch transientSkipduring the final shrunk recheck and fall back to the original failure detail.--hw-arch,--build, and--work.RefErroron unknown SDWA selectors (src*_sel/dst_sel), unknowndst_unusedmodes (previously fell through silently toUNUSED_PAD), wrong operand counts, non-VGPR destinations, and unparseable operands.tests/test_sdwa_diff.py): add 5 regression tests covering all of the above.Verification
python3 -W error -I tests/test_sdwa_diff.py -v: 27 passed, 0 failed (2.469s).main: ran=27, failures=4, errors=6.python3 -m compileall -q tools/sdwa_diff.py tests/test_sdwa_diff.py,python3 -I tests/test_text_write_line_endings.py,python3 -I scripts/check_no_game_data.py: all pass.AI-assisted: yes
GPUs tested: none (CPU unit tests with stubbed hardware oracle and
spirv_mini_interp; no game data)Independent verification (Windows, Python 3.11.9
-I -W error): oracle-leak fix confirmed —asm.family(oracle.arch)ValueError now closes the oracle and exits 77 (previously leaked);hw_prepare/_diffvalidation, shrink Skip fallback,KNOWNfinally-restore,dst_unusedunknown->RefError (was KeyError/silent), operand-count checks per form with vopc early-return ordering correct.test_sdwa_diff.py27 OK (matches body);--self-testok;--oracle hw --hw-arch gfx900-> 77 via covered path; compileall + line-endings + check_no_game_data clean. AI-assisted verification.#1653 | head
1d155fe33807e97a7a5229db494ddb5e61630530|python3 -I tests/test_sdwa_diff.py -v| red: 27 run, 4 failures, 6 errors | green: 27 passed | Red → greenThe file exercised CLI/reference input handling, oracle cleanup and restoration of KNOWN. The baseline failed the added checks.
Copied the PR tests onto clean main
4a54aedcb6b66525e0c9f72a6ea10263337c9141for the baseline, then merged that main into the recorded PR head and reran those files. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Unittest failure/error counts include subtests where applicable. AI-assisted with OpenAI Codex. Batch claim.Merged, thank you @IlyassRS3! This PR (sdwa_diff: guard asm.family() oracle leak, validate oracle/CLI/reference inputs, and restore KNOWN) passed its own tests with main merged in during sodove's verification of this shader batch, so it went in with the batch.
AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.