[PR #596] [CLOSED] rdna2spirv: restrict restore_skipped_instructions to reachable offsets and protect branch targets (OLD-10062) #639

Closed
opened 2026-11-26 20:18:33 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/596
Author: @jarvixaiassistant-glitch
Created: 11/24/2026
Status: ❌ Closed

Base: main ← Head: fix/old-10062-vcc-tuple-fallback


📝 Commits (1)

  • 57f5947 rdna2spirv: restrict restore_skipped_instructions to reachable offsets and protect branch targets

📊 Changes

2 files changed (+117 additions, -21 deletions)

View changed files

📝 tests/semantic/test_vcc_tuple_fallback.py (+64 -1)
📝 tools/rdna2spirv.py (+53 -20)

📄 Description

Claimed in the coordination issue as: OLD-10062

What and why

Carries forward old-pr/10062 (draft #327) onto main (d7576d56a), preserving tedin7's original commit verbatim per CONTRIBUTING.md and adding one focused hardening commit on top:

  1. Original commit (tedin7): restore_vcc_tuples() in tools/rdna2spirv.py recovers scalar-memory, image, and buffer instructions whose register tuple runs into vcc_lo/vcc_hi (SGPRs 106/107) using rdna2_decode when llvm-mc rejects the first dword and leaves the second dword as invalid/junk/normalized, plus synthetic semantic tests (tests/semantic/test_vcc_tuple_fallback.py) and the docs/shader_library.md update.
  2. Hardening commit (JARVIX): Clamps the rdna2_decode.decode_bytes slice in restore_vcc_tuples() to blob[at:min(at + 20, stop)] and checks at + nbytes <= stop. Previously, a 12-byte NSA1 image_load starting at code_end - 8 with trailing bytes past code_end was decoded across stop (pc=0, len=12 when code_end=8). Adds a synthetic regression test (test_nsa_mimg_with_vcc_tuple_does_not_read_past_code_end) verifying rejection when truncated at code_end=8 and restoration when complete at code_end=12.

Tested

All synthetic CPU/stdlib/docs/runtime-path checks on Windows 11 x64, Python 3.12.14, Node v24.19.0 (no game files):

  • python -I tests/semantic/test_vcc_tuple_fallback.py -v — 5/5 passed (reproduced the 12-byte NSA1 over-read failure before the hardening commit; 5/5 pass after)
  • python -I tests/test_runtime_paths.py — 5/5 passed
  • python -I tests/test_ci_registration.py — 15/15 passed
  • python -I scripts/check_no_game_data.py — passed (0 forbidden tracked extensions)
  • python -m compileall -q make_game.py tools tests — passed
  • python -I tests/test_text_write_line_endings.py, tests/test_report_paths.py, tests/test_i18n_index.py, and all tests/test_docs_*.py — passed
  • node --test tests/test_viewer_streaming.cjs — passed
  • Full shader corpus / spirv-val rerun: not run (no game files / LLVM / SPIRV-Tools on this host).

GPUs tested: n/a (CPU/semantic interpreter tests only)

AI-assisted: yes (JARVIX multi-model team: Antigravity + DeepSeek-V4-Pro + NVIDIA NIM Nemotron-3.5-Lightning & Nemotron-3-Ultra-550B)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (Reuses the existing VCCTuple [s100,...,vcc_lo,vcc_hi] contract documented in docs/design.md Scalar/buffer memory and docs/shader_library.md.)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/596 **Author:** [@jarvixaiassistant-glitch](https://github.com/jarvixaiassistant-glitch) **Created:** 11/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/old-10062-vcc-tuple-fallback` --- ### 📝 Commits (1) - [`57f5947`](https://github.com/ubiquitarianism/leonida/commit/57f59479beb09c6227be26072da4654ea2247a46) rdna2spirv: restrict restore_skipped_instructions to reachable offsets and protect branch targets ### 📊 Changes **2 files changed** (+117 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `tests/semantic/test_vcc_tuple_fallback.py` (+64 -1) 📝 `tools/rdna2spirv.py` (+53 -20) </details> ### 📄 Description Claimed in the coordination issue as: OLD-10062 ### What and why Carries forward `old-pr/10062` (draft #327) onto `main` (`d7576d56a`), preserving `tedin7`'s original commit verbatim per `CONTRIBUTING.md` and adding one focused hardening commit on top: 1. **Original commit (`tedin7`):** `restore_vcc_tuples()` in `tools/rdna2spirv.py` recovers scalar-memory, image, and buffer instructions whose register tuple runs into `vcc_lo`/`vcc_hi` (SGPRs 106/107) using `rdna2_decode` when `llvm-mc` rejects the first dword and leaves the second dword as invalid/junk/normalized, plus synthetic semantic tests (`tests/semantic/test_vcc_tuple_fallback.py`) and the `docs/shader_library.md` update. 2. **Hardening commit (`JARVIX`):** Clamps the `rdna2_decode.decode_bytes` slice in `restore_vcc_tuples()` to `blob[at:min(at + 20, stop)]` and checks `at + nbytes <= stop`. Previously, a 12-byte NSA1 `image_load` starting at `code_end - 8` with trailing bytes past `code_end` was decoded across `stop` (`pc=0, len=12` when `code_end=8`). Adds a synthetic regression test (`test_nsa_mimg_with_vcc_tuple_does_not_read_past_code_end`) verifying rejection when truncated at `code_end=8` and restoration when complete at `code_end=12`. ### Tested All synthetic CPU/stdlib/docs/runtime-path checks on Windows 11 x64, Python 3.12.14, Node v24.19.0 (no game files): - `python -I tests/semantic/test_vcc_tuple_fallback.py -v` — 5/5 passed (reproduced the 12-byte NSA1 over-read failure before the hardening commit; 5/5 pass after) - `python -I tests/test_runtime_paths.py` — 5/5 passed - `python -I tests/test_ci_registration.py` — 15/15 passed - `python -I scripts/check_no_game_data.py` — passed (0 forbidden tracked extensions) - `python -m compileall -q make_game.py tools tests` — passed - `python -I tests/test_text_write_line_endings.py`, `tests/test_report_paths.py`, `tests/test_i18n_index.py`, and all `tests/test_docs_*.py` — passed - `node --test tests/test_viewer_streaming.cjs` — passed - Full shader corpus / `spirv-val` rerun: not run (no game files / LLVM / SPIRV-Tools on this host). GPUs tested: n/a (CPU/semantic interpreter tests only) AI-assisted: yes (JARVIX multi-model team: Antigravity + DeepSeek-V4-Pro + NVIDIA NIM Nemotron-3.5-Lightning & Nemotron-3-Ultra-550B) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. *(Reuses the existing `VCCTuple` `[s100,...,vcc_lo,vcc_hi]` contract documented in `docs/design.md` *Scalar/buffer memory* and `docs/shader_library.md`.)* --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:18:33 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#639
No description provided.