D3D12.X: read back the swap chain buffer for the frame dump and guard readback_copy #2703

Open
itsSio wants to merge 1 commit from upstream-pr/2713 into main
itsSio commented 2026-11-26 08:05:49 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by itsSio on 2026-11-26T08:05:49Z.


With XCL_FRAME_DUMP set and no composited present, the frame dump read back the title's own src with a texture copy recorded at present time. XCL does not know which state the title keeps src in, and readback_copy recorded the copy for any resource, buffers included. The dump now reads back the swap chain buffer XCL has just copied into (COPY_DEST -> COPY_SOURCE -> PRESENT), as the composited path already does from RENDER_TARGET, and readback_copy refuses what it cannot copy to a buffer: anything other than a single-sample 2D texture with a size and a footprint format, or a failed GetCopyableFootprints. Part of #499 (observation 2).

What is in it

  • D3D12.X: read back the swap chain buffer for the frame dump and guard readback_copy (6d29dc26): crates/xcl/src/hle/d3d12x/present.rs (dump_backbuffer used by both present paths; readback_possible checked in readback_copy; a unit test of the checks and a GPU test on WARP that dumps a filled swap chain buffer and refuses a buffer, using ManuallyDrop::new(Some(bb.clone())) / up.clone() to avoid a COM double-Release on test teardown)

