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

Open
Pipodi wants to merge 1 commit from upstream-pr/3511 into main
Pipodi commented 2026-11-30 07:46:22 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Pipodi on 2026-11-30T07:46:22Z.


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

  • Head ecac034d, rebased onto main 9dfbe3ea (which has #1319).
  • RTX 4090, driver 621.40; i9-13900K; Windows 11 Pro 10.0.26300; rustc 1.100.0; debug.
  • Measured on the previous head 41615fe9 (same diff, main 07eec51e + #1319): the three new tests with #1319's put_in change in: 3 passed. With put_in reverted to main's body (temporary, not committed): 3 failed, all on the table staying zero:
    • a_write_past_the_last_parameter_keeps_the_part_that_fits: left [0; 16], right [1,0,0,0, 2,0,0,0, 3,0,0,0, 4,0,0,0]
    • four_constants_at_the_last_of_three_views_and_three_constants_write_bytes_24_to_35 (and the graphics_ one): left [0; 12], right [161,0,0,0, 162,0,0,0, 163,0,0,0]
  • On ecac034d (gpuq job 20261130-132119-e3f0), cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 2888 passed, 1 failed, 51 ignored in total (lib 2740 passed, 1 failed, 31 ignored). 25 SKIPPED lines.
    • The failure: gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, which also fails on bare main 9dfbe3ea (3 of 3 runs alone; fixed by #3513). two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs passed on this head; it fails on bare main 9dfbe3ea and on #3512's head (gpu_two_pass_cache_e2e.rs:472), so it is main's.
    • No 0xc0000409 abort in this run.

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)
<!-- greyfinch-sync:ivall/xcl:issue:5561167082 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3511). Originally posted by [Pipodi](https://github.com/Pipodi) on 2026-11-30T07:46:22Z. --- 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** - Head ecac034d, rebased onto main 9dfbe3ea (which has #1319). - RTX 4090, driver 621.40; i9-13900K; Windows 11 Pro 10.0.26300; rustc 1.100.0; debug. - Measured on the previous head 41615fe9 (same diff, main 07eec51e + #1319): the three new tests with #1319's `put_in` change in: 3 passed. With `put_in` reverted to main's body (temporary, not committed): 3 failed, all on the table staying zero: - `a_write_past_the_last_parameter_keeps_the_part_that_fits`: left `[0; 16]`, right `[1,0,0,0, 2,0,0,0, 3,0,0,0, 4,0,0,0]` - `four_constants_at_the_last_of_three_views_and_three_constants_write_bytes_24_to_35` (and the `graphics_` one): left `[0; 12]`, right `[161,0,0,0, 162,0,0,0, 163,0,0,0]` - On ecac034d (gpuq job 20261130-132119-e3f0), `cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4`: 2888 passed, 1 failed, 51 ignored in total (lib 2740 passed, 1 failed, 31 ignored). 25 `SKIPPED` lines. - The failure: `gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16`, which also fails on bare main 9dfbe3ea (3 of 3 runs alone; fixed by #3513). `two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs` passed on this head; it fails on bare main 9dfbe3ea and on #3512's head (`gpu_two_pass_cache_e2e.rs:472`), so it is main's. - No `0xc0000409` abort in this run. **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)
Foniass commented 2026-12-01 08:03:07 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:03:07Z.


Review (head ecac034d, 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 #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 #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.

<!-- greyfinch-sync:ivall/xcl:comment:7304810248 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3511#issuecomment-7304810248). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T08:03:07Z. --- Review (head ecac034d, 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 #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 #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 commented 2026-12-01 10:06:32 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T10:06:32Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7307680308 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3511#issuecomment-7307680308). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T10:06:32Z. --- **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 commented 2026-12-01 19:06:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-12-01T19:06:46Z.


merge-check
base: 6bfb5c5153
head: ecac034d69
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 #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 #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 #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)
<!-- greyfinch-sync:ivall/xcl:comment:7322196980 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3511#issuecomment-7322196980). Originally posted by [fromthemoonx](https://github.com/fromthemoonx) on 2026-12-01T19:06:46Z. --- merge-check base: 6bfb5c5153ccc23517daf30aa1071ddb0fadb53c head: ecac034d692345fdf7e13c24103f9cb1239a95ba 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 #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 #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 #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)
Decodere commented 2026-12-02 09:32:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Decodere on 2026-12-02T09:32:48Z.


merge-check
base: 1c8b551475
head: ecac034d69
merge: clean (trial-merge commit 989bd4858c4c101dc7f4fcff683f9d4bd2417697, git diff --check clean)
build: cargo build --workspace ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture (43 targets): 2912 passed, 0 failed, 51 ignored (+3 new tests vs main baseline). All 3 new hle::d3d12x::bind::tests passed with 0 skips (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). 28 SKIPPED lines (host environment only: 22 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 2 no heap windows, 1 cannot disable the driver cache (Windows Developer Mode required)).
review: Read the full merged diff (+72/-0 in crates/xcl/src/hle/d3d12x/bind.rs, test-only inside mod tests). Adds three unit tests locking in root-constant clamping when a write exceeds the final root parameter's dword count (5-into-4 on compute, and 4-into-3 after three 8-byte root views on both compute and graphics lists, checking bytes 0..24 preserve the views, bytes 24..36 keep the 3 fitting dwords, and the opposite list kind stays empty). Uses distinct synthetic list/root-signature addresses (0x7100_0F31..0F38) and cleans up via remove_state_for_test. No production code changed; no scope creep or UB.
performance: not applicable (Tier 0 — test-only diff in bind.rs, no production code changed).
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 4060 8 GB (driver 621.40), Intel Core i5-11400F, 32 GB RAM, Windows 11 Build 26200, Rust 1.100.1 MSVC, DXC 1.9.2602.17 / Antigravity (Gemini 4 Neon)

<!-- greyfinch-sync:ivall/xcl:comment:7341078591 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3511#issuecomment-7341078591). Originally posted by [Decodere](https://github.com/Decodere) on 2026-12-02T09:32:48Z. --- merge-check base: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f head: ecac034d692345fdf7e13c24103f9cb1239a95ba merge: clean (trial-merge commit 989bd4858c4c101dc7f4fcff683f9d4bd2417697, git diff --check clean) build: cargo build --workspace ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture (43 targets): 2912 passed, 0 failed, 51 ignored (+3 new tests vs main baseline). All 3 new hle::d3d12x::bind::tests passed with 0 skips (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). 28 SKIPPED lines (host environment only: 22 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 2 no heap windows, 1 cannot disable the driver cache (Windows Developer Mode required)). review: Read the full merged diff (+72/-0 in crates/xcl/src/hle/d3d12x/bind.rs, test-only inside mod tests). Adds three unit tests locking in root-constant clamping when a write exceeds the final root parameter's dword count (5-into-4 on compute, and 4-into-3 after three 8-byte root views on both compute and graphics lists, checking bytes 0..24 preserve the views, bytes 24..36 keep the 3 fitting dwords, and the opposite list kind stays empty). Uses distinct synthetic list/root-signature addresses (0x7100_0F31..0F38) and cleans up via remove_state_for_test. No production code changed; no scope creep or UB. performance: not applicable (Tier 0 — test-only diff in bind.rs, no production code changed). verdict: safe to merge hardware / tool and model: NVIDIA GeForce RTX 4060 8 GB (driver 621.40), Intel Core i5-11400F, 32 GB RAM, Windows 11 Build 26200, Rust 1.100.1 MSVC, DXC 1.9.2602.17 / Antigravity (Gemini 4 Neon)
bmjask commented 2026-12-02 14:12:25 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T14:12:25Z.


@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.

<!-- greyfinch-sync:ivall/xcl:comment:7348162210 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3511#issuecomment-7348162210). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T14:12:25Z. --- @Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.
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/3511:upstream-pr/3511'
git switch 'upstream-pr/3511'

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