mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:00:52 +01:00
[PR #1911] salu_diff: validate branch skips, register operands, arity, SIMM16, and comma sizing (SALU-DIFF-REF-VALIDATION) #1920
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1920
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1911
Author: @ShotTechOp
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/salu-diff-ref-validation📝 Commits (1)
f51d607salu_diff: validate branch skips, register operands, arity, SIMM16, and comma sizing (SALU-DIFF-REF-VALIDATION)📊 Changes
2 files changed (+154 additions, -22 deletions)
View changed files
📝
tests/test_salu_diff.py(+45 -0)📝
tools/salu_diff.py(+109 -22)📄 Description
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.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.