Tested
Commit 6d29dc265b2a2cd5508b31b0da53c4ecb8e9566b, clean checkouts on each PC, debug builds for workspace tests and release builds for --release present:: checks and retail smoke runs.

  • PC 1: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro build 26200, Rust 1.97.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5 (XCL_ADAPTER=NVIDIA).
    • cargo test --release -p xcl --lib hle::d3d12x::present:: -- --test-threads=1 (×3) and -- --test-threads=4 (×3): 11 passed, 0 failed on all 6 runs (exit 0).
    • cargo build --workspace: exit 0.
    • cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1431 passed, 0 failed, 47 ignored.
    • 26 SKIPPED GPU tests: wave64 tests (no wave64 on this adapter), f16 / f16-conversion wave32 refusals (#1426), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows), pso_measurement_compiles_an_exact_synthetic_record (driver cache, Developer Mode).
    • Earlier 120 s XCL_FRAME_DUMP=1 + XCL_PRESS_A_AT=15,25,35,45,55 check (release, RTX 5080, on identical runtime code b25ae0cf vs main 08db8020): both captured genuine non-black BMPs (max=249, mean=36.6, 99.8% non-dark; 3258 vs 3306 frames) with 0 crashes, 0 device removals, and 0 nvwgf2umx.dll faults.
  • PC 2: NVIDIA GeForce RTX 2080 SUPER (driver 32.0.16.1088), AMD Ryzen 5 5600X, 16 GB RAM, Windows 11 Pro build 26200, Rust 1.99.1 (stable-x86_64-pc-windows-msvc), Windows SDK 10.0.26100 DXC 1.8.2502.11 (XCL_ADAPTER=NVIDIA).
    • cargo test --release -p xcl --lib hle::d3d12x::present:: (×3 --test-threads=1, ×3 --test-threads=4): 11 passed, 0 failed on all 6 runs (exit 0).
    • cargo build --workspace: exit 0.
    • cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1431 passed, 0 failed, 47 ignored.
    • 29 SKIPPED: the same 26 as PC 1 plus 3 requiring d3d12SDKLayers.dll.
  • The present.rs GPU tests run on WARP.

Regression run

main (b49be183, RTX 5080, release):

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 5080
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1019 (PresentX 1019)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14670 MB

PR (6d29dc26, RTX 5080, release, XCL_FRAME_DUMP=1):

xcl-smoke v1
commit: 6d29dc265b2a2cd5508b31b0da53c4ecb8e9566b
gpu: NVIDIA GeForce RTX 5080
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1663 (PresentX 1663)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14738 MB

Not tested

  • Reproducing the original RTX 3080 Ti nvwgf2umx.dll crash on main (did not reproduce on RTX 5080 on main 08db8020).
  • AMD discrete GPUs (RDNA3/RDNA4), Intel Arc, Linux / Wine / vkd3d-proton.
  • Retail scripts/smoke.ps1 on the RTX 2080 SUPER.

AI use
Ran via Samaritan:

  • OpenCode (Claude Opus 5.5): wrote the submitted runtime patch and initial tests, ran the initial workspace checks, and drafted the initial description. OpenCode helpers on the same model ran independent workspace checks and recorded earlier paired retail smoke results.
  • Google Antigravity CLI (Gemini 4 Hydrogen (High)): fixed the test-only COM double-Release teardown bug in 6d29dc26, independently reviewed the fix, ran the dual-PC workspace suites, 6× --release present:: checks, and the fresh RTX 5080 6d29dc26 smoke run, and contributed earlier frame-dump verification.
  • Google Antigravity CLI (Gemini 4 Neon (High)): coordinated verification, ran scripts/pr_check.py --local, updated this PR description, and pushed 6d29dc26.
  • OpenCode (GPT-6.2 Sol): checked attribution against the original execution records for the earlier description.
<!-- greyfinch-sync:ivall/xcl:issue:5506280027 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2713). Originally posted by [itsSio](https://github.com/itsSio) on 2026-11-26T08:05:49Z. --- With `XCL_FRAME_DUMP` set and no composited present, the frame dump read back the title's own `src` with a texture copy recorded at present time. XCL does not know which state the title keeps `src` in, and `readback_copy` recorded the copy for any resource, buffers included. The dump now reads back the swap chain buffer XCL has just copied into (COPY_DEST -> COPY_SOURCE -> PRESENT), as the composited path already does from RENDER_TARGET, and `readback_copy` refuses what it cannot copy to a buffer: anything other than a single-sample 2D texture with a size and a footprint format, or a failed `GetCopyableFootprints`. Part of #499 (observation 2). **What is in it** - `D3D12.X: read back the swap chain buffer for the frame dump and guard readback_copy` (`6d29dc26`): `crates/xcl/src/hle/d3d12x/present.rs` (`dump_backbuffer` used by both present paths; `readback_possible` checked in `readback_copy`; a unit test of the checks and a GPU test on WARP that dumps a filled swap chain buffer and refuses a buffer, using `ManuallyDrop::new(Some(bb.clone()))` / `up.clone()` to avoid a COM double-`Release` on test teardown) **Tested** Commit `6d29dc265b2a2cd5508b31b0da53c4ecb8e9566b`, clean checkouts on each PC, debug builds for workspace tests and release builds for `--release` `present::` checks and retail smoke runs. - PC 1: NVIDIA GeForce RTX 5080 (driver `32.0.16.1088`), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro build 26200, Rust 1.97.0 (`stable-x86_64-pc-windows-msvc`), DXC 1.9.2609.5 (`XCL_ADAPTER=NVIDIA`). - `cargo test --release -p xcl --lib hle::d3d12x::present:: -- --test-threads=1` (×3) and `-- --test-threads=4` (×3): **11 passed, 0 failed** on all 6 runs (exit 0). - `cargo build --workspace`: exit 0. - `cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture`: **1431 passed, 0 failed, 47 ignored**. - 26 `SKIPPED` GPU tests: wave64 tests (no wave64 on this adapter), f16 / f16-conversion wave32 refusals (`#1426`), `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows), `pso_measurement_compiles_an_exact_synthetic_record` (driver cache, Developer Mode). - Earlier 120 s `XCL_FRAME_DUMP=1` + `XCL_PRESS_A_AT=15,25,35,45,55` check (release, RTX 5080, on identical runtime code `b25ae0cf` vs `main` `08db8020`): both captured genuine non-black BMPs (`max=249`, `mean=36.6`, `99.8%` non-dark; `3258` vs `3306` frames) with `0` crashes, `0` device removals, and `0` `nvwgf2umx.dll` faults. - PC 2: NVIDIA GeForce RTX 2080 SUPER (driver `32.0.16.1088`), AMD Ryzen 5 5600X, 16 GB RAM, Windows 11 Pro build 26200, Rust 1.99.1 (`stable-x86_64-pc-windows-msvc`), Windows SDK 10.0.26100 DXC 1.8.2502.11 (`XCL_ADAPTER=NVIDIA`). - `cargo test --release -p xcl --lib hle::d3d12x::present::` (×3 `--test-threads=1`, ×3 `--test-threads=4`): **11 passed, 0 failed** on all 6 runs (exit 0). - `cargo build --workspace`: exit 0. - `cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture`: **1431 passed, 0 failed, 47 ignored**. - 29 `SKIPPED`: the same 26 as PC 1 plus 3 requiring `d3d12SDKLayers.dll`. - The `present.rs` GPU tests run on WARP. **Regression run** `main` (`b49be183`, RTX 5080, release): ``` xcl-smoke v1 commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 gpu: NVIDIA GeForce RTX 5080 title: retail-title seconds: 60 exit: 0x0 frames shown: 1019 (PresentX 1019) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14670 MB ``` PR (`6d29dc26`, RTX 5080, release, `XCL_FRAME_DUMP=1`): ``` xcl-smoke v1 commit: 6d29dc265b2a2cd5508b31b0da53c4ecb8e9566b gpu: NVIDIA GeForce RTX 5080 title: retail-title seconds: 60 exit: 0x0 frames shown: 1663 (PresentX 1663) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14738 MB ``` **Not tested** - Reproducing the original RTX 3080 Ti `nvwgf2umx.dll` crash on `main` (did not reproduce on RTX 5080 on `main` `08db8020`). - AMD discrete GPUs (RDNA3/RDNA4), Intel Arc, Linux / Wine / vkd3d-proton. - Retail `scripts/smoke.ps1` on the RTX 2080 SUPER. **AI use** Ran via Samaritan: - OpenCode (Claude Opus 5.5): wrote the submitted runtime patch and initial tests, ran the initial workspace checks, and drafted the initial description. OpenCode helpers on the same model ran independent workspace checks and recorded earlier paired retail smoke results. - Google Antigravity CLI (Gemini 4 Hydrogen (High)): fixed the test-only COM double-`Release` teardown bug in `6d29dc26`, independently reviewed the fix, ran the dual-PC workspace suites, 6× `--release` `present::` checks, and the fresh RTX 5080 `6d29dc26` smoke run, and contributed earlier frame-dump verification. - Google Antigravity CLI (Gemini 4 Neon (High)): coordinated verification, ran `scripts/pr_check.py --local`, updated this PR description, and pushed `6d29dc26`. - OpenCode (GPT-6.2 Sol): checked attribution against the original execution records for the earlier description.
emirduran707 commented 2026-11-26 10:06:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by emirduran707 on 2026-11-26T10:01:18Z.


Independent AMD RDNA4 (native wave64) verification of exact PR head b25ae0cf3816b2538742645b755ea8cf967976fd on Windows 11 Pro 26300 (AMD Radeon RX 9060 XT 16 GB, driver 32.0.31044.16, Ryzen 5 5600, Rust 1.100.0 MSVC, DXC 1.9.2602.17).

Tested

  • cargo build --workspace (debug): passed (0 errors).
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 1429 passed, 2 failed, 47 ignored (8 SKIPPED: 6 per-lane DXIL forms refused by host adapter/driver, 1 heap_window_out_of_memory_falls_back_to_the_switch_form no heap windows, 1 pso_measurement_compiles_an_exact_synthetic_record Windows Developer Mode off).
    • Both new tests passed on this GPU:
      • hle::d3d12x::present::frame_dump_tests::frame_dump_reads_the_swap_chain_buffer_after_its_copy_and_refuses_a_buffer
      • hle::d3d12x::present::frame_dump_tests::readback_needs_a_single_sample_2d_texture_with_a_footprint
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 and fuzz_validate_and_gpu_3) are pre-existing on unmodified main on this RX 9060 XT / driver 32.0.31044.16.
  • cargo build --release -p xcl + 60 s retail-title smoke test (scripts/smoke.ps1, offline):
