Skip to content

D3D12.X: a runtime-made resource inside a device creation call is not adopted - #2319

Merged
ivall merged 1 commit into
xcl-dev:mainfrom
oni-swr:d3d12x-dred-debug-layer-placed
Nov 25, 2026
Merged

ivall merged 1 commit into
xcl-dev:mainfrom
oni-swr:d3d12x-dred-debug-layer-placed

Conversation

@oni-swr

@oni-swr oni-swr commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

With XCL_DRED=1 and the D3D12 debug layer, D3D12Core makes a command list's auto-breadcrumb buffer inside CreateCommandList by calling the device's own public CreatePlacedResource. The device's vtable is XCL's, so that call reached the creator! hook, which adopted the half-made internal resource (a QueryInterface on it) and D3D12Core read a null pointer (0xC0000005 in D3D12Core.dll, test title, after the retail-format shader check). creator! now notes when it is already inside a call of its own on the thread and passes a nested call straight to the runtime. Fixes #2298.

Found by taking the stack at the crash: CreatePlacedResource (XCL's hook) sits under D3D12Core's CreateCommandList. Not the cause (tried and ruled out): DRED's own SetMarker / SetName calls in dred.rs, page-fault reporting (only auto-breadcrumbs matter), the command allocator's or pipeline's adoption. A plain D3D12 program with the same layer and DRED settings does not crash.

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs: a thread-local IN_CREATOR guard in the creator! macro.
  • crates/xcl/tests/e2e.rs: the debug-layer test body becomes title_under_the_debug_layer(dred); the old test calls it with false, the new test_title_runs_under_the_debug_layer_with_dred with true (sets XCL_DRED=1). The new test crashes without the real.rs change (checked) and passes with it.

Tested

  • AMD Radeon RX 7800 XT, Ryzen, Windows 11 Pro 26200, Rust stable-x86_64-pc-windows-msvc, debug (tests) / release (smoke)
  • XCL_DRED=1 cargo test -p xcl --test e2e test_title_draws_with_a_root_signature_under_the_debug_layer failed before the fix (same D3D12Core.dll+0x606fb null read as in the issue); the two debug-layer e2e tests pass after it
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on this commit: lib 1195 passed, 1 failed, 26 ignored; every other test target passed. The one failure, gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (seed 722, res[30] = 0x1, CPU 0x7fffffff), fails the same way on origin/main 06c9f55 on this GPU.
  • SKIPPED: f16_programs_on_the_gpu (f16 arithmetic and packed, wave32 and wave64) and f32_programs_on_the_gpu (f32 conversions, wave32 and wave64): refused V_MUL_F16 / V_PK_MUL_F16 / V_CVT_F16_F32 (gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426); heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows

Regression run

main (06c9f55):

xcl-smoke v1
commit: 06c9f5505f63f10c5ec49ef932d75b2c28177324
gpu: AMD Radeon RX 7800 XT
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1442 (PresentX 1442)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16916 MB

This PR (41dac1f):

xcl-smoke v1
commit: 41dac1f367c358b8964a524a78003a5c62aa9509
gpu: AMD Radeon RX 7800 XT
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1524 (PresentX 1524)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16919 MB

Same title, 60 s each.

Not tested

  • NVIDIA / Intel (the issue was seen on an RTX 3060)
  • a build with the Agility SDK loaded (this run used the inbox D3D12)
  • the debug layer with XCL_DRED=1 on a retail title: the smoke runs above are without the debug layer

AI use

  • Claude Code (Claude Sonnet 5.5) investigated the crash, wrote the change and the test, ran the commands above and wrote this description. I read the diff.

🤖 Generated with Claude Code

… adopted

With XCL_DRED=1 and the debug layer, D3D12Core makes a command list's
auto-breadcrumb buffer inside CreateCommandList by calling the device's own
public CreatePlacedResource. The device's vtable is XCL's, so that call reached
the `creator!` hook, which adopted the half-made internal resource (a
QueryInterface on it) and D3D12Core read a null pointer (0xC0000005 in
D3D12Core.dll, e2e test title, after the retail-format shader check).

`creator!` now notes when it is already inside a call of its own on the thread
and passes such a nested call straight to the runtime.

The new e2e test runs the test title under the debug layer with XCL_DRED=1; it
crashes without the change and passes with it.

Fixes xcl-dev#2298

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@nnonno91

Copy link
Copy Markdown

Independent debug-layer test-title check of 41dac1f367c358b8964a524a78003a5c62aa9509.

Tested

  • Ryzen 7 9800X3D, Windows 11 25H2 build 26200.9974, Rust 1.100.0 MSVC, unoptimized profiles. AMD Radeon(TM) Graphics driver 32.0.21042.62 and GeForce RTX 5090 driver 32.0.16.1742. Windows SDK DXC/DXIL 1.8.2502.11. System debug-layer and XGameRuntime DLLs present.
  • cargo build --locked --workspace passed. cargo test --locked -p xcl --test e2e under_the_debug_layer -- --nocapture --test-threads=1 with XCL_NETWORK=0 gave 2 passed, 0 failed and 0 ignored with each of XCL_ADAPTER=AMD Radeon and XCL_ADAPTER=NVIDIA GeForce RTX 5090. No skips. In each run the repository test title ran to completion with the debug layer enabled, both with and without DRED, and the test's log assertions passed.

Not tested

The old revision, retail gameplay and the full workspace suite.

AI use

OpenAI Codex (GPT-6.2 Sol) ran the checks, verified the logs and wrote this report.

@SlopTart

Copy link
Copy Markdown

Wine/vkd3d-proton lane check: clean on the suite, and the #2298 repro cannot fire on this lane.

Tested: head 41dac1f3 (already contains current origin/main, fast-forwards onto it), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).

