D3D12.X: a root signature with a huge constant count gets no layout #1280

Merged
emirduran707 merged 1 commit from upstream-pr/1290 into main 2026-11-24 15:57:15 +00:00
emirduran707 commented 2026-11-24 14:20:55 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by emirduran707 on 2026-11-24T14:20:55Z.


layout_from_blob (console_list.rs) built a root signature's argument layout from the title's RTS0 blob and trusted Num32BitValues:

  • With 0x4000_0000 root constants, 4 * count overflows u32. Debug builds (and cargo test) panic; release builds wrap.
  • With 0x3FFF_FFFF the layout is 0xFFFF_FFFC bytes. Every Set*RootSignature on it then allocates that many zeroed bytes (bind.rs), and when commit runs out the allocation failure aborts the title.

It is reachable: when the PC refuses such a root signature, dev_create_root_signature substitutes an empty one but still records the title's own blob for the layout. Microsoft's root signature limits put the whole root signature at 64 DWORDs.

The byte count and the running size now use checked arithmetic, and a layout over MAX_ARGS (4096 bytes) is refused. A malformed blob gets no layout, the same as one that does not parse. 4096 bytes is 16 times the PC's limit: the console's own limit is not documented, so the cap only stops absurd sizes.

What is in it

  • crates/xcl/src/hle/d3d12x/console_list.rs:
    • the checks;
    • test a_huge_constant_count_has_no_layout. Counts 0x4000_0000 and 0x3FFF_FFFF, a root descriptor followed by 0xFFFF_FFFF constants, and a 4100-byte layout give no layout; a layout of exactly 4096 bytes still parses.

Tested

  • AMD Radeon RX 9060 XT (driver 32.0.31044.16), Ryzen 5 5600, Windows 11 Pro 26300, Rust 1.100.0; tests debug, smoke release
  • cargo test --workspace -- --test-threads=4 on 35665aa: 742 passed, 0 failed, 41 ignored; no SKIPPED GPU tests
  • the new test without the checks panics ("attempt to multiply with overflow" in layout_from_blob); with them cargo test -p xcl --lib hle::d3d12x::console_list passes, 5 passed

Regression run

main:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: AMD Radeon RX 9060 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1541 (PresentX 1541)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19650 MB

this PR:

xcl-smoke v1
commit: 35665aa634173a51aa8d3afecffb649c94873d98
gpu: AMD Radeon RX 9060 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1506 (PresentX 1506)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19736 MB

Not tested

  • The console's own root signature size limit: the 4096-byte cap is a sanity bound, not the console's number.
  • NVIDIA and Intel GPUs.

AI use

  • Claude Code with Claude Opus 5.5: found the problem, wrote the change, the test and this description; I reviewed the diff and ran the tests and smoke runs above.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:6583896211 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1290). Originally posted by [emirduran707](https://github.com/emirduran707) on 2026-11-24T14:20:55Z. --- `layout_from_blob` (console_list.rs) built a root signature's argument layout from the title's RTS0 blob and trusted `Num32BitValues`: - With 0x4000_0000 root constants, `4 * count` overflows u32. Debug builds (and `cargo test`) panic; release builds wrap. - With 0x3FFF_FFFF the layout is 0xFFFF_FFFC bytes. Every `Set*RootSignature` on it then allocates that many zeroed bytes (`bind.rs`), and when commit runs out the allocation failure aborts the title. It is reachable: when the PC refuses such a root signature, `dev_create_root_signature` substitutes an empty one but still records the title's own blob for the layout. Microsoft's root signature limits put the whole root signature at 64 DWORDs. The byte count and the running size now use checked arithmetic, and a layout over `MAX_ARGS` (4096 bytes) is refused. A malformed blob gets no layout, the same as one that does not parse. 4096 bytes is 16 times the PC's limit: the console's own limit is not documented, so the cap only stops absurd sizes. **What is in it** - `crates/xcl/src/hle/d3d12x/console_list.rs`: - the checks; - test `a_huge_constant_count_has_no_layout`. Counts 0x4000_0000 and 0x3FFF_FFFF, a root descriptor followed by 0xFFFF_FFFF constants, and a 4100-byte layout give no layout; a layout of exactly 4096 bytes still parses. **Tested** - AMD Radeon RX 9060 XT (driver 32.0.31044.16), Ryzen 5 5600, Windows 11 Pro 26300, Rust 1.100.0; tests debug, smoke release - `cargo test --workspace -- --test-threads=4` on 35665aa: 742 passed, 0 failed, 41 ignored; no SKIPPED GPU tests - the new test without the checks panics ("attempt to multiply with overflow" in `layout_from_blob`); with them `cargo test -p xcl --lib hle::d3d12x::console_list` passes, 5 passed **Regression run** main: ``` xcl-smoke v1 commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3 gpu: AMD Radeon RX 9060 XT title: retail-title seconds: 60 exit: 0x0 frames shown: 1541 (PresentX 1541) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 19650 MB ``` this PR: ``` xcl-smoke v1 commit: 35665aa634173a51aa8d3afecffb649c94873d98 gpu: AMD Radeon RX 9060 XT title: retail-title seconds: 60 exit: 0x0 frames shown: 1506 (PresentX 1506) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 19736 MB ``` **Not tested** - The console's own root signature size limit: the 4096-byte cap is a sanity bound, not the console's number. - NVIDIA and Intel GPUs. **AI use** - Claude Code with Claude Opus 5.5: found the problem, wrote the change, the test and this description; I reviewed the diff and ran the tests and smoke runs above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
DavidM1911 commented 2026-11-24 15:05:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T14:33:28Z.


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

  • cargo test -p xcl --lib lib console_list: 6 passed, 0 failed.

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7134570933 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1290#issuecomment-7134570933). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T14:33:28Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - cargo test -p xcl --lib lib console_list: 6 passed, 0 failed. Thanks!
futurepro62 commented 2026-11-24 15:06:00 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T14:38:46Z.


Full-suite run on NVIDIA and AMD to go with the subset check above. Tested exact head 35665aa (on its base 47efa2e).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 742 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: a_huge_constant_count_has_no_layout.
  • Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 742 passed, 0 failed, 41 ignored, no skips.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:ivall/xcl:comment:7134714843 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1290#issuecomment-7134714843). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T14:38:46Z. --- Full-suite run on NVIDIA and AMD to go with the subset check above. Tested exact head `35665aa` (on its base `47efa2e`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4`: **742 passed, 0 failed, 41 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - The new tests ran and passed: `a_huge_constant_count_has_no_layout`. - Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4`: **742 passed, 0 failed, 41 ignored**, no skips. **Not tested** - a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
upstream-sync closed this pull request 2026-11-24 16:06:09 +00:00
DavidM1911 commented 2026-11-24 16:07:25 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T16:01:57Z.


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

  • cargo test -p xcl --lib -- --test-threads=1: all passed, 0 failed, 21 ignored. (Parallel runs intermittently abort with 0xc0000005 — same harness flake seen on unmodified main.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7137009743 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1290#issuecomment-7137009743). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T16:01:57Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib -- --test-threads=1`: all passed, 0 failed, 21 ignored. (Parallel runs intermittently abort with 0xc0000005 — same harness flake seen on unmodified `main`.) Thanks!
DavidM1911 commented 2026-11-26 05:05:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T04:47:28Z.


Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

<!-- greyfinch-sync:ivall/xcl:comment:7182904992 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1290#issuecomment-7182904992). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T04:47:28Z. --- Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
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!1280
No description provided.