xcl-smoke v1
commit: b25ae0cf3816b2538742645b755ea8cf967976fd
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1619)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 18726 MB

(Compare against main b49be183 on this machine: 1603 frames, 18576 MB peak, 0 device removals, 0 crashes.)

Not tested

  • NVIDIA / Intel GPUs, Linux / Wine.

AI use

  • Verification run and report prepared with Antigravity (Gemini 4 Neon); all build, test, and smoke results are from live runs on this machine.
<!-- greyfinch-sync:ivall/xcl:comment:7188800595 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2713#issuecomment-7188800595). Originally posted by [emirduran707](https://github.com/emirduran707) on 2026-11-26T10:01:18Z. --- Independent AMD RDNA4 (native wave64) verification of exact PR head `b25ae0cf3816b2538742645b755ea8cf967976fd` on Windows 11 Pro 26300 (AMD Radeon RX 9060 XT 16 GB, driver `32.0.31044.16`, Ryzen 5 5600, Rust 1.100.0 MSVC, DXC `1.9.2602.17`). **Tested** - `cargo build --workspace` (debug): passed (`0` errors). - `cargo test --workspace --no-fail-fast -- --test-threads=4`: `1429 passed, 2 failed, 47 ignored` (`8 SKIPPED`: 6 per-lane DXIL forms refused by host adapter/driver, 1 `heap_window_out_of_memory_falls_back_to_the_switch_form` no heap windows, 1 `pso_measurement_compiles_an_exact_synthetic_record` Windows Developer Mode off). - Both new tests passed on this GPU: - `hle::d3d12x::present::frame_dump_tests::frame_dump_reads_the_swap_chain_buffer_after_its_copy_and_refuses_a_buffer` - `hle::d3d12x::present::frame_dump_tests::readback_needs_a_single_sample_2d_texture_with_a_footprint` - The 2 failures (`gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1` and `fuzz_validate_and_gpu_3`) are pre-existing on unmodified `main` on this RX 9060 XT / driver `32.0.31044.16`. - `cargo build --release -p xcl` + 60 s retail-title smoke test (`scripts/smoke.ps1`, offline): ``` xcl-smoke v1 commit: b25ae0cf3816b2538742645b755ea8cf967976fd gpu: AMD Radeon RX 9060 XT title: 21222967 seconds: 60 exit: 0x0 frames shown: 1618 (PresentX 1619) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 18726 MB ``` (Compare against `main` `b49be183` on this machine: `1603 frames, 18576 MB peak, 0 device removals, 0 crashes`.) **Not tested** - NVIDIA / Intel GPUs, Linux / Wine. **AI use** - Verification run and report prepared with Antigravity (Gemini 4 Neon); all build, test, and smoke results are from live runs on this machine.
Decodere commented 2026-11-26 11:05:07 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Decodere on 2026-11-26T10:24:35Z.


