D3D12.X: a pipeline stream cut inside a subobject payload is not rewritten #1279

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

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


Two walkers of a title's pipeline state stream (D3D12_PIPELINE_STATE_STREAM_DESC) checked that a subobject's 8-byte header fits in SizeInBytes, but not that its payload does:

  • fallback_stream (real.rs) rewrites a stream the PC driver refused. It writes into a buffer of exactly SizeInBytes bytes. For a stream cut inside its last subobject's payload, it panicked with a range error inside an extern "system" function, which aborts the title. Example: 16 bytes, a VS subobject with 8 of its 16-byte D3D12_SHADER_BYTECODE.
  • capture_stream_desc (null.rs) read the 16 bytes of shader bytecode at the cut payload without checking them, an access violation when the stream ends at a page the process may not read.

The sibling walkers stream_subobjects and known_subobjects already bound the payload, and fallback_stream is documented to return None when it cannot rewrite. Both now stop at a payload that runs past the end: fallback_stream returns None, so the title gets the driver's error, and capture_stream_desc stops the walk.

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs:
    • the payload bound in fallback_stream;
    • test fallback_stream_tests::a_stream_ending_inside_a_payload_is_not_rewritten, which compiles its stand-in shaders with D3DCompile and uses no device. A cut stream gives None; a whole one is rewritten as before.
  • crates/xcl/src/hle/d3d12x/null.rs:
    • the bound in capture_stream_desc;
    • test a_stream_ending_inside_a_shader_payload_is_not_read_past_its_end, with a stream that ends at a page the process may not read.

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 365d7c8: 743 passed, 0 failed, 41 ignored; no SKIPPED GPU tests
  • without the bounds: the real.rs test panics at the buf[at..at + 16] copy ("range end index 24 out of range for slice of length 16"); the null.rs test ends the test process with STATUS_ACCESS_VIOLATION; with them both pass

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: 365d7c80401ccf90be83a1fedad4c1f350ab0121
gpu: AMD Radeon RX 9060 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1494 (PresentX 1494)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19727 MB

Not tested

  • What the PC runtime itself does with such a truncated stream; the panic needs the driver to refuse it first.
  • own_stream (real.rs) indexes payloads the same way, but only after stream_subobjects has checked the stream; left as it is.
  • NVIDIA and Intel GPUs.

AI use

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:6583894196 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1289). Originally posted by [emirduran707](https://github.com/emirduran707) on 2026-11-24T14:20:49Z. --- Two walkers of a title's pipeline state stream (`D3D12_PIPELINE_STATE_STREAM_DESC`) checked that a subobject's 8-byte header fits in `SizeInBytes`, but not that its payload does: - `fallback_stream` (real.rs) rewrites a stream the PC driver refused. It writes into a buffer of exactly `SizeInBytes` bytes. For a stream cut inside its last subobject's payload, it panicked with a range error inside an `extern "system"` function, which aborts the title. Example: 16 bytes, a VS subobject with 8 of its 16-byte `D3D12_SHADER_BYTECODE`. - `capture_stream_desc` (null.rs) read the 16 bytes of shader bytecode at the cut payload without checking them, an access violation when the stream ends at a page the process may not read. The sibling walkers `stream_subobjects` and `known_subobjects` already bound the payload, and `fallback_stream` is documented to return None when it cannot rewrite. Both now stop at a payload that runs past the end: `fallback_stream` returns None, so the title gets the driver's error, and `capture_stream_desc` stops the walk. **What is in it** - `crates/xcl/src/hle/d3d12x/real.rs`: - the payload bound in `fallback_stream`; - test `fallback_stream_tests::a_stream_ending_inside_a_payload_is_not_rewritten`, which compiles its stand-in shaders with D3DCompile and uses no device. A cut stream gives None; a whole one is rewritten as before. - `crates/xcl/src/hle/d3d12x/null.rs`: - the bound in `capture_stream_desc`; - test `a_stream_ending_inside_a_shader_payload_is_not_read_past_its_end`, with a stream that ends at a page the process may not read. **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 365d7c8: 743 passed, 0 failed, 41 ignored; no SKIPPED GPU tests - without the bounds: the real.rs test panics at the `buf[at..at + 16]` copy ("range end index 24 out of range for slice of length 16"); the null.rs test ends the test process with `STATUS_ACCESS_VIOLATION`; with them both pass **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: 365d7c80401ccf90be83a1fedad4c1f350ab0121 gpu: AMD Radeon RX 9060 XT title: retail-title seconds: 60 exit: 0x0 frames shown: 1494 (PresentX 1494) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 19727 MB ``` **Not tested** - What the PC runtime itself does with such a truncated stream; the panic needs the driver to refuse it first. - `own_stream` (real.rs) indexes payloads the same way, but only after `stream_subobjects` has checked the stream; left as it is. - NVIDIA and Intel GPUs. **AI use** - Claude Code with Claude Opus 5.5: found the problem, wrote the change, the tests 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:55 +00:00 (Migrated from github.com)

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


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

  • cargo test -p xcl --lib new stream-cut tests: 2 passed, 0 failed.

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7134569247 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1289#issuecomment-7134569247). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T14:33:24Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - cargo test -p xcl --lib new stream-cut tests: 2 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:31Z.


Full-suite run on NVIDIA and AMD to go with the subset check above. Tested exact head 365d7c8 (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: 743 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_stream_ending_inside_a_shader_payload_is_not_read_past_its_end, a_stream_ending_inside_a_payload_is_not_rewritten.
  • Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 743 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:7134708101 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1289#issuecomment-7134708101). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T14:38:31Z. --- Full-suite run on NVIDIA and AMD to go with the subset check above. Tested exact head `365d7c8` (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`: **743 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_stream_ending_inside_a_shader_payload_is_not_read_past_its_end`, `a_stream_ending_inside_a_payload_is_not_rewritten`. - Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4`: **743 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:27 +00:00 (Migrated from github.com)

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


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.

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7137072724 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1289#issuecomment-7137072724). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T16:04:21Z. --- 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. Thanks!
DavidM1911 commented 2026-11-26 05:05:36 +00:00 (Migrated from github.com)

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


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:7182809719 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1289#issuecomment-7182809719). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T04:40:58Z. --- 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!1279
No description provided.