Scripts: flag BVH shader loads past the root-argument table #1509

Open
GonZiin wants to merge 1 commit from upstream-pr/1519 into main
GonZiin commented 2026-11-24 17:11:53 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by GonZiin on 2026-11-24T17:11:53Z.


The BVH layout checker counted scalar loads as valid whenever their starting offset matched a root parameter, even if the load extended past the packed table. Check the full load width so these reads appear in the report.

What is in it

  • scripts/re/check_layout.py reports loads that extend past the root-argument table. The README documents the command.
  • scripts/test_check_layout_bounds.py exercises a synthetic root signature with three in-bounds loads and two overruns, using mocked disassembly.

Tested

  • Linux x86_64, Python 3.14.4, head a30bf7667794b4627881d2e6a5510a100ab77f62. python3 -B -m unittest discover -s scripts -p 'test_*.py': 17 passed, 0 failed, 0 skipped. Before the fix, the new test reported both overruns as in bounds.

  • git diff --cached --check passed before committing.

  • Windows 11 Pro build 26300, Ryzen 7 7800X3D, Radeon RX 9070 XT (driver 32.0.32029.2010), DXC 1.8.2502.11, Rust 1.100.0 (x86_64-pc-windows-msvc), debug. Exact head a30bf7667794b4627881d2e6a5510a100ab77f62.

  • .\scripts\test.ps1: workspace build passed and the suite reported 776 passed, 0 failed, 41 ignored. The bundled end-to-end title test passed. One runtime GPU skip inside the passing count: heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).

  • python -B -m unittest discover -s scripts -p 'test_*.py' on Windows (Python 3.13.15): 17 passed, 0 failed, 0 skipped.

  • python -B scripts/re/check_layout.py <synthetic-shader-dir> used the Windows xcl disasm executable and reported three in-bounds reads and two overruns.

Not tested

  • Extracted retail shaders and the opt-in XCL_SAMPLE_* tests. No sample paths were set.

AI use

  • Codex (gpt-6.2-sol) implemented the change and regression test, ran the Linux and Windows checks, and drafted this description.
