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

Closed
github-bot wants to merge 1 commit from gh-pr/2556/head into gh-pr/2556/base
Owner

@⁠kotekompotek on GitHub · 2026-11-25 22:49 UTC · original
kotekompotek:fix/desc-heap-null-ppv → main · +70 −1 · 1 files · 1 commits · closed without merging

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.
**@⁠kotekompotek** on GitHub · 2026-11-25 22:49 UTC · [original](https://github.com/xcl-dev/xcl/pull/2556) `kotekompotek:fix/desc-heap-null-ppv` → `main` · +70 −1 · 1 files · 1 commits · closed without merging 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.
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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:33:43 +00:00
github-bot closed this pull request 2026-11-26 05:33:43 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 23:19 UTC · original

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

**@⁠DavidM1911** on GitHub · 2026-11-25 23:19 UTC · [original](https://github.com/xcl-dev/xcl/pull/2556#issuecomment-7177402702) 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
Author
Owner

@⁠xpatfussy69x on GitHub · 2026-11-26 00:02 UTC · original

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.
**@⁠xpatfussy69x** on GitHub · 2026-11-26 00:02 UTC · [original](https://github.com/xcl-dev/xcl/pull/2556#issuecomment-7178322115) 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.
Author
Owner

@⁠Prime1997 on GitHub · 2026-11-26 00:19 UTC · original

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 43d1ebb6 (this PR) and e5e55281 (#2444) against main 08db802. Reviewed with Claude Code (Claude Opus 5.5); I checked the comparison before closing.

**@⁠Prime1997** on GitHub · 2026-11-26 00:19 UTC · [original](https://github.com/xcl-dev/xcl/pull/2556#issuecomment-7178636601) 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 43d1ebb6 (this PR) and e5e55281 (#2444) against main 08db802. Reviewed with Claude Code (Claude Opus 5.5); I checked the comparison before closing.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.