Skip to content

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

Open
GustavoEllwanger wants to merge 1 commit into
xcl-dev:mainfrom
GustavoEllwanger:fix/d3d12x-descriptor-heap-null-ppv
Open

GustavoEllwanger wants to merge 1 commit into
xcl-dev:mainfrom
GustavoEllwanger:fix/d3d12x-descriptor-heap-null-ppv

Conversation

@GustavoEllwanger

@GustavoEllwanger GustavoEllwanger commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

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 Olympus: emulate geometry wave64 on wave32 #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, DXIL fuzz tests: fuzz_validate_and_gpu_1 fails on AMD (seed 722 and others, RDNA2-4), so the default suite is red there #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

@ahmetbagci8

Copy link
Copy Markdown

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.

…xcl-dev#2401)

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 <noreply@anthropic.com>
@GustavoEllwanger
GustavoEllwanger force-pushed the fix/d3d12x-descriptor-heap-null-ppv branch from 55a476e to e5e5528 Compare November 25, 2026 19:54
@SlopTart

Copy link
Copy Markdown

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.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

@GustavoEllwanger

Copy link
Copy Markdown
Contributor Author

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.

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 25, 2026
…#2127, xcl-dev#2476, xcl-dev#2479, xcl-dev#2467, xcl-dev#2444, xcl-dev#2447, xcl-dev#2448

Integrates compositor RT tracking fix (xcl-dev#2480), split shader cache budget
(xcl-dev#2475), foreign-thread deferred release (xcl-dev#2474), Wine 4-thread DXC cap
(xcl-dev#2127), DXIL feature/reload fixes (xcl-dev#2476, xcl-dev#2479), DXC loader cleanup
(xcl-dev#2467), console xcl-dev#14 null ppv guard (xcl-dev#2444), root-sig flag stripping
(xcl-dev#2447), and two-pass stream canonicalization (xcl-dev#2448).

Assisted-by: Antigravity (Gemini 4 Neon)

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No code-level blocker found. The null-output guard matches the existing creator pattern, preserves S_FALSE, and the new tests cover both affected console heap types; Windows CI is green. Merge readiness is administrative: this runtime change still needs the required paired retail smoke evidence. Optional additional coverage: explicitly assert normal non-null creation still registers successfully.

@luckyteagirl

Copy link
Copy Markdown
Contributor

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.

@DavidM1911

Copy link
Copy Markdown
Contributor

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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

D3D12.X: dev_create_descriptor_heap_x dereferences NULL ppv on S_FALSE validation calls

6 participants