D3D12.X: unresolved standin::Shell pointers leak into native MakeResident, Evict, StorePipeline, and PC CreateCommandList #2445

Open
opened 2026-11-25 19:30:13 +00:00 by microwave805 · 4 comments
microwave805 commented 2026-11-25 19:30:13 +00:00 (Migrated from github.com)
Contributor

Imported from ivall/xcl. Originally posted by microwave805 on 2026-11-25T19:30:13Z.


Static audit on main @ c7e1799 found that several D3D12 APIs accepting ID3D12PipelineState* / ID3D12Pageable* pass unresolved standin::Shell pointers directly into native D3D12Core.dll. Part of #1333, Part of #1833. (Note: open PR #2369 hardens standin::query_interface, but does not hook these device / pipeline-library entry points.)

Where

  • crates/xcl/src/hle/d3d12x/standin.rs:106 (Box::into_raw(Box::new(Shell { ... })))
  • crates/xcl/src/hle/d3d12x/real.rs:912-964, 2855-2920 (unhooked residency & pipeline-library vtable slots)
  • crates/xcl/src/hle/d3d12x/real.rs:3163 (dev_create_command_list PC vtable override)
  • crates/xcl/src/hle/d3d12x/real.rs:3651 (Kind::PipelineLibrary adoption)

Root cause

standin::shell() returns a Rust Box<Shell> (standin.rs:106), not a native D3D12Core.dll COM object. The following methods accept ID3D12PipelineState* (or its base ID3D12Pageable*) without resolving stand-ins:

  1. ID3D12Device::MakeResident (slot 34), Evict (slot 35), ID3D12Device1::SetResidencyPriority (slot 46), ID3D12Device3::EnqueueMakeResident (slot 51): unhooked in real.rs:2858-2886, so a title passing a stand-in PSO in the ppObjects array passes *mut Shell straight to D3D12Core.dll.
  2. ID3D12PipelineLibrary::StorePipeline: real.rs:3651 adopts Kind::PipelineLibrary with zero method overrides in real.rs:2855-2920, passing *mut Shell straight into D3D12Core.dll.
  3. PC ID3D12Device::CreateCommandList override (real.rs:3163): forwards a4 (pInitialState) unresolved (console slot 12 routes through device_x::create_command_list_pc, which does resolve, but direct PC-vtable calls do not).

Trigger

A title with XCL_LAZY_PSO=1 / async stand-ins passes a stand-in PSO pointer to MakeResident, Evict, SetResidencyPriority, EnqueueMakeResident, ID3D12PipelineLibrary::StorePipeline, or PC CreateCommandList(..., pInitialState, ...) → D3D12Core.dll casts *mut Shell to internal CPageable / CPipelineState → immediate access violation / heap corruption.

Fix direction

  • Hook MakeResident, Evict, SetResidencyPriority, and EnqueueMakeResident to replace any stand-in elements in ppObjects with their underlying driver pipeline (via standin::pipeline_of / pso_async::resolve_for_bind) in a temporary stack/vec copy before calling native D3D12.
  • Override ID3D12PipelineLibrary::StorePipeline to resolve (or reject/skip storing) stand-in PSOs rather than handing *mut Shell to D3D12Core.dll.
  • Resolve a4 (pInitialState) in dev_create_command_list (real.rs:3163).

AI use

  • Antigravity (Gemini 4 Neon): static code audit on main @ c7e1799 and issue drafting.
<!-- greyfinch-sync:ivall/xcl:issue:6612105232 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/2455). Originally posted by [microwave805](https://github.com/microwave805) on 2026-11-25T19:30:13Z. --- Static audit on `main @ c7e1799` found that several D3D12 APIs accepting `ID3D12PipelineState*` / `ID3D12Pageable*` pass unresolved `standin::Shell` pointers directly into native `D3D12Core.dll`. Part of #1333, Part of #1833. *(Note: open PR #2369 hardens `standin::query_interface`, but does not hook these device / pipeline-library entry points.)* ### Where - `crates/xcl/src/hle/d3d12x/standin.rs:106` (`Box::into_raw(Box::new(Shell { ... }))`) - `crates/xcl/src/hle/d3d12x/real.rs:912-964, 2855-2920` (unhooked residency & pipeline-library vtable slots) - `crates/xcl/src/hle/d3d12x/real.rs:3163` (`dev_create_command_list` PC vtable override) - `crates/xcl/src/hle/d3d12x/real.rs:3651` (`Kind::PipelineLibrary` adoption) ### Root cause `standin::shell()` returns a Rust `Box<Shell>` (`standin.rs:106`), not a native `D3D12Core.dll` COM object. The following methods accept `ID3D12PipelineState*` (or its base `ID3D12Pageable*`) without resolving stand-ins: 1. **`ID3D12Device::MakeResident` (slot 34), `Evict` (slot 35), `ID3D12Device1::SetResidencyPriority` (slot 46), `ID3D12Device3::EnqueueMakeResident` (slot 51):** unhooked in `real.rs:2858-2886`, so a title passing a stand-in PSO in the `ppObjects` array passes `*mut Shell` straight to `D3D12Core.dll`. 2. **`ID3D12PipelineLibrary::StorePipeline`:** `real.rs:3651` adopts `Kind::PipelineLibrary` with zero method overrides in `real.rs:2855-2920`, passing `*mut Shell` straight into `D3D12Core.dll`. 3. **PC `ID3D12Device::CreateCommandList` override (`real.rs:3163`):** forwards `a4` (`pInitialState`) unresolved (console slot 12 routes through `device_x::create_command_list_pc`, which does resolve, but direct PC-vtable calls do not). ### Trigger A title with `XCL_LAZY_PSO=1` / async stand-ins passes a stand-in PSO pointer to `MakeResident`, `Evict`, `SetResidencyPriority`, `EnqueueMakeResident`, `ID3D12PipelineLibrary::StorePipeline`, or PC `CreateCommandList(..., pInitialState, ...)` → `D3D12Core.dll` casts `*mut Shell` to internal `CPageable` / `CPipelineState` → immediate access violation / heap corruption. ### Fix direction - Hook `MakeResident`, `Evict`, `SetResidencyPriority`, and `EnqueueMakeResident` to replace any stand-in elements in `ppObjects` with their underlying driver pipeline (via `standin::pipeline_of` / `pso_async::resolve_for_bind`) in a temporary stack/vec copy before calling native D3D12. - Override `ID3D12PipelineLibrary::StorePipeline` to resolve (or reject/skip storing) stand-in PSOs rather than handing `*mut Shell` to `D3D12Core.dll`. - Resolve `a4` (`pInitialState`) in `dev_create_command_list` (`real.rs:3163`). ### AI use - Antigravity (Gemini 4 Neon): static code audit on `main @ c7e1799` and issue drafting.
oni-swr commented 2026-11-25 22:06:37 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ivall/xcl. Originally posted by oni-swr on 2026-11-25T21:10:25Z.


Claiming this issue: resolving standin::Shell pointers in MakeResident, Evict, SetResidencyPriority, EnqueueMakeResident, ID3D12PipelineLibrary::StorePipeline, and PC dev_create_command_list, with CPU unit tests.
AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7174709996 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/2455#issuecomment-7174709996). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-25T21:10:25Z. --- Claiming this issue: resolving `standin::Shell` pointers in `MakeResident`, `Evict`, `SetResidencyPriority`, `EnqueueMakeResident`, `ID3D12PipelineLibrary::StorePipeline`, and PC `dev_create_command_list`, with CPU unit tests. AI use: Claude Code (Claude Opus 5.5).
KOLESNiii commented 2026-11-26 02:08:17 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-26T01:10:30Z.


A related cache-facing entry point on main at b49be18. Verified: the shell’s own GetCachedBlob calls slot 8 on its shared dummy PSO. That call has no lookup of the asynchronously built PSO, so it still selects the dummy after the real one is ready. On compute the dummy contains dummy().cs. This differs from the native StorePipeline pointer path in the issue description. Shell method · Dummy compute descriptor · Normal resolution

If a title asks for and persists this blob, its cache can record dummy bytecode identity. A title-side size probe could likewise report a stand-in size. Title calls and driver behavior remain unobserved here. Logging the receiver and HRESULT before and after the build completes would establish which case matters.

AI use was OpenAI Codex (GPT-6, exact serving variant unavailable) for static review and drafting.

<!-- greyfinch-sync:ivall/xcl:comment:7179507737 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/2455#issuecomment-7179507737). Originally posted by [KOLESNiii](https://github.com/KOLESNiii) on 2026-11-26T01:10:30Z. --- A related cache-facing entry point on `main` at `b49be18`. **Verified:** the shell’s own `GetCachedBlob` calls slot 8 on its shared dummy PSO. That call has no lookup of the asynchronously built PSO, so it still selects the dummy after the real one is ready. On compute the dummy contains `dummy().cs`. This differs from the native `StorePipeline` pointer path in the issue description. [Shell method](https://github.com/xcl-dev/xcl/blob/b49be18/crates/xcl/src/hle/d3d12x/standin.rs#L225-L240) · [Dummy compute descriptor](https://github.com/xcl-dev/xcl/blob/b49be18/crates/xcl/src/hle/d3d12x/real.rs#L5530-L5535) · [Normal resolution](https://github.com/xcl-dev/xcl/blob/b49be18/crates/xcl/src/hle/d3d12x/pso_async.rs#L1049-L1065) If a title asks for and persists this blob, its cache can record dummy bytecode identity. A title-side size probe could likewise report a stand-in size. Title calls and driver behavior remain unobserved here. Logging the receiver and HRESULT before and after the build completes would establish which case matters. AI use was OpenAI Codex (GPT-6, exact serving variant unavailable) for static review and drafting.
oni-swr commented 2026-11-26 18:50:40 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ivall/xcl. Originally posted by oni-swr on 2026-11-26T18:50:40Z.


Following #2523 (MakeResident/Evict), taking the next focused PR from #2455: overriding ID3D12PipelineLibrary::StorePipeline so unresolved standin::Shell pointers never reach native D3D12Core.dll, with CPU unit tests.
Opening as a draft PR with CPU tests first; full GPU suite and paired smoke runs will follow once our RX 7800 XT slot is free. AI-assisted: Claude Code (Claude Sonnet 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7200914187 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/2455#issuecomment-7200914187). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-26T18:50:40Z. --- Following #2523 (MakeResident/Evict), taking the next focused PR from #2455: overriding ID3D12PipelineLibrary::StorePipeline so unresolved standin::Shell pointers never reach native D3D12Core.dll, with CPU unit tests. Opening as a draft PR with CPU tests first; full GPU suite and paired smoke runs will follow once our RX 7800 XT slot is free. AI-assisted: Claude Code (Claude Sonnet 5.5).
oni-swr commented 2026-11-26 19:30:39 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ivall/xcl. Originally posted by oni-swr on 2026-11-26T19:30:39Z.


Following #2523 (MakeResident/Evict) and #2853 (StorePipeline), taking the next focused PR from #2455: resolving standin::Shell pInitialState pointers in PC ID3D12Device::CreateCommandList (real.rs) with CPU unit tests.
Opening as a draft PR with CPU tests first (full GPU suite and paired smoke runs pending a free RX 7800 XT); AI use: Claude Code (Claude Sonnet 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7201668353 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/2455#issuecomment-7201668353). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-26T19:30:39Z. --- Following #2523 (MakeResident/Evict) and #2853 (StorePipeline), taking the next focused PR from #2455: resolving `standin::Shell` `pInitialState` pointers in PC `ID3D12Device::CreateCommandList` (`real.rs`) with CPU unit tests. Opening as a draft PR with CPU tests first (full GPU suite and paired smoke runs pending a free RX 7800 XT); AI use: Claude Code (Claude Sonnet 5.5).
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#2445
No description provided.