<!-- greyfinch-sync:ivall/xcl:issue:5476855874 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1519). Originally posted by [GonZiin](https://github.com/GonZiin) on 2026-11-24T17:11:53Z. --- The BVH layout checker counted scalar loads as valid whenever their starting offset matched a root parameter, even if the load extended past the packed table. Check the full load width so these reads appear in the report. **What is in it** - `scripts/re/check_layout.py` reports loads that extend past the root-argument table. The README documents the command. - `scripts/test_check_layout_bounds.py` exercises a synthetic root signature with three in-bounds loads and two overruns, using mocked disassembly. **Tested** - Linux x86_64, Python 3.14.4, head `a30bf7667794b4627881d2e6a5510a100ab77f62`. `python3 -B -m unittest discover -s scripts -p 'test_*.py'`: 17 passed, 0 failed, 0 skipped. Before the fix, the new test reported both overruns as in bounds. - `git diff --cached --check` passed before committing. - Windows 11 Pro build 26300, Ryzen 7 7800X3D, Radeon RX 9070 XT (driver 32.0.32029.2010), DXC 1.8.2502.11, Rust 1.100.0 (`x86_64-pc-windows-msvc`), debug. Exact head `a30bf7667794b4627881d2e6a5510a100ab77f62`. - `.\scripts\test.ps1`: workspace build passed and the suite reported 776 passed, 0 failed, 41 ignored. The bundled end-to-end title test passed. One runtime GPU skip inside the passing count: `heap_window_out_of_memory_falls_back_to_the_switch_form` (`no heap windows`). - `python -B -m unittest discover -s scripts -p 'test_*.py'` on Windows (Python 3.13.15): 17 passed, 0 failed, 0 skipped. - `python -B scripts/re/check_layout.py <synthetic-shader-dir>` used the Windows `xcl disasm` executable and reported three in-bounds reads and two overruns. **Not tested** - Extracted retail shaders and the opt-in `XCL_SAMPLE_*` tests. No sample paths were set. **AI use** - Codex (`gpt-6.2-sol`) implemented the change and regression test, ran the Linux and Windows checks, and drafted this description.
DavidM1911 commented 2026-11-24 19:07:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T18:53:58Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7141307704 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1519#issuecomment-7141307704). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T18:53:58Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified `main`.) Thanks!
RavenCurseBurg commented 2026-11-26 04:07:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by RavenCurseBurg on 2026-11-26T03:27:36Z.


Tested a30bf7667794b4627881d2e6a5510a100ab77f62 with an independent synthetic 64-byte root table (an 8-byte descriptor followed by 14 dword constants). For each of five widths — 1, 2, 4, 8 and 16 dwords — I ran python -B scripts/re/check_layout.py <fixture-directory> with a disassembler stand-in. All five loads ending exactly at byte 64 passed. Moving each start four bytes later flagged all five. The 1-dword case started outside the table. The other four started at a recognized parameter offset but ended beyond the table. The author head printed those findings and returned 0, and its original bounds test passed.

On the earlier #1196/#1088 CLI integration, the four wider cases counted as successful loads. Candidate carrying this width check onto that CLI matched the author’s counts for all ten cases, returned 1 for each flagged load and 0 for each exact end. A separate child-error control still returned the disassembler’s exit code 23 and its diagnostic.

python -B -m unittest discover -s scripts -p "test_*.py" passed all 18 tests on the integrated candidate, with no failures or skips. Windows build 26100, i7-13700, Python 3.14.3. OpenAI Codex (GPT-6) ported the change, wrote the independent fixture and ran the tests. No real shader disassembly, GPU, game or Rust build.

<!-- greyfinch-sync:ivall/xcl:comment:7181737747 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1519#issuecomment-7181737747). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-26T03:27:36Z. --- Tested `a30bf7667794b4627881d2e6a5510a100ab77f62` with an independent synthetic 64-byte root table (an 8-byte descriptor followed by 14 dword constants). For each of five widths — 1, 2, 4, 8 and 16 dwords — I ran `python -B scripts/re/check_layout.py <fixture-directory>` with a disassembler stand-in. All five loads ending exactly at byte 64 passed. Moving each start four bytes later flagged all five. The 1-dword case started outside the table. The other four started at a recognized parameter offset but ended beyond the table. The author head printed those findings and returned 0, and its original bounds test passed. On the earlier #1196/#1088 CLI integration, the four wider cases counted as successful loads. [Candidate carrying this width check onto that CLI](https://github.com/RavenCurseBurg/xcl/commit/16caadf931afa2caa5072dc1376ef5bb6f851930) matched the author’s counts for all ten cases, returned 1 for each flagged load and 0 for each exact end. A separate child-error control still returned the disassembler’s exit code 23 and its diagnostic. `python -B -m unittest discover -s scripts -p "test_*.py"` passed all 18 tests on the integrated candidate, with no failures or skips. Windows build 26100, i7-13700, Python 3.14.3. OpenAI Codex (GPT-6) ported the change, wrote the independent fixture and ran the tests. No real shader disassembly, GPU, game or Rust build.
github-actions[bot] commented 2026-11-30 08:42:16 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-30T08:42:16Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7273238619 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1519#issuecomment-7273238619). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-30T08:42:16Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 05:59:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:59:26Z.


Triage (#1607) – head a30bf76

No open or merged PR makes the same change. #2668 edits the same script (scripts/re/check_layout.py) to find the right table pointer pair; the shared lines are only the test fixture boilerplate, and the two will conflict lightly.
The README addition describes an internal reverse-engineering script in the user-facing section; it is not needed for this fix.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7302354401 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1519#issuecomment-7302354401). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:59:26Z. --- **Triage (#1607)** – head a30bf76 No open or merged PR makes the same change. #2668 edits the same script (scripts/re/check_layout.py) to find the right table pointer pair; the shared lines are only the test fixture boilerplate, and the two will conflict lightly. The README addition describes an internal reverse-engineering script in the user-facing section; it is not needed for this fix. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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/1519:upstream-pr/1519'
git switch 'upstream-pr/1519'

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/1519'
git switch 'upstream-pr/1519'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1519'
git switch 'upstream-pr/1519'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1519'
git switch 'main'
git merge --squash 'upstream-pr/1519'
git switch 'main'
git merge --ff-only 'upstream-pr/1519'
git switch 'main'
git merge 'upstream-pr/1519'
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
xcl-dev/xcl!1509
No description provided.