Independent RTX 4060 (8 GB) / Windows 11 release verification of PR #2713 at b25ae0cf3816b2538742645b755ea8cf967976fd (parent 08db8020d323bf478964fcc586152cce54959cfc, MERGEABLE against origin/main b49be183).

Result: STATUS_ACCESS_VIOLATION (0xc0000005) in the new test — COM double-Release on teardown

Running hle::d3d12x::present:: in --release on Windows 11 26200 (rustc 1.100.0, NVIDIA GeForce RTX 4060 8 GB, driver 32.0.16.2114) hit 0xc0000005 (STATUS_ACCESS_VIOLATION) inside the new test frame_dump_reads_the_swap_chain_buffer_after_its_copy_and_refuses_a_buffer (both under --test-threads=4 and deterministically isolated by --test-threads=1), while unmodified origin/main (b49be183) passed 3/3 times cleanly.

Reproduction on b25ae0cf vs origin/main (b49be183)

  • origin/main (b49be183) cargo test --release -p xcl --lib hle::d3d12x::present:: -- --test-threads=4: 9 passed, 0 failed, 0 ignored × 3 consecutive runs (0.03 s, 0.03 s, 0.02 s, exit 0).
  • PR #2713 (b25ae0cf):
    • cargo test --release -p xcl --lib readback_needs_a_single_sample_2d_texture_with_a_footprint -- --nocapture: 1 passed, 0 failed (0.00 s, exit 0).
    • cargo test --release -p xcl --lib frame_dump_reads_the_swap_chain_buffer_after_its_copy_and_refuses_a_buffer -- --nocapture: 1 passed, 0 failed (0.02 s, exit 0 when run standalone).
    • cargo test --release -p xcl --lib hle::d3d12x::present:: -- --test-threads=4: crashed 1/4 runs with exit code: 0xc0000005, STATUS_ACCESS_VIOLATION (the other 10 tests printed ... ok, leaving only frame_dump_reads_the_swap_chain_buffer_after_its_copy_and_refuses_a_buffer unfinished; the other 3/4 passes exited 0, 11/0/0).
    • cargo test --release -p xcl --lib hle::d3d12x::present:: -- --test-threads=1: crashed with exit code: 0xc0000005, STATUS_ACCESS_VIOLATION directly on frame_dump_reads_the_swap_chain_buffer_after_its_copy_and_refuses_a_buffer:
      running 11 tests
      test hle::d3d12x::present::frame_dump_tests::compositor_blends_ui_plane_over_scene_plane ... ok
      test hle::d3d12x::present::frame_dump_tests::frame_dump_reads_the_swap_chain_buffer_after_its_copy_and_refuses_a_buffer ... error: test failed, to rerun pass `-p xcl --lib`
      (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)
      

Root cause in crates/xcl/src/hle/d3d12x/present.rs (b25ae0cf)

In frame_dump_reads_the_swap_chain_buffer_after_its_copy_and_refuses_a_buffer:

  • Lines 1809–1815 construct dst.pResource and src.pResource with std::mem::transmute_copy(&bb) and std::mem::transmute_copy(&up), which copies the COM interface pointer without calling AddRef.
  • Lines 1848–1849 then call:
    let _ = ManuallyDrop::into_inner(dst.pResource);
    let _ = ManuallyDrop::into_inner(src.pResource);
    
    which immediately drops both un-AddRef'd wrappers and invokes IUnknown::Release() on bb and up (up drops 1 -> 0 and is freed; bb drops 2 -> 1, then dumps drops 1 -> 0 freeing bb).
  • At function exit (line 1851), up and bb drop a second time, calling IUnknown::Release() on freed WARP ID3D12Resource objects -> heap-dependent UAF / STATUS_ACCESS_VIOLATION (which explains why isolated or single-run test invocations can occasionally slip through before the freed slot is reused).

