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

Open
opened 2026-11-26 05:29:51 +00:00 by github-bot · 0 comments
Owner

@⁠ahmetbagci8 on GitHub · 2026-11-25 17:48 UTC · original

Summary

In crates/xcl/src/hle/d3d12x/real.rs (dev_create_descriptor_heap_x, lines 1089-1093):

let hr = dev_create_descriptor_heap(this, pc.as_ptr() as usize, riid, ppv);
if hr >= 0 {
    let raw = *ppv;
    let heap = ID3D12DescriptorHeap::from_raw_borrowed(&raw).unwrap();

In D3D12, calling ID3D12Device::CreateDescriptorHeap with ppvHeap == NULL is a documented parameter-validation call that succeeds with S_FALSE (1, which satisfies hr >= 0). While dev_create_descriptor_heap guards !ppv.is_null() && !(*ppv).is_null(), dev_create_descriptor_heap_x only checks hr >= 0 and immediately dereferences *ppv (NULL pointer dereference / access violation).

Suggested fix

if hr >= 0 && !ppv.is_null() && !(*ppv).is_null() {

Not tested

  • Read from commit 082944135cd2b96288470a595861fa608eee08dc without a new runtime test.

AI use

  • Antigravity harness (Gemini 4 Neon) audited real.rs and drafted this report; the author reviewed it before posting.
**@⁠ahmetbagci8** on GitHub · 2026-11-25 17:48 UTC · [original](https://github.com/xcl-dev/xcl/issues/2401) ### Summary In `crates/xcl/src/hle/d3d12x/real.rs` (`dev_create_descriptor_heap_x`, lines 1089-1093): ```rust let hr = dev_create_descriptor_heap(this, pc.as_ptr() as usize, riid, ppv); if hr >= 0 { let raw = *ppv; let heap = ID3D12DescriptorHeap::from_raw_borrowed(&raw).unwrap(); ``` In D3D12, calling `ID3D12Device::CreateDescriptorHeap` with `ppvHeap == NULL` is a documented parameter-validation call that succeeds with `S_FALSE` (`1`, which satisfies `hr >= 0`). While `dev_create_descriptor_heap` guards `!ppv.is_null() && !(*ppv).is_null()`, `dev_create_descriptor_heap_x` only checks `hr >= 0` and immediately dereferences `*ppv` (NULL pointer dereference / access violation). ### Suggested fix ```rust if hr >= 0 && !ppv.is_null() && !(*ppv).is_null() { ``` ### Not tested - Read from commit `082944135cd2b96288470a595861fa608eee08dc` without a new runtime test. ### AI use - Antigravity harness (Gemini 4 Neon) audited `real.rs` and drafted this report; the author reviewed it before posting.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:29:51 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.