fix: the Rust RDNA 2 interpreter refuses an indexed register past 32 bits #402
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!402
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-402"
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 17:26 UTC · original
Luke-Ervin:fix/rdna2-ref-movrel-index-overflow→main· +52 −10 · 4 files · 2 commits · openChange
The Rust reference interpreter (
crates/anyxboxx-rdna2-ref/src/movrel.rs) now refuses a movrel register index that passes 2^32, as the Python model does. Before, it added the register number and M0 asu32:attempt to add with overflow) instead of returning the interpreter's error.emu/rdna2_exec_movrel.py): unbounded integers, index0x10000002C, refused as outside the model (Untranslated), which is what its docstring specifies.check()now takes the register and the offset separately and adds them inu64before applying the same range and even-pair rules. Nothing changes for sums below 2^32.Affected forms:
s_movrels_b32/b64,s_movreld_b32/b64,v_movrels_b32,v_movreld_b32,v_movrelsd_b32. Not affected: the_2forms andv_swaprel_b32(10-bit fields of M0, cannot overflow) andv_swap_b32(no offset).docs/rust-full-status.mdanddocs/fr/rust-full-status.mdrecord the finding. No README row or test-count change (1902 collected, still1900+).Linked issue: none.
Verification
Run on Linux (Ubuntu, Python 3.13, Rust 1.98.1), on top of
mainat47759e8, 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,s 124 FFFFFFFD,s 44 12345678,program BEE62E2F BF810000. Release printeds 102 12345678; debug panicked atmovrel.rs:134. Both now printerror untranslated.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 plain integer arithmetic. No game was run.Oracle and test data
tests/test_rdna2_ref_parity.py.test_indexed_registers_past_32_bits_are_refused_by_both_models(seven forms × M0 =0xFFFFFFFD,0xFFFFFFFF,0x80000000, plus M0 = 1 as the in-range control) fails on the old release binary. The Rust unit testan_index_past_32_bits_is_refused_not_wrappedpins the refusal.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
The movrel instructions address a register by "register number in the instruction + M0". The Rust port (crates/anyxboxx-rdna2-ref/src/movrel.rs) added the two as u32. M0 is a full 32-bit register, so the sum can pass 2^32: M0 = 0xFFFFFFFD, s_movrels_b32 s102, s47 -> 47 + 0xFFFFFFFD = 0x10000002C - In a release build the sum wrapped to 44, which is in range, so the instruction ran and copied s44. That is a wrong result reported as success. - In a debug build the same addition panicked ("attempt to add with overflow") instead of returning the interpreter's own error. - The Python model (emu/rdna2_exec_movrel.py) uses unbounded integers, sees 0x10000002C, and refuses it as outside the model, which is what its docstring specifies: the hardware's behaviour for an index outside the registers is not described, so it raises Untranslated. So the two reference interpreters disagreed, and the Rust one broke rule 3 of AGENTS.md (no fake success). The Python is the model the port is checked against, and its refusal is the documented behaviour, so the Rust is the side that changes. What changed: check() now takes the register and the offset separately and adds them in u64, then applies the same range and even-pair rules. Nothing changes for sums below 2^32. The four call sites (vector destination, vector source, scalar source, scalar destination) pass the two parts instead of their u32 sum. The error message prints the unwrapped index, as the Python does. Affected forms: s_movrels_b32/b64, s_movreld_b32/b64, v_movrels_b32, v_movreld_b32, v_movrelsd_b32. Not affected: the _2 forms and v_swaprel_b32, which add 10-bit fields of M0 to a register number below 512 and cannot overflow, and v_swap_b32, which adds nothing. Why the existing tests missed it: the 300 seeded parity programs set M0 below 256, so a large M0 only appears when an earlier random instruction happens to write s124. It was found by running the same generator on 6,000 more seeds with special values (NaN patterns, 0xFFFFFFFF, ...) in the scalar registers; one program wrote a large value to M0 and then ran s_movrels_b32. Tests: - movrel.rs: an_index_past_32_bits_is_refused_not_wrapped (fails to compile against the old check(); the behaviour it pins is the refusal). - tests/test_rdna2_ref_parity.py: test_indexed_registers_past_32_bits_are_refused_by_both_models runs the seven affected forms with M0 = 0xFFFFFFFD, 0xFFFFFFFF and 0x80000000 and expects "error untranslated" from both interpreters, plus M0 = 1 as the in-range control. It fails on the old release binary and passes now. docs/rust-full-status.md and its French version record the finding. Not checked: Windows. The change is plain integer arithmetic with no platform-specific code. 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 17:26 UTC · original · edited 2026-11-26 17:28 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
1fe066aℹ️ 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.
@akimfomin on GitHub · 2026-11-26 23:21 UTC · original
The movrel overflow regression catches the old arithmetic in an optimized Windows build. On
b676bbc429aa3c98ab36b7d3b4907a6dd1935618all three movrel tests passed in debug and release. In an isolated copy of the exact reference crate, I then restored wrapping only incheck; the regression failed because the unsupported index returned success. Pinned source and regression. This crate-only run excludes launcher and audio.The PR also merges cleanly against the actual post-#454
b6d86cf. A useful final guard is to keep the overflow case in the release-mode reference test job, where the original wrong success is observable. PortBridge · AI-assisted test report.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.