(Note: production code in present_now lines 1150/1155 uses ManuallyDrop::new(Some(bb.clone())) / src.clone() before ManuallyDrop::into_inner, and readback_copy lines 1333–1335 uses transmute_copy without calling ManuallyDrop::into_inner, so this COM double-Release is isolated to the new test.)

Suggested fix (2 lines in the new test)

Either match present_now by calling .clone():

pResource: ManuallyDrop::new(Some(bb.clone())),
// ...
pResource: ManuallyDrop::new(Some(up.clone())),

or delete lines 1848–1849 (let _ = ManuallyDrop::into_inner(...)) so the borrowed transmute_copy wrappers stay ManuallyDrop and are not released.

Limits of coverage

  • Stopped before building/running a 60 s retail smoke on b25ae0cf once hle::d3d12x::present:: crashed with 0xc0000005; happy to re-verify unit tests + paired 60 s RTX 4060 smoke once the test teardown is fixed.

AI use

Ran the release unit test reproductions and root-cause inspection with assistance from Google Antigravity (Gemini 4 Neon); all test results and exit codes were taken directly from cargo test output.

<!-- greyfinch-sync:ivall/xcl:comment:7189327111 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2713#issuecomment-7189327111). Originally posted by [Decodere](https://github.com/Decodere) on 2026-11-26T10:24:35Z. --- **Independent RTX 4060 (8 GB) / Windows 11 release verification of PR #2713 at `b25ae0cf3816b2538742645b755ea8cf967976fd`** (parent `08db8020d323bf478964fcc586152cce54959cfc`, `MERGEABLE` against `origin/main` `b49be183`). ### Result: `STATUS_ACCESS_VIOLATION` (`0xc0000005`) in the new test — COM double-`Release` on teardown Running `hle::d3d12x::present::` in `--release` on Windows 11 `26200` (`rustc 1.100.0`, NVIDIA GeForce RTX 4060 8 GB, driver `32.0.16.2114`) hit **`0xc0000005` (`STATUS_ACCESS_VIOLATION`)** inside the new test `frame_dump_reads_the_swap_chain_buffer_after_its_copy_and_refuses_a_buffer` (both under `--test-threads=4` and deterministically isolated by `--test-threads=1`), while unmodified `origin/main` (`b49be183`) passed 3/3 times cleanly. #### Reproduction on `b25ae0cf` vs `origin/main` (`b49be183`) - `origin/main` (`b49be183`) `cargo test --release -p xcl --lib hle::d3d12x::present:: -- --test-threads=4`: **9 passed, 0 failed, 0 ignored** × 3 consecutive runs (`0.03 s`, `0.03 s`, `0.02 s`, exit `0`). - PR `#2713` (`b25ae0cf`): - `cargo test --release -p xcl --lib readback_needs_a_single_sample_2d_texture_with_a_footprint -- --nocapture`: **1 passed, 0 failed** (`0.00 s`, exit `0`). - `cargo test --release -p xcl --lib frame_dump_reads_the_swap_chain_buffer_after_its_copy_and_refuses_a_buffer -- --nocapture`: **1 passed, 0 failed** (`0.02 s`, exit `0` when run standalone). - `cargo test --release -p xcl --lib hle::d3d12x::present:: -- --test-threads=4`: crashed **1/4** runs with **`exit code: 0xc0000005, STATUS_ACCESS_VIOLATION`** (the other 10 tests printed `... ok`, leaving only `frame_dump_reads_the_swap_chain_buffer_after_its_copy_and_refuses_a_buffer` unfinished; the other 3/4 passes exited `0`, `11/0/0`). - `cargo test --release -p xcl --lib hle::d3d12x::present:: -- --test-threads=1`: crashed with **`exit code: 0xc0000005, STATUS_ACCESS_VIOLATION`** directly on `frame_dump_reads_the_swap_chain_buffer_after_its_copy_and_refuses_a_buffer`: ```text running 11 tests test hle::d3d12x::present::frame_dump_tests::compositor_blends_ui_plane_over_scene_plane ... ok test hle::d3d12x::present::frame_dump_tests::frame_dump_reads_the_swap_chain_buffer_after_its_copy_and_refuses_a_buffer ... error: test failed, to rerun pass `-p xcl --lib` (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION) ``` #### Root cause in `crates/xcl/src/hle/d3d12x/present.rs` (`b25ae0cf`) In `frame_dump_reads_the_swap_chain_buffer_after_its_copy_and_refuses_a_buffer`: - Lines `1809–1815` construct `dst.pResource` and `src.pResource` with `std::mem::transmute_copy(&bb)` and `std::mem::transmute_copy(&up)`, which copies the COM interface pointer **without calling `AddRef`**. - Lines `1848–1849` then call: ```rust let _ = ManuallyDrop::into_inner(dst.pResource); let _ = ManuallyDrop::into_inner(src.pResource); ``` which immediately drops both un-`AddRef`'d wrappers and invokes `IUnknown::Release()` on `bb` and `up` (`up` drops `1 -> 0` and is freed; `bb` drops `2 -> 1`, then `dumps` drops `1 -> 0` freeing `bb`). - At function exit (line `1851`), `up` and `bb` drop a **second** time, calling `IUnknown::Release()` on freed WARP `ID3D12Resource` objects -> heap-dependent UAF / `STATUS_ACCESS_VIOLATION` (which explains why isolated or single-run test invocations can occasionally slip through before the freed slot is reused). *(Note: production code in `present_now` lines `1150`/`1155` uses `ManuallyDrop::new(Some(bb.clone()))` / `src.clone()` before `ManuallyDrop::into_inner`, and `readback_copy` lines `1333–1335` uses `transmute_copy` without calling `ManuallyDrop::into_inner`, so this COM double-`Release` is isolated to the new test.)* #### Suggested fix (2 lines in the new test) Either match `present_now` by calling `.clone()`: ```rust pResource: ManuallyDrop::new(Some(bb.clone())), // ... pResource: ManuallyDrop::new(Some(up.clone())), ``` or delete lines `1848–1849` (`let _ = ManuallyDrop::into_inner(...)`) so the borrowed `transmute_copy` wrappers stay `ManuallyDrop` and are not released. ### Limits of coverage - Stopped before building/running a 60 s retail smoke on `b25ae0cf` once `hle::d3d12x::present::` crashed with `0xc0000005`; happy to re-verify unit tests + paired 60 s RTX 4060 smoke once the test teardown is fixed. ### AI use Ran the release unit test reproductions and root-cause inspection with assistance from Google Antigravity (Gemini 4 Neon); all test results and exit codes were taken directly from `cargo test` output.
itsSio commented 2026-11-26 13:05:34 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by itsSio on 2026-11-26T12:08:20Z.


