salu_diff: validate branch skips, register operands, arity, SIMM16, and comma sizing (SALU-DIFF-REF-VALIDATION) #1911
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!1911
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/salu-diff-ref-validation"
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
Claimed in #1608 as
SALU-DIFF-REF-VALIDATION(https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7167019096).What and why
tools/salu_diff.py's scalar reference interpreter and instruction sizer silently accepted malformed operands and out-of-bounds branch skips (or raised rawValueError/IndexErrorinstead ofRefError):branch_skip,reference):rest.startswith("+")accepteds_cbranch_scc0 +-1, makingskip = -1decrement indefinitely (-1, -2, ...) and skip every remaining instruction in the program;reference()also silently allowed branches past the end oflineseven thoughlisting()rejects them.branch_skip()now requires+<non-negative integer>(+0preserved fordrop()during shrinking) andreference()checksi + 1 + br[1] <= len(lines)._parse_src,_write,reference):_write()andv_mov_b32only stripped the first character (int(tok[1:])), sos_add_u32 v4, 1, 2silently wrotesgpr[4],v_mov_b32 s8, 5silently wrotevgpr[8],s_movrels_b32 s4, v5silently readsgpr[5 + m0], non-consecutive pairs likes[4:6]were accepted, and extra operands were ignored. All register operands, pairs (s[N:N+1]), and per-form operand counts are now validated and raiseRefError.cmpk,movk,sopk): out-of-range immediates (outside-0x8000..0xFFFF) were silently truncated to 16 bits instead of raisingRefError.reference,insn_size,_is_literal): splitting on", "broke compact comma spacing (s_add_u32 s4,1,2crashed withIndexError, andinsn_size("s_add_u32 s4,s5,0x12345")returned4instead of8, corrupting branch offsets);_is_literal("")crashed withIndexError.Verification (Windows 11 x64, Python 3.12.10, no GPU / no game data)
origin/mainb0f3d39)python -I tests/test_salu_diff.pytools/salu_diff.py(negative control)python -I tools/salu_diff.py --self-testpython -m compileall -q tools/salu_diff.py tests/test_salu_diff.pypython -I scripts/check_no_game_data.py tools/salu_diff.py tests/test_salu_diff.pygit diff --checkAI-assisted: yes. Synthetic unit tests only; no game data, no GPU required.
Tested on Windows 11, Python 3.12.10, with this PR merged onto current upstream main.
python -m pytest -q tests/test_salu_diff.py:(AI-assisted test run; output checked by hand.)
#1911 | head
f51d6070f7f8542486ca8fb1e51db59868e2c1a4|python3 -I tests/test_salu_diff.py -v| red: 31 run, 16 failures, 10 errors | green: 31 passed | Red → greenThe test file exercised reference semantics, branch skips, register operands, arity, SIMM16 and compact comma spacing.
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 @ShotTechOp! This PR (salu_diff: validate branch skips, register operands, arity, SIMM16, and comma sizing (SALU-DIFF-REF-VALIDATION)) 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.