fix: the Rust RDNA 2 interpreter refuses a register group past v255 instead of aborting #437
No reviewers
Labels
No labels
accessibility
bloqué : binaire console
bug
chargeur
console-dll
cpu
documentation
duplicate
enhancement
good first issue
gpu
help wanted
invalid
performance
question
runtime-gdk
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LooperSalty--AnyXboxX!437
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-437"
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?
@Luke-Ervin on GitHub · 2026-11-26 18:46 UTC · original
Luke-Ervin:fix/rdna2-vgpr-pair-past-v255→main· +122 −7 · 8 files · 3 commits · openChange
The Rust reference interpreter (
crates/anyxboxx-rdna2-ref) now returns its operand error when a VGPR group runs past v255, instead of aborting.A 64-bit vector result is written to
vdst,vdst + 1; withvdst = 255there is no second register. Five places indexedwave.vfor such a group without checking where it ends, and the binary aborted (index out of bounds: the len is 256 but the index is 256; the release profile aborts on panic):wide.rsdiv.rsv_div_scale/fmas/fixup_f64vop3_forms.rsv_mad_u64_u32(v_mad_i64_i32shares the code but is refused earlier in both models, for its signed carry)sad.rs(×2)v_qsad_pk_u16_u8,v_mqsad_pk_u16_u8; 128-bit result and 128-bit source S2 ofv_mqsad_u32_u8(four registers, from v253)The crate already answers this case on the source side:
compare::read64returnsError::Operandfor a 64-bit source pair at v255, and the memory, image, typed-buffer and LDS code check their groups the same way. These five sites were missing the check.Wave::vgpr_group(first, count)returnsfirstwhen thecountregisters exist,Error::Operandotherwise.read64, the check is inside the lane loop: with no active lane the instruction still does nothing and succeeds. Programs that ran before run exactly as they did; only the aborts change.Left open, for the maintainers: the Python model raises
IndexErrorin all of these cases (an uncaught list index, after writing the low half of the result in the first active lane), which the parity harness does not turn into an error line, so the two models cannot be compared on these programs yet. Whether the Python should raiseUntranslatedthere, with the Rust following, is not decided here. The new test states the current pairing (error operand/IndexError) explicitly, and is named for what it checks (..._is_an_operand_error_in_rust), so a later change has to update it on purpose.docs/rust-full-status.mdanddocs/fr/rust-full-status.mdrecord the finding. No README row or test-count change (1904 collected, still1900+).Linked issue: none.
Verification
Run on Linux (Ubuntu, Python 3.13, Rust 1.98.1), on top of
mainatf088a43, and again merged with the newestmain(74dfb48) and with #402 and #403 (1458 passed, 449 skipped), withanyxboxx-rdna2-refandanyxboxx-pebuilt bycargo build --release -p anyxboxx-rdna2-ref -p anyxboxx-pe:Reproduction before the fix (input to
anyxboxx-rdna2-ref):lanes 32,scc 0,primitive 0,program D70100FF 02020481 BF810000(v_ashrrev_i64 v[255:256], 1, v[2:3]). The process aborted atwide.rs:251; it now printserror operand.Not run (the 449 skipped tests): everything that needs Windows, the C++ runtime,
dxcor a GPU, and the Rust crates that only build for Windows;cargo test --workspacefor the same reason. No Windows machine was available. The change is bounds checking on aVec. No game was run.Oracle and test data
v_ashrrev_i64withvdst = 255). The generator's VOP3 encoder keepsvdstbelow 255 only for names ending in_f64, so the 64-bit shifts, the VOP3 forms ofv_cvt_f64_*and the SAD forms can still be drawn with a destination group past v255; the 300 seeded programs happen not to.assert_same. For the refused cases there is no shared error line yet (see "Left open").test_a_register_group_past_v255_is_an_operand_error_in_rustfails on the old binary, whose process aborts. It runs 15 programs across the five sites: eleven 64-bit results (nine VOP3, two VOP1), the 128-bit result ofv_mqsad_u32_u8, the 64-bit S2 pair of the two packed SAD forms and the 128-bit S2 ofv_mqsad_u32_u8. The source registers are filled first with values that differ by lane and register, so the programs that fit write non-zero results that both models must agree on. Rust unit tests:a_register_group_must_end_at_v255(wave.rs) anda_64_bit_result_at_v255_is_refused_without_mutation(wide.rs).Checklist
E_NOTIMPL), never a fake success.test_readme_sync.pychecks it). No README change needed.This change was made with AI assistance (Claude Code): the bug was found, fixed and tested by the AI as described above. It was not tested on Windows.
🤖 Generated with Claude Code
https://claude.ai/code/session_01CVSn4bUDfLBFvceKVLPSX5
A 64-bit vector result is written to the pair vdst, vdst + 1. With vdst = 255 there is no second register. Five places of crates/anyxboxx-rdna2-ref indexed `wave.v` for such a group without checking where it ends, so the binary aborted with "index out of bounds: the len is 256 but the index is 256" (the release profile aborts on panic): wide.rs 64-bit result of the f64 operations and the 64-bit shifts div.rs 64-bit result of v_div_scale/fmas/fixup_f64 vop3_forms.rs 64-bit result of v_mad_u64_u32 (v_mad_i64_i32 shares the code but both models refuse it earlier, for its signed carry) sad.rs (x2) 64-bit result and 64-bit source S2 of v_qsad_pk_u16_u8 and v_mqsad_pk_u16_u8; 128-bit result and 128-bit source S2 of v_mqsad_u32_u8, which take four registers and overflow from v253 An abort is not one of the interpreter's answers: the CLI prints nothing, and the caller sees a dead process instead of an error line. The crate already has the right answer for this case elsewhere: compare::read64 returns Error::Operand ("paire de registres vectoriels hors plage") for a 64-bit *source* pair at v255, and the memory, image, typed-buffer and LDS code check their register groups the same way. These five sites were simply missing the check. What changed: - Wave::vgpr_group(first, count) returns `first` when the `count` registers starting there exist, and Error::Operand otherwise. - Each of the five sites calls it before its first write (or read, for the 128-bit source), so a refused instruction changes nothing in the wave. Like read64, the check sits inside the lane loop: with no active lane the instruction still does nothing and succeeds, as before. Programs that ran before run exactly as they did; only the aborts change. Why Operand and not Untranslated: it is what the crate already returns for the same situation on the source side, and error.rs defines Operand as "an operand or register the model refuses". The Python model raises IndexError in all of these cases (an uncaught list index, after it has written the low half of the result in the first active lane), which the parity harness does not turn into an error line, so the two models cannot be compared on these programs yet. Whether the Python should raise Untranslated there instead, with the Rust following, is a decision for the maintainers and is not taken here; the new test states the current pairing explicitly so that a later change has to update it on purpose. How the list was established: every VOP1, VOP2, VOP3, VOP3P and VOPC opcode was run through the release binary with the destination at v255 and v254 and with sources at v255, v254, v0-v2 and an inline constant. 29 mnemonics aborted, all at these five lines; after the change none does. The first one was found by the parity generator on extra seeds (v_ashrrev_i64 with vdst = 255): the generator's VOP3 encoder keeps vdst below 255 only for names ending in `_f64`, so the 64-bit shifts, the VOP3 forms of v_cvt_f64_* and the SAD forms can still be drawn with a destination group past v255. Tests: - wave.rs: a_register_group_must_end_at_v255. - wide.rs: a_64_bit_result_at_v255_is_refused_without_mutation. - tests/test_rdna2_ref_parity.py: test_a_register_group_past_v255_is_an_operand_error_in_rust, 15 programs across all five sites: eleven 64-bit results (nine VOP3, two VOP1), the 128-bit result of v_mqsad_u32_u8, the 64-bit S2 pair of the two packed SAD forms and the 128-bit S2 of v_mqsad_u32_u8. Each must give "error operand" in Rust and IndexError in Python; the same instruction one register lower must run and agree in both. The source registers are filled with values that differ by lane and register first, so the programs that fit write non-zero results. It fails on the old binary (the process aborts). docs/rust-full-status.md and its French version record the finding. Not checked: Windows. The change is bounds checking on a Vec. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_01CVSn4bUDfLBFvceKVLPSX5@chatgpt-codex-connector[bot] on GitHub · 2026-11-26 18:47 UTC · original · edited 2026-11-26 18:49 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
2c116aeℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.