ir::build: a scalar code past the registers is not an index past unspill's table #325

Open
github-bot wants to merge 1 commit from github-bot/gh-325 into main AGit
Owner

@⁠illuminatedfellow on GitHub · 2026-11-26 16:52 UTC · original
illuminatedfellow:fix/unspill-scalar-codes → main · +20 −1 · 1 files · 1 commits · open

ir::build → unspill marks the scalar codes a program uses in used: [bool; 128], but an instruction's effects can name a scalar code up to 255 — e.g. a VOP3-encoded compare whose sdst field holds a constant's code (0xD4C5A8D7: sdst 215). That panics with index out of bounds (ir.rs:336) instead of returning a translation error, and a panic during translation takes the process down. used is now 256 wide, like stores and other next to it; with that, these programs come back as ordinary errors.

How it was found: fuzzing the whole translation on Linux — mutated instruction arrays from the crate's own tests plus random words, run through ir::build, structure, resource::track, io::raise and lower with overflow checks on. About 1,400 of 3,000,000 programs hit this one; it was the only panic class without an open fix. With this change and #308, 800,000 further programs ran without a panic.

Test: scalar_codes_past_the_registers_do_not_panic (three of the smallest crashing programs, each with a v_writelane_b32 so the parking search runs). It fails without the change (ir.rs:336) and passes with it; cargo test -p victory-shader 210 passed on Linux.

Relation to #268: #268 returns early from unspill when nothing is parked, which hides the three bare programs but not ones that park a scalar — with #268 alone the test still panics (ir.rs:341). The two changes don't overlap textually.

The other panic class the fuzzer found (debug_assert!(self.s.threads.is_none() || self.console_lanes) in cross_lane, from v_cndmask_b32 on a numeric lane mask) is fixed by #308 — noted there.

(Written with Claude Opus 5.5.)

**@⁠illuminatedfellow** on GitHub · 2026-11-26 16:52 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/325) `illuminatedfellow:fix/unspill-scalar-codes` → `main` · +20 −1 · 1 files · 1 commits · open `ir::build` → `unspill` marks the scalar codes a program uses in `used: [bool; 128]`, but an instruction's effects can name a scalar code up to 255 — e.g. a VOP3-encoded compare whose `sdst` field holds a constant's code (`0xD4C5A8D7`: sdst 215). That panics with *index out of bounds* (`ir.rs:336`) instead of returning a translation error, and a panic during translation takes the process down. `used` is now 256 wide, like `stores` and `other` next to it; with that, these programs come back as ordinary errors. **How it was found:** fuzzing the whole translation on Linux — mutated instruction arrays from the crate's own tests plus random words, run through `ir::build`, `structure`, `resource::track`, `io::raise` and `lower` with overflow checks on. About 1,400 of 3,000,000 programs hit this one; it was the only panic class without an open fix. With this change and #308, 800,000 further programs ran without a panic. **Test:** `scalar_codes_past_the_registers_do_not_panic` (three of the smallest crashing programs, each with a `v_writelane_b32` so the parking search runs). It fails without the change (`ir.rs:336`) and passes with it; `cargo test -p victory-shader` 210 passed on Linux. **Relation to #268:** #268 returns early from `unspill` when nothing is parked, which hides the three bare programs but not ones that park a scalar — with #268 alone the test still panics (`ir.rs:341`). The two changes don't overlap textually. The other panic class the fuzzer found (`debug_assert!(self.s.threads.is_none() || self.console_lanes)` in `cross_lane`, from `v_cndmask_b32` on a numeric lane mask) is fixed by #308 — noted there. (Written with Claude Opus 5.5.)
unspill marks the scalar codes a program uses in a table of 128, but an
instruction's effects can name a code up to 255 (a VOP3 compare whose
sdst field holds a constant's code, e.g. 0xD4C5A8D7), which panicked
with an index out of bounds instead of a translation error. The table
now covers every code, as stores and other beside it already do.

Found by fuzzing the translator on Linux (mutated test programs and
random words through ir::build, structure, resources, io and lowering):
about 400 of 800,000 programs hit it. Still reachable with #268, whose
early return only skips programs that park no scalar: the test parks one.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 16:54:09 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/325/head:github-bot/gh-325'
git switch 'github-bot/gh-325'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-325'
git switch 'github-bot/gh-325'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-325'
git switch 'github-bot/gh-325'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-325'
git switch 'main'
git merge --squash 'github-bot/gh-325'
git switch 'main'
git merge --ff-only 'github-bot/gh-325'
git switch 'main'
git merge 'github-bot/gh-325'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.