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

Open
opened 2026-11-25 17:48:32 +00:00 by ahmetbagci8 · 0 comments
ahmetbagci8 commented 2026-11-25 17:48:32 +00:00 (Migrated from github.com)
Contributor

Imported from ivall/xcl. Originally posted by ahmetbagci8 on 2026-11-25T17:48:32Z.


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.
<!-- greyfinch-sync:ivall/xcl:issue:6610356622 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/2401). Originally posted by [ahmetbagci8](https://github.com/ahmetbagci8) on 2026-11-25T17:48:32Z. --- ### 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.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl#2391
No description provided.