fix: the Rust RDNA 2 interpreter refuses an indexed register past 32 bits #402

Merged
Luke-Ervin merged 2 commits from upstream-pr/402 into main 2026-11-27 12:57:11 +00:00
Luke-Ervin commented 2026-11-26 17:26:48 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by Luke-Ervin on 2026-11-26T17:26:48Z.


Change

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 as u32:

M0 = 0xFFFFFFFD, s_movrels_b32 s102, s47   →   47 + 0xFFFFFFFD = 0x10000002C
  • Release build: the sum wrapped to 44, so the instruction ran and copied s44 (a wrong result reported as success, against rule 3).
  • Debug build: the addition panicked (attempt to add with overflow) instead of returning the interpreter's error.
  • Python model (emu/rdna2_exec_movrel.py): unbounded integers, index 0x10000002C, refused as outside the model (Untranslated), which is what its docstring specifies.

check() now takes the register and the offset separately and adds them in u64 before 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 _2 forms and v_swaprel_b32 (10-bit fields of M0, cannot overflow) and v_swap_b32 (no offset).

docs/rust-full-status.md and docs/fr/rust-full-status.md record the finding. No README row or test-count change (1902 collected, still 1900+).

Linked issue: none.

Verification

Run on Linux (Ubuntu, Python 3.13, Rust 1.98.1), on top of main at 47759e8, with anyxboxx-rdna2-ref and anyxboxx-pe built by cargo build --release -p anyxboxx-rdna2-ref -p anyxboxx-pe:

python -m pytest                → 1453 passed, 449 skipped
python -m pytest tests/test_rdna2_ref_parity.py → 41 passed
python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools → All checks passed!
cargo test -p anyxboxx-rdna2-ref → 136 passed; 0 failed
cargo clippy -p anyxboxx-rdna2-ref --all-targets -- -D warnings → no warnings
cargo fmt --check -p anyxboxx-rdna2-ref → clean

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 printed s 102 12345678; debug panicked at movrel.rs:134. Both now print error untranslated.

Not run (the 449 skipped tests): everything that needs Windows, the C++ runtime, dxc or a GPU, and the Rust crates that only build for Windows; cargo test --workspace for the same reason. No Windows machine was available. The change is plain integer arithmetic. No game was run.

Oracle and test data

  • Oracle: the Python model, through tests/test_rdna2_ref_parity.py.
  • How it was found: the parity generator of that file, run on 6,000 more seeds with special values in the scalar registers. The 300 seeded programs set M0 below 256, so a large M0 only appears when an earlier random instruction writes s124.
  • Test data: built in the tests (no external data).
  • Failure case: 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 test an_index_past_32_bits_is_refused_not_wrapped pins the refusal.

Checklist

  • The PR covers a single reviewable behaviour.
  • A test fails without this change and passes with it.
  • The commands and results of each check are given above.
  • An unimplemented function returns an error (E_NOTIMPL), never a fake success.
  • README: the same change in the English and French READMEs (test_readme_sync.py checks it). No README change needed.
  • No game, console or SDK file, no key, no dump, no download link.
  • Findings drawn from a title: none in this PR.
  • Code taken from another project: none in this PR.

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