One note for the fix itself: the pass-through for nested calls keys on "already inside one of its own calls on the thread". Under Wine the device vtable is also reached from vkd3d-proton's own threads via the same hooks; nothing observable broke in the suite, but the nested-call detection is thread state, not call state, if a title ever calls CreateCommandList from one thread while another thread is inside CreatePlacedResource. Counting by call nesting instead of thread entry might be the safer shape; this is a reading of the diff, not a measured failure.

Not tested: Windows with the Agility SDK debug layer (the actual #2298 crash path); retail titles (no title data on this lane, counts only).

AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.

@thehollowedone

Copy link
Copy Markdown

Independent full Windows suite on 41dac1f, based on 06c9f55. RTX 3080 Ti (621.35), Windows 11 build 26300, Rust 1.99.1 MSVC, DXC 1.8.2502.11, inbox D3D12.

  • Workspace build passed. Workspace tests reported 1,266 passed, 0 failed and 46 ignored. The pass count includes 26 reported skips (21 without wave64, 3 unsupported per-lane forms, 1 driver-cache toggle and 1 heap-window test).
  • Both stock debug-layer tests also passed in a separate serial run, with zero skips. The bundled test title ran to completion both with and without DRED, and the debug-layer log assertions passed.

Synthetic fixtures only. AI-assisted. Codex (GPT-6, exact variant unavailable) ran the tests and drafted this report.

@S1m0ne1997

Copy link
Copy Markdown

Test report for 41dac1f367c358b8964a524a78003a5c62aa9509 (this PR's head), for #1607.

Tested

  • NVIDIA GeForce RTX 4090 24 GB (driver 621.40), AMD Ryzen 9 9950X3D, 47 GB RAM, Windows 11 Home 10.0.26300, rustc 1.100.0 (0ef1bc386 2026-11-09) x86_64-pc-windows-msvc, debug.
  • cargo build --workspace, then cargo test --workspace -- --test-threads=4 at the head: 1266 passed, 0 failed, 46 ignored.
  • SKIPPED (18): dispatch_chain_native_wave64_builds_whole (no wave64), a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu (no wave64), coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu (no wave64), cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu (no wave64), the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu (no wave64), a_per_lane_2d_or_3d_group_runs_on_the_gpu (no wave64), const_and_null_mask_operands_agree_with_hlsl_on_the_gpu (const_mask, wave64: no wave64), f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's)); f16 arithmetic, wave64: no wave64), f32_programs_on_the_gpu (f32 arithmetic, wave64: no wave64; f32 compares, wave64: no wave64), f64_programs_on_the_gpu (f64, wave64: no wave64), integer_programs_on_the_gpu (integer arithmetic, wave64: no wave64; integer carries, wave64: no wave64), mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu (mask_ff0_flbit, wave64: no wave64), gpu_geometry_wave32_prefix_count_over_a_mask (no wave64), gpu_wave32_program_in_wave64_hardware (no wave64), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows), pso_measurement_compiles_an_exact_synthetic_record (cannot disable the driver cache (Windows Developer Mode is required): L'applicazione ha richiesto un'operazione che dipende da un componente SDK mancante o non corrispondente. (0x887A002D)), the title under the debug layer (dred (false): no d3d12SDKLayers.dll; true): no d3d12SDKLayers.dll), uploads_start_from_each_subresources_state (no D3D12 debug layer (L'applicazione ha richiesto un'operazione che dipende da un componente SDK mancante o non corrispondente. (0x887A002D))).

Regression run (retail title, scripts/smoke.ps1 -Seconds 60, release; main built from the commit in its block, this PR from its head with no changes to crates/, both run with the scripts/smoke.ps1 of main, which hashes the name of the game folder)

main:

xcl-smoke v1
commit: 06c9f5505f63f10c5ec49ef932d75b2c28177324
gpu: NVIDIA GeForce RTX 4090
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1599 (PresentX 1599)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16384 MB

this PR:

xcl-smoke v1
commit: 41dac1f367c358b8964a524a78003a5c62aa9509
gpu: NVIDIA GeForce RTX 4090
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1622 (PresentX 1622)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19202 MB

Not tested

  • AMD, other NVIDIA cards and drivers, Linux. I did not review the diff; this report is the build, the suite and the regression run only.

AI use: Claude Code with Claude Opus 5.5 ran the build, the suite and the regression run and wrote this report at my request.

@ivall

ivall commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Merged into main (68a284a).

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this on the maintainer's behalf.

@ivall
ivall merged commit 68a284a into xcl-dev:main Nov 25, 2026
2 checks passed
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.

e2e: XCL_DRED=1 with the debug layer crashes the test title in D3D12Core.dll (null read)

6 participants