Skip to content

D3D12.X: pass a NULL-ppv CreateDescriptorHeap validation call through (#2401) - #2556

Closed
kotekompotek wants to merge 1 commit into
xcl-dev:mainfrom
kotekompotek:fix/desc-heap-null-ppv
Closed

kotekompotek wants to merge 1 commit into
xcl-dev:mainfrom
kotekompotek:fix/desc-heap-null-ppv

Conversation

@kotekompotek

Copy link
Copy Markdown

Fixes #2401.

In D3D12, ID3D12Device::CreateDescriptorHeap with ppvHeap == NULL is the documented parameter-validation call – the PC answers S_FALSE (1, which satisfies hr >= 0) and writes nothing. dev_create_descriptor_heap_x checked only hr >= 0 and then read *ppv to register the heap's console bookkeeping: a NULL ppv (or a *ppv the PC left NULL) is a null-pointer read the moment the call "succeeds".

What is in it

  • hle/d3d12x/real.rs: the heap-registration block now runs under hr >= 0 && !ppv.is_null() && !(*ppv).is_null() – the same guard the creator! macro and the other _x methods already apply. The HRESULT passes through untouched either way.
  • create_descriptor_heap_x_tests: a fake adopted device (CLASSES entry + ext vtable stub, as adopt() records them) whose PC-side CreateDescriptorHeap answers S_FALSE. Calling dev_create_descriptor_heap_x with ppv == NULL, and with an out pointer the PC left NULL, returns S_FALSE instead of dereferencing it; the test aborts on the null read when the guard is reverted (checked).

Tested

  • hardware (GPU + driver, CPU), Rust version, debug / release: NVIDIA GeForce GTX 1050 (driver supports up to SM 6.5, no mesh shaders), DXC 1.8.2502.11 (10.0.26100.0), rustc 1.98.1 stable-x86_64-pc-windows-msvc; debug tests, release smoke builds
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on the head commit: 1421 passed, 3 failed, 46 ignored (SKIPPED GPU tests: 355 – this adapter has no SM 6.6 / mesh shaders)
  • the three lib failures are environmental on this machine, unrelated to the change: gpu_retire_queue_holds_heap_until_blocked_queue_passes_mark (driver refuses a sparse heap op, HRESULT 0x80070057), stale_blob_cannot_bypass_the_offline_pipeline_cap and split_compute_program_prebuilds_and_caches_chain_pieces (both build/dispatch cs_6_6, which this SM 6.5 adapter cannot run; the latter is a new upstream test with no capability gate)
  • a_null_ppv_validation_call_passes_the_pc_answer_through aborts with a null-pointer dereference when the fix is reverted (checked by restoring if hr >= 0)

Regression run

main:

xcl-smoke v1
commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea
gpu: NVIDIA GeForce GTX 1050
title: gta6
seconds: 0
exit: 0x0
frames shown: 0 (PresentX 0)
presents per 2 s (last 3): 
device removals: 0
crashes: 0
peak commit: n/a MB

PR:

xcl-smoke v1
commit: 43d1ebb64ccbcb4c5235c7f13089d9de2af04ad6
gpu: NVIDIA GeForce GTX 1050
title: gta6
seconds: 0
exit: 0x0
frames shown: 0 (PresentX 0)
presents per 2 s (last 3): 
device removals: 0
crashes: 0
peak commit: n/a MB

Not tested

  • The only available title cannot reach its own code on this adapter: ~2 s into its init it raises a breakpoint the same way on main and on this PR (with -Seconds 1-8 the log shows unhandled exception 0x80000003 then process ends with status 0x80000003). The blocks above end it through XCL_RUN_SECONDS=0 before that point – they cover host boot, game loading and shutdown, no frames, no shaders.
  • A title that actually calls CreateDescriptorHeap with ppv == NULL through the console interface: the validation call is exercised by the unit test's fake device, not observed from a real game.

AI use

  • Devin (SWE-2 High): verified the issue against the code, the one-line guard, the regression test with the fake adopted device, the revert-check, the test suite, both smoke runs and this PR.

…xcl-dev#2401)

dev_create_descriptor_heap_x read *ppv the moment hr >= 0, but a title may
call CreateDescriptorHeap with ppv == NULL as the D3D12 validation call –
the PC answers S_FALSE and writes nothing – or hand back a NULL *ppv.
Dereferencing either is a null read. Gate the console bookkeeping on
!ppv.is_null() && !(*ppv).is_null(), the same guard the creator! macro and
the other _x methods already use.
@DavidM1911

Copy link
Copy Markdown
Contributor

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

  • cargo test -p xcl --lib: all passed, 0 failed, 26 ignored.

Thanks!

— Devin

@xpatfussy69x

Copy link
Copy Markdown

Test run on exact head 43d1ebb (43d1ebb64ccbcb4c5235c7f13089d9de2af04ad6, on its base 6d12f58), clean tree.

Tested

  • NVIDIA GeForce RTX 3060 12 GB (driver 32.0.16.2124, 32-lane waves only), AMD Ryzen 5 7500F, Windows 11, Rust 1.100.0; debug build for the tests, release for the smoke runs
  • cargo test --workspace -- --test-threads=4: 1424 passed, 0 failed, 46 ignored
  • SKIPPED (25): 21 × no wave64; 1 × no heap windows; 3 × per-lane form refused V_MUL_F16 / V_PK_MUL_F16 / V_CVT_F16_F32 (on main too)
  • cargo test -p xcl --lib a_null_ppv_validation_call: 1 passed, 0 failed
  • This PR's new tests in the workspace run:
    • a_null_ppv_validation_call_passes_the_pc_answer_through: ok

Regression run (60 s, default settings, a retail title)

main:

xcl-smoke v1
commit: 08db8020d323bf478964fcc586152cce54959cfc
gpu: NVIDIA GeForce RTX 3060
title: c3f791f3
seconds: 60
exit: 0x0
frames shown: 1571 (PresentX 1571)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14042 MB

this PR:

xcl-smoke v1
commit: 43d1ebb64ccbcb4c5235c7f13089d9de2af04ad6
gpu: NVIDIA GeForce RTX 3060
title: c3f791f3
seconds: 60
exit: 0x0
frames shown: 1650 (PresentX 1650)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14086 MB

No crash or device removal; frames 105 % of main's, peak commit 100 %. The main run is on current main (08db802), newer than this PR's base.

Not tested

  • Whether the title makes a NULL-ppv CreateDescriptorHeap call in this run: a regression check only
  • The PR merged into current main (tested on its own base; it merges into 08db802 without conflicts)
  • AMD / native wave64

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and both smoke runs on the machine above and wrote this report.

@Prime1997

Copy link
Copy Markdown
Collaborator

Closing as a duplicate of #2444, which was opened earlier for the same issue (#2401). Both make the same change in dev_create_descriptor_heap_x: the registration guard becomes hr >= 0 && !ppv.is_null() && !(*ppv).is_null(), so the null-ppv validation call returns S_FALSE without reading *ppv. Only the tests differ. The unit test for an out pointer left NULL could be offered on #2444 if wanted.

Compared at heads 43d1ebb (this PR) and e5e5528 (#2444) against main 08db802. Reviewed with Claude Code (Claude Opus 5.5); I checked the comparison before closing.

@Prime1997 Prime1997 closed this Nov 26, 2026
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 26, 2026
…ixes

Integrates upstream amd-dev 61121fe/xcl-dev#2569 (DirectStorage ordered completion
wakeups) plus open PRs xcl-dev#2577 (skip AMD cache-reference driver blobs on disk,
xcl-dev#2512), xcl-dev#2578 (clear LAST_CONTENT on placed texture unmap/remap, xcl-dev#2460),
xcl-dev#2579 (mark put-off builds wanted immediately), xcl-dev#2556 (NULL-ppv
CreateDescriptorHeap test), xcl-dev#2550 (skipped ExecuteIndirect occlusion query),
xcl-dev#2549 (reused spare keeps in-flight deferred allocator, with Wine raw fences
and UnadoptGuard), and xcl-dev#2548 (Reset/KickoffX/CreateCommandList do not wait on
building compute pipelines).

Assisted-by: Antigravity (Gemini 4 Neon)
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

4 participants