D3D12.X: a null ppv validation call does not crash console #14 (#2401) #2444

Open
github-bot wants to merge 1 commit from github-bot/gh-2444 into main AGit
Owner

@⁠GustavoEllwanger on GitHub · 2026-11-25 19:07 UTC · original
GustavoEllwanger:fix/d3d12x-descriptor-heap-null-ppv → main · +24 −2 · 2 files · 1 commits · open

CreateDescriptorHeap with a null out pointer is D3D12's validation call: no heap is made and it returns S_FALSE. The console #14 hook (dev_create_descriptor_heap_x) read *ppv on any success code, so that call crashed for CBV_SRV_UAV and SAMPLER heaps, the two types it sends through its own path. Fixes #2401.

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs: dev_create_descriptor_heap_x registers the heap only when ppv and *ppv are not null, as dev_create_descriptor_heap already does; the validation call returns the driver's S_FALSE.
  • crates/xcl/tests/d3d12_resource_and_sync.rs: console_descriptor_heap_validation_call_with_null_out_pointer_returns_s_false calls console #14 with a null out pointer for both heap types, shader-visible and not, and expects S_FALSE.

I also checked the other hr >= 0 then *ppv spots in hle/d3d12x: create_device returns early on a null ppv, finish_two_pass returns E_INVALIDARG for it (so the mesh and GS dred::label calls after it are not reached), and compute_container is covered by #2297.

Tested

  • AMD Ryzen 7 7700, Windows 11 build 26200.9974, Rust 1.95.0 MSVC, debug.
    • NVIDIA GeForce RTX 5060 (driver 32.0.16.1088), XCL_ADAPTER=5060
    • AMD Radeon RDNA2 iGPU (driver 32.0.21042.62), XCL_ADAPTER=Radeon
  • Fail-first, on main 3ceb550 with only the test added: cargo test -p xcl --test d3d12_resource_and_sync console_descriptor_heap_validation -- --test-threads=1 panics with null pointer dereference occurred at real.rs:1093 (let raw = *ppv) and the test binary aborts with 0xc0000409.
  • Rebased onto main 889ef3e; head e5e5528. On that head:
    • cargo test -p xcl --test d3d12_resource_and_sync -- --test-threads=1: 4 passed, 0 failed, 0 ignored on both GPUs.
    • cargo test --workspace --no-fail-fast -- --test-threads=4, with main 889ef3e run the same way for comparison:
      • RTX 5060: 1414 passed, 0 failed, 46 ignored, 29 SKIPPED lines (main: 1413 passed, 0 failed, 46 ignored).
      • RDNA2 iGPU: 1413 passed, 1 failed, 46 ignored, 18 SKIPPED lines (main: 1412 passed, 1 failed, 46 ignored). The failure is gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (seed 783), the same as on main, #2115.
      • The SKIPPED lines are wave64-only and per-lane gpu:: tests, plus heap_window_out_of_memory_falls_back_to_the_switch_form, shaders::tests::pso_measurement_compiles_an_exact_synthetic_record, the two the title under the debug layer runs and uploads_start_from_each_subresources_state (no debug layer or Developer Mode here), and on the iGPU passthrough_mesh_stream_accepts_a_triangle_driver_blob (no mesh shaders).

Regression run

  • Pending: I don't have a retail title package; this needs a paired scripts/smoke.ps1 run on main and on this head.

Not tested

  • A retail title run (see above). The title's normal calls pass a valid ppv, so this path only changes what happens on a validation call.
  • A release build.

AI use

  • Claude Code (Claude Opus 5.5): found which ppv sites in hle/d3d12x are reachable, wrote the fix and the test, ran the tests above and wrote this description.

🤖 Generated with Claude Code