Thanks for catching the --release 0xc0000005 teardown crash @Decodere — confirmed the test-only COM double-Release from std::mem::transmute_copy + ManuallyDrop::into_inner in frame_dump_reads_the_swap_chain_buffer_after_its_copy_and_refuses_a_buffer.

Pushed squashed commit 6d29dc265b2a2cd5508b31b0da53c4ecb8e9566b replacing both transmute_copy calls with ManuallyDrop::new(Some(bb.clone())) / ManuallyDrop::new(Some(up.clone())) and updated the PR description with fresh dual-PC results and a 6d29dc26 RTX 5080 smoke block:

  • PC 1 (RTX 5080, driver 32.0.16.1088, Ryzen 7 9800X3D, Win11 26200, rustc 1.97.0, DXC 1.9.2609.5): cargo test --release -p xcl --lib hle::d3d12x::present:: passed 11/0 across 6 runs (--test-threads=1 ×3, --test-threads=4 ×3); full workspace 1431/0/47 (26 SKIPPED); 60 s XCL_FRAME_DUMP=1 smoke 1663 frames, 0 removals/crashes.
  • PC 2 (RTX 2080 SUPER, driver 32.0.16.1088, Ryzen 5 5600X, Win11 26200, rustc 1.99.1, WinSDK DXC 1.8.2502.11): cargo test --release -p xcl --lib hle::d3d12x::present:: passed 11/0 across 6 runs (--test-threads=1 ×3, --test-threads=4 ×3); full workspace 1431/0/47 (29 SKIPPED).

AI use
Ran via Samaritan:

  • Google Antigravity CLI (Gemini 4 Hydrogen (High)): wrote and reviewed the 2-line fix in 6d29dc26 and ran the dual-PC release, workspace, and smoke checks.
  • Google Antigravity CLI (Gemini 4 Neon (High)): verified pr_check.py, pushed 6d29dc26, and posted this update.
