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; then verifies that normal non-null creation for the same combinations still returns S_OK, registers in console_heap, and unregisters on drop.

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, Rust 1.95.0 MSVC, DXC 1.8.2502.11, 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 panicked with null pointer dereference occurred at real.rs:1093 (let raw = *ppv) and aborted with 0xc0000409.
  • Rebased onto main b49be183; head 5681f9fa:
    • cargo test -p xcl --test d3d12_resource_and_sync --test d3d12_descriptor_heap_and_fence -- --test-threads=1: d3d12_resource_and_sync 4 passed, d3d12_descriptor_heap_and_fence 3 passed (0 failed, 0 ignored, 0 skipped) on both RTX 5060 and AMD Radeon RDNA2.
    • XCL_ADAPTER=5060 cargo test --workspace -- --test-threads=4 (NVIDIA RTX 5060): 1436 passed, 0 failed, 47 ignored (29 pre-existing runtime SKIPPED lines on wave32 NVIDIA / without D3D12 debug layer / Developer Mode / heap windows).

Regression run

  • Pending: I don't have a retail title package; this needs paired scripts/smoke.ps1 blocks on main (b49be183) and on this head (5681f9fa).

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): initial investigation, fix, and test.
  • Antigravity (Google Gemini): rebased onto b49be183, added the non-null registration/unregistration assertions per @bmjask's review, and ran the dual-GPU and workspace test suites.

@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.

@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

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
…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 e5e5528 to 5681f9f Compare November 26, 2026 12:32
@GustavoEllwanger

Copy link
Copy Markdown
Contributor Author

Thanks @bmjask for the review and @luckyteagirl for the RX 6800M check! Rebased onto current \main\ (\�49be183, new head \5681f9fa) and added explicit non-null console #14 creation assertions in \console_descriptor_heap_validation_call_with_null_out_pointer_returns_s_false\ verifying \S_OK, \console_heap::start(...)\ registration (when UMA is active), and clean unregistration on drop for both \CBV_SRV_UAV\ and \SAMPLER\ heaps (shader-visible and non-shader-visible).

Re-verified on NVIDIA RTX 5060 and AMD Radeon RDNA2 (4/4 \d3d12_resource_and_sync, 3/3 \d3d12_descriptor_heap_and_fence, 1436 passed, 0 failed, 47 ignored full workspace on RTX 5060). If anyone with a retail title can run a paired 60 s \scripts/smoke.ps1\ on \�49be183\ and \5681f9fa, it would be greatly appreciated!

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