**@⁠GustavoEllwanger** on GitHub · 2026-11-25 19:07 UTC · [original](https://github.com/xcl-dev/xcl/pull/2444) `GustavoEllwanger:fix/d3d12x-descriptor-heap-null-ppv` → `main` · +24 −2 · 2 files · 1 commits · open `CreateDescriptorHeap` with a null out pointer is D3D12's validation call: no heap is made and it returns `S_FALSE`. The console #14 hook (`dev_create_descriptor_heap_x`) read `*ppv` on any success code, so that call crashed for CBV_SRV_UAV and SAMPLER heaps, the two types it sends through its own path. Fixes #2401. **What is in it** - `crates/xcl/src/hle/d3d12x/real.rs`: `dev_create_descriptor_heap_x` registers the heap only when `ppv` and `*ppv` are not null, as `dev_create_descriptor_heap` already does; the validation call returns the driver's `S_FALSE`. - `crates/xcl/tests/d3d12_resource_and_sync.rs`: `console_descriptor_heap_validation_call_with_null_out_pointer_returns_s_false` calls console #14 with a null out pointer for both heap types, shader-visible and not, and expects `S_FALSE`. I also checked the other `hr >= 0` then `*ppv` spots in `hle/d3d12x`: `create_device` returns early on a null `ppv`, `finish_two_pass` returns `E_INVALIDARG` for it (so the mesh and GS `dred::label` calls after it are not reached), and `compute_container` is covered by #2297. **Tested** - AMD Ryzen 7 7700, Windows 11 build 26200.9974, Rust 1.95.0 MSVC, debug. - NVIDIA GeForce RTX 5060 (driver 32.0.16.1088), `XCL_ADAPTER=5060` - AMD Radeon RDNA2 iGPU (driver 32.0.21042.62), `XCL_ADAPTER=Radeon` - Fail-first, on `main` `3ceb550` with only the test added: `cargo test -p xcl --test d3d12_resource_and_sync console_descriptor_heap_validation -- --test-threads=1` panics with `null pointer dereference occurred` at `real.rs:1093` (`let raw = *ppv`) and the test binary aborts with `0xc0000409`. - Rebased onto `main` `889ef3e`; head `e5e5528`. On that head: - `cargo test -p xcl --test d3d12_resource_and_sync -- --test-threads=1`: 4 passed, 0 failed, 0 ignored on both GPUs. - `cargo test --workspace --no-fail-fast -- --test-threads=4`, with `main` `889ef3e` run the same way for comparison: - RTX 5060: 1414 passed, 0 failed, 46 ignored, 29 `SKIPPED` lines (`main`: 1413 passed, 0 failed, 46 ignored). - RDNA2 iGPU: 1413 passed, 1 failed, 46 ignored, 18 `SKIPPED` lines (`main`: 1412 passed, 1 failed, 46 ignored). The failure is `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1` (seed 783), the same as on `main`, #2115. - The `SKIPPED` lines are wave64-only and per-lane `gpu::` tests, plus `heap_window_out_of_memory_falls_back_to_the_switch_form`, `shaders::tests::pso_measurement_compiles_an_exact_synthetic_record`, the two `the title under the debug layer` runs and `uploads_start_from_each_subresources_state` (no debug layer or Developer Mode here), and on the iGPU `passthrough_mesh_stream_accepts_a_triangle_driver_blob` (no mesh shaders). **Regression run** - Pending: I don't have a retail title package; this needs a paired `scripts/smoke.ps1` run on `main` and on this head. **Not tested** - A retail title run (see above). The title's normal calls pass a valid `ppv`, so this path only changes what happens on a validation call. - A release build. **AI use** - Claude Code (Claude Opus 5.5): found which `ppv` sites in `hle/d3d12x` are reachable, wrote the fix and the test, ran the tests above and wrote this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
CreateDescriptorHeap with a null out pointer is D3D12's validation call:
no heap is made and it returns S_FALSE. dev_create_descriptor_heap_x read
*ppv on any success code, so the call crashed for CBV_SRV_UAV and SAMPLER
heaps. It now registers the heap only when ppv and *ppv are not null, as
dev_create_descriptor_heap already does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:31:08 +00:00
Author
Owner

@⁠ahmetbagci8 on GitHub · 2026-11-25 19:40 UTC · original

Tested

  • Commit: 55a476e3ab62fdcbfe79fcbb522c1de54e4eae6b
  • Hardware / OS: Intel Core i7-11800H, NVIDIA GeForce RTX 3070 Laptop GPU (driver 32.0.16.1714), Windows 11 Pro (Build 26300), DXC v1.9.2609
  • cargo test -j 2 -p xcl --lib d3d12x -- --test-threads=4: 245 passed; 0 failed; 2 ignored (7.92s)

Not tested

  • Full workspace suite and scripts/smoke.ps1 (no unpacked title locally).

AI use

  • Antigravity harness (Gemini 4 Neon) ran the targeted unit tests on this commit and drafted this report; the author reviewed it before posting.
**@⁠ahmetbagci8** on GitHub · 2026-11-25 19:40 UTC · [original](https://github.com/xcl-dev/xcl/pull/2444#issuecomment-7172609047) ### Tested - **Commit:** `55a476e3ab62fdcbfe79fcbb522c1de54e4eae6b` - **Hardware / OS:** Intel Core i7-11800H, NVIDIA GeForce RTX 3070 Laptop GPU (driver `32.0.16.1714`), Windows 11 Pro (Build 26300), DXC `v1.9.2609` - `cargo test -j 2 -p xcl --lib d3d12x -- --test-threads=4`: `245 passed; 0 failed; 2 ignored (7.92s)` ### Not tested - Full workspace suite and `scripts/smoke.ps1` (no unpacked title locally). ### AI use - Antigravity harness (Gemini 4 Neon) ran the targeted unit tests on this commit and drafted this report; the author reviewed it before posting.
Author
Owner

@⁠SlopTart on GitHub · 2026-11-25 20:02 UTC · original

gpu_ suite (cold cache): 160 passed / 4 failed, no crashes. The four are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, depth-buffer state refusal, and gpu_promoted_uav_clear_values_pass_create_committed_resource (report); none caused by this PR.

**@⁠SlopTart** on GitHub · 2026-11-25 20:02 UTC · [original](https://github.com/xcl-dev/xcl/pull/2444#issuecomment-7173109577) `gpu_` suite (cold cache): 160 passed / 4 failed, no crashes. The four are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, depth-buffer state refusal, and `gpu_promoted_uav_clear_values_pass_create_committed_resource` ([report](https://git.gtahub.st/github/xcl-dev--xcl/pulls/2280)); none caused by this PR.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 20:15 UTC · original

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

  • cargo test -p xcl --lib: 1 real failure, deterministic (also fails --test-threads=1, 1219/1):
gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier
  assertion failed: group barriers in the program (lower_dxil.rs:1155)

The lowered program is missing an expected group barrier (or emits one where none is expected). Needs a fix before merge.

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-25 20:15 UTC · [original](https://github.com/xcl-dev/xcl/pull/2444#issuecomment-7173416089) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: **1 real failure**, deterministic (also fails `--test-threads=1`, 1219/1): ``` gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier assertion failed: group barriers in the program (lower_dxil.rs:1155) ``` The lowered program is missing an expected group barrier (or emits one where none is expected). Needs a fix before merge. — Devin
Author
Owner

@⁠GustavoEllwanger on GitHub · 2026-11-25 20:18 UTC · original

Thanks @⁠DavidM1911 for running it!

That failure is not from this PR. a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier was broken on main itself after #2203 and was fixed by #2420, merged at 18:45 UTC. Your local main was probably from before that.

The current head e5e5528 is rebased onto main 889ef3e, which has #2420. There the test passes on an RTX 5060 and an AMD RDNA2 iGPU, the whole suite is main plus the one new test on both, and Build and test on this PR is green. This PR only changes dev_create_descriptor_heap_x in real.rs and adds one test in crates/xcl/tests/d3d12_resource_and_sync.rs, nothing in gpu::recomp.

If you rerun on e5e5528 after updating main, it should pass. The test for this fix itself is cargo test -p xcl --test d3d12_resource_and_sync.

**@⁠GustavoEllwanger** on GitHub · 2026-11-25 20:18 UTC · [original](https://github.com/xcl-dev/xcl/pull/2444#issuecomment-7173484440) Thanks @⁠DavidM1911 for running it! That failure is not from this PR. `a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier` was broken on `main` itself after #2203 and was fixed by #2420, merged at 18:45 UTC. Your local `main` was probably from before that. The current head `e5e5528` is rebased onto `main` `889ef3e`, which has #2420. There the test passes on an RTX 5060 and an AMD RDNA2 iGPU, the whole suite is `main` plus the one new test on both, and `Build and test` on this PR is green. This PR only changes `dev_create_descriptor_heap_x` in `real.rs` and adds one test in `crates/xcl/tests/d3d12_resource_and_sync.rs`, nothing in `gpu::recomp`. If you rerun on `e5e5528` after updating `main`, it should pass. The test for this fix itself is `cargo test -p xcl --test d3d12_resource_and_sync`.
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-25 23:00 UTC · original

RX 6800M verification on exact PR head e5e55281f2aad85a8116d2bbdffeaa4406ae68dc (Windows 11 build 26200, Radeon RX 6800M driver 30.0.13002.13003, Rust 1.99.0 MSVC):

  • Guarded XCL_ADAPTER=6800M XCL_REQUIRE_GPU=1 cargo test --locked -p xcl --test d3d12_resource_and_sync console_descriptor_heap_validation_call_with_null_out_pointer_returns_s_false -j 1 -- --test-threads=1 --show-output: 1 passed, 0 failed, 0 ignored, 0 SKIPPED (3 filtered out). The first cold build attempt stopped at the memory guard before testing; the retry above completed.
  • Guarded cargo build --locked --release -p xcl -j 1 passed on the PR head and its exact base e0d93c84ad8253f6e17738d14741c1bab7061127, with no guard stop. I preserved the PR executable before rebuilding the base and verified the copy's SHA-256 matched.
  • Matched 7-second owned-title smoke runs, separate fresh data/cache roots, both exit 0x0, 0 crashes and 0 device removals. Base: 13 frames, 6,954 MB peak commit. PR: 6 frames, 6,927 MB peak commit. This pair's PR frame count is 46% of base, below the 80% regression threshold; I would not call the smoke gate passed. These runs only reached intro frames and did not exercise the null-output validation call.
  • A 12-second PR run stopped at the memory guard (882 MB free commit) before completing, so it supplies no longer-run comparison. A separate 7-second current-main (6d12f58) run was also clean but showed 0 frames; short startup frame counts vary here. The PR's base predates four source-file changes on current main (core_tests.rs, lower_mem.rs, runner.rs, bind.rs), so the exact-base pair is the causal comparison, while a current-main pair after rebase is still needed for merge readiness.

Not tested: a full current-head workspace suite, a completed longer title run, a physical Bluetooth controller, or other GPUs on this exact head. No game data was uploaded.

AI use: OpenAI Codex (GPT-6; exact variant unavailable) ran the guarded exact-head test/builds and smoke comparisons, checked the logs and source delta, and drafted this report.

**@⁠luckyteagirl** on GitHub · 2026-11-25 23:00 UTC · [original](https://github.com/xcl-dev/xcl/pull/2444#issuecomment-7177030257) **RX 6800M verification on exact PR head `e5e55281f2aad85a8116d2bbdffeaa4406ae68dc`** (Windows 11 build 26200, Radeon RX 6800M driver `30.0.13002.13003`, Rust 1.99.0 MSVC): - Guarded `XCL_ADAPTER=6800M XCL_REQUIRE_GPU=1 cargo test --locked -p xcl --test d3d12_resource_and_sync console_descriptor_heap_validation_call_with_null_out_pointer_returns_s_false -j 1 -- --test-threads=1 --show-output`: **1 passed, 0 failed, 0 ignored, 0 SKIPPED** (3 filtered out). The first cold build attempt stopped at the memory guard before testing; the retry above completed. - Guarded `cargo build --locked --release -p xcl -j 1` passed on the PR head and its exact base `e0d93c84ad8253f6e17738d14741c1bab7061127`, with no guard stop. I preserved the PR executable before rebuilding the base and verified the copy's SHA-256 matched. - Matched 7-second owned-title smoke runs, separate fresh data/cache roots, both exit `0x0`, **0 crashes and 0 device removals**. Base: 13 frames, 6,954 MB peak commit. PR: 6 frames, 6,927 MB peak commit. This pair's PR frame count is **46%** of base, below the 80% regression threshold; I would not call the smoke gate passed. These runs only reached intro frames and did not exercise the null-output validation call. - A 12-second PR run stopped at the memory guard (882 MB free commit) before completing, so it supplies **no** longer-run comparison. A separate 7-second current-main (`6d12f58`) run was also clean but showed 0 frames; short startup frame counts vary here. The PR's base predates four source-file changes on current main (`core_tests.rs`, `lower_mem.rs`, `runner.rs`, `bind.rs`), so the exact-base pair is the causal comparison, while a current-main pair after rebase is still needed for merge readiness. **Not tested:** a full current-head workspace suite, a completed longer title run, a physical Bluetooth controller, or other GPUs on this exact head. No game data was uploaded. **AI use:** OpenAI Codex (GPT-6; exact variant unavailable) ran the guarded exact-head test/builds and smoke comparisons, checked the logs and source delta, and drafted this report.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 01:50 UTC · original

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

**@⁠DavidM1911** on GitHub · 2026-11-26 01:50 UTC · [original](https://github.com/xcl-dev/xcl/pull/2444#issuecomment-7180185073) 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
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2444/head:github-bot/gh-2444'
git switch 'github-bot/gh-2444'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2444'
git switch 'github-bot/gh-2444'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2444'
git switch 'github-bot/gh-2444'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2444'
git switch 'main'
git merge --squash 'github-bot/gh-2444'
git switch 'main'
git merge --ff-only 'github-bot/gh-2444'
git switch 'main'
git merge 'github-bot/gh-2444'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.