<!-- greyfinch-sync:ivall/xcl:comment:7191614623 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2713#issuecomment-7191614623). Originally posted by [itsSio](https://github.com/itsSio) on 2026-11-26T12:08:20Z. --- Thanks for catching the `--release` `0xc0000005` teardown crash @Decodere — confirmed the test-only COM double-`Release` from `std::mem::transmute_copy` + `ManuallyDrop::into_inner` in `frame_dump_reads_the_swap_chain_buffer_after_its_copy_and_refuses_a_buffer`. Pushed squashed commit `6d29dc265b2a2cd5508b31b0da53c4ecb8e9566b` replacing both `transmute_copy` calls with `ManuallyDrop::new(Some(bb.clone()))` / `ManuallyDrop::new(Some(up.clone()))` and updated the PR description with fresh dual-PC results and a `6d29dc26` RTX 5080 smoke block: - PC 1 (RTX 5080, driver `32.0.16.1088`, Ryzen 7 9800X3D, Win11 26200, `rustc 1.97.0`, DXC `1.9.2609.5`): `cargo test --release -p xcl --lib hle::d3d12x::present::` passed `11/0` across 6 runs (`--test-threads=1` ×3, `--test-threads=4` ×3); full workspace `1431/0/47` (`26 SKIPPED`); 60 s `XCL_FRAME_DUMP=1` smoke `1663` frames, `0` removals/crashes. - PC 2 (RTX 2080 SUPER, driver `32.0.16.1088`, Ryzen 5 5600X, Win11 26200, `rustc 1.99.1`, WinSDK DXC `1.8.2502.11`): `cargo test --release -p xcl --lib hle::d3d12x::present::` passed `11/0` across 6 runs (`--test-threads=1` ×3, `--test-threads=4` ×3); full workspace `1431/0/47` (`29 SKIPPED`). **AI use** Ran via Samaritan: - Google Antigravity CLI (Gemini 4 Hydrogen (High)): wrote and reviewed the 2-line fix in `6d29dc26` and ran the dual-PC release, workspace, and smoke checks. - Google Antigravity CLI (Gemini 4 Neon (High)): verified `pr_check.py`, pushed `6d29dc26`, and posted this update.
Decodere commented 2026-11-26 13:05:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Decodere on 2026-11-26T12:49:52Z.


Re-verification of PR #2713 at 6d29dc265b2a2cd5508b31b0da53c4ecb8e9566b (RTX 4060 8 GB / Windows 11, --release) (parent 08db8020d323bf478964fcc586152cce54959cfc, MERGEABLE against origin/main b49be183).

Result: --release 0xc0000005 teardown crash is fixed

Re-tested the exact commands that previously hit 0xc0000005 (STATUS_ACCESS_VIOLATION) on b25ae0cf (both --test-threads=1 and --test-threads=4), plus a quiet 60 s retail smoke:

Setup

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6 cores / 12 threads), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200
  • Toolchain / caches: rustc 1.100.0 (0ef1bc386 2026-11-09), DXC 1.9.2609.5, release builds, warm DXIL/pipeline caches, quiet machine (zero concurrent builds/tests during timed runs)
  • Workload: Retail workload title: 29640639 via scripts/smoke.ps1 -Seconds 60 (XCL_NETWORK=0 XCL_ACTIVITY=1, default flags, no input)

Targeted Win11 / RTX 4060 release unit tests (6d29dc26)

  • cargo test --release -p xcl --lib hle::d3d12x::present:: -- --test-threads=1 (3 consecutive runs): 11 passed, 0 failed, 0 ignored × 3 (0.05 s, 0.05 s, 0.05 s, 0 skipped, exit 0).
  • cargo test --release -p xcl --lib hle::d3d12x::present:: -- --test-threads=4 (3 consecutive runs): 11 passed, 0 failed, 0 ignored × 3 (0.03 s, 0.03 s, 0.03 s, 0 skipped, exit 0).

Paired 60 s RTX 4060 smoke (b49be183 vs 6d29dc26)

Reference origin/main (b49be183):

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1518 (PresentX 1518)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14018 MB

PR #2713 head (6d29dc26):

xcl-smoke v1
commit: 6d29dc265b2a2cd5508b31b0da53c4ecb8e9566b
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1577 (PresentX 1577)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14017 MB

Limits of coverage

  • Full workspace test suite was not re-run on 6d29dc26 (only 6 repeated --release passes of hle::d3d12x::present:: plus paired quiet 60 s default-flags smoke).
  • Live XCL_FRAME_DUMP=1 BMP export during the retail smoke was not enabled; swap-chain backbuffer readback and buffer refusal are covered by the WARP D3D12 unit test frame_dump_reads_the_swap_chain_buffer_after_its_copy_and_refuses_a_buffer.
  • Native Windows 11 (26200) / discrete RTX 4060 only; no AMD, Intel, or Wine/Linux run on this host.

AI use

Ran the repeated release unit test passes and paired quiet 60 s smoke runs with assistance from Google Antigravity (Gemini 4 Neon); all test counts and smoke blocks were taken directly from cargo test and scripts/smoke.ps1 outputs.

