Skip to content

Tests: a root constants write past the last parameter keeps the part that fits - #3511

Open
Pipodi wants to merge 1 commit into
xcl-dev:mainfrom
Pipodi:root-write-tests
Open

Pipodi wants to merge 1 commit into
xcl-dev:mainfrom
Pipodi:root-write-tests

Conversation

@Pipodi

@Pipodi Pipodi commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Tests for the case the retail title hits and #1319's own test does not: a root constants write that runs past the end of the last parameter, where it is also the end of the argument table. A retail title's BVH builder writes 4 dwords into compute parameter 3, the last of a 9-dword table (3 fit). Before the clip bind::put_in dropped the whole write, the radix pass read a null BVH header, and the refit's box stores corrupted the vertex and index lists. With the clip alone, in our diagnostic tree, the count of 24-byte corrupted runs in those lists went from 80 to 0, and the refit's loads of parents that were never written from 30.7M to 1 (test report on #1319). Part of #2867.

What is in it

  • Tests: a root constants write past the last parameter keeps the part that fits (crates/xcl/src/hle/d3d12x/bind.rs, mod tests, +72 lines, no runtime change):
    • 5 values into test_rts0_blob() leave 1, 2, 3, 4;
    • three root views + 3 constants, 4 values at parameter 3 write bytes 24-35 only and leave the views alone, for the compute and for the graphics arguments (two tests).
  • Not covered: the console-list replay arm in console_list.rs. Its table is a local of close() and is visible only through a translated dispatch (UMA + GPU), so a unit test would need a refactor; left out.

Tested

Regression run

  • Test-only diff in a runtime file; the smoke pair below is on our own GPU anyway (RTX 4090, driver 621.40, 60 s, same title, XCL_PREPARE=0).

main:

xcl-smoke v1
commit: 6bfb5c5153ccc23517daf30aa1071ddb0fadb53c
gpu: NVIDIA GeForce RTX 4090
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1611 (PresentX 1611)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 17826 MB

This PR's head:

xcl-smoke v1
commit: ecac034d692345fdf7e13c24103f9cb1239a95ba
gpu: NVIDIA GeForce RTX 4090
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1613 (PresentX 1613)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17736 MB

Not tested

  • The console-list replay arm (above); AMD / Intel.

AI use

  • Claude Code: Claude Opus 5.5 (diagnosis, plan, review) and Claude Sonnet 5.5 (code, tests)

@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) needs-rebase Has merge conflicts with its base branch labels Nov 30, 2026
@github-actions github-actions Bot added needs-pr-check Failing the PR description check (CONTRIBUTING.md) and removed needs-rebase Has merge conflicts with its base branch needs-pr-check Failing the PR description check (CONTRIBUTING.md) labels Nov 30, 2026
…that fits

A retail title's BVH builder writes 4 dwords into compute parameter 3, the
last parameter of a 9-dword table (3 fit). Before the clip, bind::put_in
dropped the whole write, so the radix pass read a null BVH header and the
refit's box stores corrupted vertex and index lists. With the clip alone
(r262) L24 went 80 -> 0 and de5c's bad parent loads 30.7M -> 1.

The clip's own test covers a write that overruns a mid-table parameter. These
cover the shape of that title: 5 values into a parameter of 4 keep 1..4, and
4 values at the last parameter of three views + 3 constants write bytes 24-35
and leave the views alone, for the compute and the graphics argument table.
All three fail with the put_in change reverted (zeros in the table).

The console-list replay arm has no test: its table is a local of close(),
visible only through a translated dispatch, so it needs a GPU title run.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Review (head ecac034, diff read, not a merge-check: PR description fails without the test-only label, so not built or run here):

  • No findings. I traced the three tests against main's put_in (bind.rs ~1461-1488, which already has D3D12.X: clamp root argument writes to the target parameter's size #1319's clip): 5 dwords into a 4-dword parameter keep 16 bytes; 4 dwords at parameter 3 (byte 24, 3 dwords) stop at byte 36, the end of the table; the root-descriptor setters store the VA unchanged, so the view asserts hold; and the addresses 0x7100_0F3x aren't used by any other test.
  • They test main's current behaviour, not D3D12.X: warn when a root argument write runs past its parameter #3512's (that one only adds a warning, so these pass with or without it, and the hunks don't overlap).
  • PR description is red because bind.rs counts as a runtime file; the diff is entirely inside mod tests, so it needs the test-only label from a maintainer.

Fine: test-only, drives the real set_*_root_constants / _descriptor -> put_in paths, covers the end-of-table case #1319's test doesn't, and the reverted-clip failures are reported.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head ecac034

No open or merged PR has these tests. #1319's out_of_bounds_root_constants_do_not_clobber_adjacent_parameter covers a clip in the middle of the table; these cover a write past the last parameter, at the end of the table, which main's pre-#1319 put_in dropped whole. #3512 adds a warning in put_in and is separate.
The root signature blob in three_views_and_three_constants lays out as the asserts expect (3 x 8-byte views + 3 constants = 36 bytes). No problems found in the diff.
Recommendation: keep open.

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

@fromthemoonx

fromthemoonx commented Dec 1, 2026 •

Copy link
Copy Markdown

merge-check
base: 6bfb5c5
head: ecac034
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2907 passed, 0 failed, 51 ignored (base: 2904 passed, 0 failed, 51 ignored); SKIPPED: 25 (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps), the same set as base; failing: none
review: read the whole diff (bind.rs, +72, all in mod tests; test-only). No findings.

  • The three new tests pass against main's put_in, which already has D3D12.X: clamp root argument writes to the target parameter's size #1319's clip (write_end = end.min(limit)).
  • Mutation: the clip taken out (write_end = end, so a write past the argument table is dropped, as before D3D12.X: clamp root argument writes to the target parameter's size #1319) fails all three:
    • a_write_past_the_last_parameter_keeps_the_part_that_fits
    • four_constants_at_the_last_of_three_views_and_three_constants_write_bytes_24_to_35
    • graphics_four_constants_at_the_last_of_three_views_and_three_constants_write_bytes_24_to_35
      Good: they cover the end-of-table case D3D12.X: clamp root argument writes to the target parameter's size #1319's own test does not.
  • hle::d3d12x::bind::tests:: at --test-threads=8, 30 runs: 20 of 30 ok on this merge, and also 20 of 30 on main 6bfb5c5. The failures are not this PR's tests: later_queue_completion_during_sleep_reclaims_before_wait_deadline (9 on the merge, 10 on main; bind.rs:10023, left: Stopped) and once wait_oldest_fenced_reclaims_in_flight_buffer_before_refusing on the merge.
  • bind.rs counts as a runtime file for pr_check.py, so it still needs the test-only label.
    performance: none: test code only.
    verdict: safe to merge
    hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300 / Claude Code (Claude Opus 5.5)

@github-actions github-actions Bot added needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) and removed needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU labels Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) needs:amd-test Needs a test report or merge-check on an AMD GPU needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants