Skip to content

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

Open
GonZiin wants to merge 1 commit into
xcl-dev:mainfrom
GonZiin:scripts/check-bvh-root-argument-bounds
Open

GonZiin wants to merge 1 commit into
xcl-dev:mainfrom
GonZiin:scripts/check-bvh-root-argument-bounds

Conversation

@GonZiin

@GonZiin GonZiin commented Nov 24, 2026 •

Copy link
Copy Markdown

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.

Check the full width of each scalar load so a valid starting offset cannot hide a read past the packed table. Exercise valid and oversized reads with a synthetic shader.

Assisted-by: Codex (gpt-6.2-sol)
@GonZiin
GonZiin marked this pull request as draft November 24, 2026 17:11
@GonZiin
GonZiin marked this pull request as ready for review November 24, 2026 17:13
@DavidM1911

Copy link
Copy Markdown
Contributor

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!

@throny throny added the off-goal Does not bear on the current goal (world loading); waits until it is reached label Nov 25, 2026
@RavenCurseBurg

RavenCurseBurg commented Nov 26, 2026 •

Copy link
Copy Markdown

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.

@github-actions

Copy link
Copy Markdown

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.

@github-actions github-actions Bot added the stale No activity for 3 days; closed 4 days later unless something happens label Nov 30, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

off-goal Does not bear on the current goal (world loading); waits until it is reached stale No activity for 3 days; closed 4 days later unless something happens

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants