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

Open
illuminatedfellow wants to merge 1 commit from upstream-pr/325 into main
illuminatedfellow commented 2026-11-26 16:52:14 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by illuminatedfellow on 2026-11-26T16:52:14Z.


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.)

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:6631356191 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/325). Originally posted by [illuminatedfellow](https://github.com/illuminatedfellow) on 2026-11-26T16:52:14Z. --- `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.)
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/325:upstream-pr/325'
git switch 'upstream-pr/325'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/325'
git switch 'upstream-pr/325'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/325'
git switch 'upstream-pr/325'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/325'
git switch 'main'
git merge --squash 'upstream-pr/325'
git switch 'main'
git merge --ff-only 'upstream-pr/325'
git switch 'main'
git merge 'upstream-pr/325'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
avatarmanz/VIctory-7900XTX!325
No description provided.