<!-- greyfinch-sync:LooperSalty/AnyXboxX:issue:5514505192 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/402). Originally posted by [Luke-Ervin](https://github.com/Luke-Ervin) on 2026-11-26T17:26:48Z. --- ## Change 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 as `u32`: ``` M0 = 0xFFFFFFFD, s_movrels_b32 s102, s47 → 47 + 0xFFFFFFFD = 0x10000002C ``` - Release build: the sum wrapped to 44, so the instruction ran and copied s44 (a wrong result reported as success, against rule 3). - Debug build: the addition panicked (`attempt to add with overflow`) instead of returning the interpreter's error. - Python model (`emu/rdna2_exec_movrel.py`): unbounded integers, index `0x10000002C`, refused as outside the model (`Untranslated`), which is what its docstring specifies. `check()` now takes the register and the offset separately and adds them in `u64` before 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 `_2` forms and `v_swaprel_b32` (10-bit fields of M0, cannot overflow) and `v_swap_b32` (no offset). `docs/rust-full-status.md` and `docs/fr/rust-full-status.md` record the finding. No README row or test-count change (1902 collected, still `1900+`). Linked issue: none. ## Verification Run on Linux (Ubuntu, Python 3.13, Rust 1.98.1), on top of `main` at `47759e8`, with `anyxboxx-rdna2-ref` and `anyxboxx-pe` built by `cargo build --release -p anyxboxx-rdna2-ref -p anyxboxx-pe`: ``` python -m pytest → 1453 passed, 449 skipped python -m pytest tests/test_rdna2_ref_parity.py → 41 passed python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools → All checks passed! cargo test -p anyxboxx-rdna2-ref → 136 passed; 0 failed cargo clippy -p anyxboxx-rdna2-ref --all-targets -- -D warnings → no warnings cargo fmt --check -p anyxboxx-rdna2-ref → clean ``` 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 printed `s 102 12345678`; debug panicked at `movrel.rs:134`. Both now print `error untranslated`. Not run (the 449 skipped tests): everything that needs Windows, the C++ runtime, `dxc` or a GPU, and the Rust crates that only build for Windows; `cargo test --workspace` for the same reason. No Windows machine was available. The change is plain integer arithmetic. No game was run. ## Oracle and test data - Oracle: the Python model, through `tests/test_rdna2_ref_parity.py`. - How it was found: the parity generator of that file, run on 6,000 more seeds with special values in the scalar registers. The 300 seeded programs set M0 below 256, so a large M0 only appears when an earlier random instruction writes s124. - Test data: built in the tests (no external data). - Failure case: `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 test `an_index_past_32_bits_is_refused_not_wrapped` pins the refusal. ## Checklist - [x] The PR covers a single reviewable behaviour. - [x] A test fails without this change and passes with it. - [x] The commands and results of each check are given above. - [x] An unimplemented function returns an error (`E_NOTIMPL`), never a fake success. - [x] README: the same change in the English and French READMEs (`test_readme_sync.py` checks it). No README change needed. - [x] No game, console or SDK file, no key, no dump, no download link. - [x] Findings drawn from a title: none in this PR. - [x] Code taken from another project: none in this PR. 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.com/claude-code)
chatgpt-codex-connector[bot] commented 2026-11-26 17:26:58 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T17:26:58Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T17:28:18.533446Z 1fe066a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7199035184 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/402#issuecomment-7199035184). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-26T17:26:58Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"1fe066aa3d339ccd8284052c4d7f579501e8ccbd","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-26T17:28:18.533446Z">2026-11-26T17:28:18.533446Z</relative-time> | `1fe066a` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
akimfomin commented 2026-11-26 23:21:03 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by akimfomin on 2026-11-26T23:21:03Z.


The movrel overflow regression catches the old arithmetic in an optimized Windows build. On b676bbc429aa3c98ab36b7d3b4907a6dd1935618 all three movrel tests passed in debug and release. In an isolated copy of the exact reference crate, I then restored wrapping only in check; 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.

<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7205467131 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/402#issuecomment-7205467131). Originally posted by [akimfomin](https://github.com/akimfomin) on 2026-11-26T23:21:03Z. --- The movrel overflow regression catches the old arithmetic in an optimized Windows build. On `b676bbc429aa3c98ab36b7d3b4907a6dd1935618` all three movrel tests passed in debug and release. In an isolated copy of the exact reference crate, I then restored wrapping only in `check`; the regression failed because the unsupported index returned success. [Pinned source and regression](https://github.com/LooperSalty/AnyXboxX/blob/b676bbc429aa3c98ab36b7d3b4907a6dd1935618/crates/anyxboxx-rdna2-ref/src/movrel.rs#L61-L76). 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](https://github.com/akimfomin/PortBridge) · AI-assisted test report.
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
LooperSalty/AnyXboxX!402
No description provided.