<!-- greyfinch-sync:ivall/xcl:comment:7192517076 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2713#issuecomment-7192517076). Originally posted by [Decodere](https://github.com/Decodere) on 2026-11-26T12:49:52Z. --- **Re-verification of PR #2713 at `6d29dc265b2a2cd5508b31b0da53c4ecb8e9566b` (RTX 4060 8 GB / Windows 11, `--release`)** (parent `08db8020d323bf478964fcc586152cce54959cfc`, `MERGEABLE` against `origin/main` `b49be183`). ### Result: `--release` `0xc0000005` teardown crash is fixed Re-tested the exact commands that previously hit `0xc0000005` (`STATUS_ACCESS_VIOLATION`) on `b25ae0cf` (both `--test-threads=1` and `--test-threads=4`), plus a quiet 60 s retail smoke: ### Setup - **GPU:** NVIDIA GeForce RTX 4060 (8 GB / `7956 MiB` reported by D3D12), driver `32.0.16.2114` (NVIDIA `621.14`, WDDM 3.2) - **CPU / RAM / OS:** Intel Core i5-11400F (6 cores / 12 threads), 32 GB RAM (`31.9 GiB` usable), Windows 11 Home `26200` - **Toolchain / caches:** `rustc 1.100.0 (0ef1bc386 2026-11-09)`, DXC `1.9.2609.5`, release builds, warm DXIL/pipeline caches, quiet machine (zero concurrent builds/tests during timed runs) - **Workload:** Retail workload `title: 29640639` via `scripts/smoke.ps1 -Seconds 60` (`XCL_NETWORK=0 XCL_ACTIVITY=1`, default flags, no input) ### Targeted Win11 / RTX 4060 release unit tests (`6d29dc26`) - `cargo test --release -p xcl --lib hle::d3d12x::present:: -- --test-threads=1` (3 consecutive runs): **11 passed, 0 failed, 0 ignored** × 3 (`0.05 s`, `0.05 s`, `0.05 s`, `0` skipped, exit `0`). - `cargo test --release -p xcl --lib hle::d3d12x::present:: -- --test-threads=4` (3 consecutive runs): **11 passed, 0 failed, 0 ignored** × 3 (`0.03 s`, `0.03 s`, `0.03 s`, `0` skipped, exit `0`). ### Paired 60 s RTX 4060 smoke (`b49be183` vs `6d29dc26`) Reference `origin/main` (`b49be183`): ``` xcl-smoke v1 commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1518 (PresentX 1518) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14018 MB ``` PR #2713 head (`6d29dc26`): ``` xcl-smoke v1 commit: 6d29dc265b2a2cd5508b31b0da53c4ecb8e9566b gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1577 (PresentX 1577) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14017 MB ``` ### Limits of coverage - Full workspace test suite was not re-run on `6d29dc26` (only 6 repeated `--release` passes of `hle::d3d12x::present::` plus paired quiet 60 s default-flags smoke). - Live `XCL_FRAME_DUMP=1` BMP export during the retail smoke was not enabled; swap-chain backbuffer readback and buffer refusal are covered by the WARP D3D12 unit test `frame_dump_reads_the_swap_chain_buffer_after_its_copy_and_refuses_a_buffer`. - Native Windows 11 (`26200`) / discrete RTX 4060 only; no AMD, Intel, or Wine/Linux run on this host. ### AI use Ran the repeated release unit test passes and paired quiet 60 s smoke runs with assistance from Google Antigravity (Gemini 4 Neon); all test counts and smoke blocks were taken directly from `cargo test` and `scripts/smoke.ps1` outputs.
github-actions[bot] commented 2026-12-01 02:34:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-12-01T02:34:26Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7298761186 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2713#issuecomment-7298761186). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-12-01T02:34:26Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 08:47:13 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:47:13Z.


Triage (#1607) – head 6d29dc2

Main still reads back the title's src in the uncomposited present path (present.rs, readback_copy(&p.list, src, desc)), and readback_copy has no guard. No open or merged PR moves the dump to the swap chain buffer or adds readback_possible.
dump_backbuffer leaves bb in PRESENT on both paths, as the old barriers did. No problems found in the diff. The PR conflicts with main's newer present.rs and needs a rebase.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7305782816 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2713#issuecomment-7305782816). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T08:47:13Z. --- **Triage (#1607)** – head 6d29dc2 Main still reads back the title's `src` in the uncomposited present path (`present.rs`, `readback_copy(&p.list, src, desc)`), and `readback_copy` has no guard. No open or merged PR moves the dump to the swap chain buffer or adds `readback_possible`. `dump_backbuffer` leaves `bb` in PRESENT on both paths, as the old barriers did. No problems found in the diff. The PR conflicts with main's newer `present.rs` and needs a rebase. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2713:upstream-pr/2713'
git switch 'upstream-pr/2713'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2713'
git switch 'upstream-pr/2713'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2713'
git switch 'upstream-pr/2713'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2713'
git switch 'main'
git merge --squash 'upstream-pr/2713'
git switch 'main'
git merge --ff-only 'upstream-pr/2713'
git switch 'main'
git merge 'upstream-pr/2713'
git push origin 'main'
Sign in to join this conversation.
No reviewers
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!2703
No description provided.