Tests: stop leaking imported heap resource references #1510

Open
wileyGray wants to merge 1 commit from upstream-pr/1520 into main
wileyGray commented 2026-11-24 17:12:01 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by wileyGray on 2026-11-24T17:12:01Z.


Part of #1487. Four transition barriers in the imported-heap GPU test cloned a resource into ManuallyDrop and never released it. The test then freed the backing allocation with four resource references outstanding. This fixes that specific lifetime bug, also identified in the #175 investigation; it does not establish the cause of every intermittent access violation in #1487.

What is in it

  • crates/xcl/src/hle/d3d12x/list_x.rs: borrow the resource in the four test barriers while its owner remains alive through the existing fence waits, check VirtualFree, and add a CPU-only reference-count regression. All 75 changed lines are inside #[cfg(test)] mod tests.

Tested

  • Clean head 6159773d93e826b4c328ad7174334c7a12c75541, based on main b7aa9f3; Windows 11 Home build 26300, i9-14900K, RTX 4080 SUPER, driver 32.0.16.2114, Rust 1.93.0, DXC 1.9.2609.5, debug, XCL_ADAPTER=NVIDIA. All XCL_SAMPLE_* unset.
  • scripts/test.ps1 (workspace build and tests with four threads): 771 passed, 0 failed, 41 ignored. Includes four GPU/debug skips (two native-wave64 tests, two missing-debug-layer tests) and 33 sample-gated early returns; these are not executed coverage. Synthetic console-title e2e passed.
  • The new regression failed with the old clone behavior: reference counts (5, 4) after four barriers / dropping the owner, versus expected (1, 0). With the fix: 1 passed, 0 failed. Reproduce: cargo test -p xcl --lib imported_heap_test_barriers_do_not_retain_the_resource -- --nocapture.
  • The existing imported-heap GPU test passed individually. Ten processes each ran it alongside real::readback_routing_tests::coherent_buffer_sanitizes_console_flags_and_state with two threads: 20 passed, 0 failed, 0 skipped, no access violations or stalls (0.27-0.36 seconds per pair).
  • Independent diff review and git diff --check passed.
Paired-test reproduction and exact GPU/debug skips

Build with cargo test -p xcl --lib --no-run. Run the emitted library test executable ten times, one process at a time, with these arguments (each run must report exactly two passes and no skips):

--test-threads=2 --nocapture --exact
hle::d3d12x::list_x::tests::write_buffer_immediate_on_open_existing_heap_visible_to_cpu
hle::d3d12x::real::readback_routing_tests::coherent_buffer_sanitizes_console_flags_and_state

Full-suite GPU/debug skips: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware (no native wave64); uploads_start_from_each_subresources_state and test_title_draws_with_a_root_signature_under_the_debug_layer (debug layer unavailable).

Regression run

  • No retail smoke run. This diff only changes the inline test module; please review and apply the maintainer-controlled test-only label under CONTRIBUTING.md. The path-based description check otherwise requests retail smoke blocks. No runtime behavior changes.

Not tested

  • AMD, Intel, Wine/RADV, release, retail titles, long stress runs, or the reporter's hardware/driver. Ten repetitions do not prove the broader intermittent issue resolved. No proprietary game data or issue attachments were used.

AI use

  • Codex (GPT-6; exact variant unavailable) inspected the issue and code, implemented and reviewed the test-only fix, ran validation, and wrote this report under the user's direction.
<!-- greyfinch-sync:ivall/xcl:issue:5476857761 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1520). Originally posted by [wileyGray](https://github.com/wileyGray) on 2026-11-24T17:12:01Z. --- Part of #1487. Four transition barriers in the imported-heap GPU test cloned a resource into `ManuallyDrop` and never released it. The test then freed the backing allocation with four resource references outstanding. This fixes that specific lifetime bug, also identified in [the #175 investigation](https://github.com/ivall/xcl/issues/175#issuecomment-7125561381); it does not establish the cause of every intermittent access violation in #1487. **What is in it** - `crates/xcl/src/hle/d3d12x/list_x.rs`: borrow the resource in the four test barriers while its owner remains alive through the existing fence waits, check `VirtualFree`, and add a CPU-only reference-count regression. All 75 changed lines are inside `#[cfg(test)] mod tests`. **Tested** - Clean head `6159773d93e826b4c328ad7174334c7a12c75541`, based on main `b7aa9f3`; Windows 11 Home build 26300, i9-14900K, RTX 4080 SUPER, driver 32.0.16.2114, Rust 1.93.0, DXC 1.9.2609.5, debug, `XCL_ADAPTER=NVIDIA`. All `XCL_SAMPLE_*` unset. - `scripts/test.ps1` (workspace build and tests with four threads): **771 passed, 0 failed, 41 ignored**. Includes four GPU/debug skips (two native-wave64 tests, two missing-debug-layer tests) and 33 sample-gated early returns; these are not executed coverage. Synthetic console-title e2e passed. - The new regression failed with the old clone behavior: reference counts `(5, 4)` after four barriers / dropping the owner, versus expected `(1, 0)`. With the fix: **1 passed, 0 failed**. Reproduce: `cargo test -p xcl --lib imported_heap_test_barriers_do_not_retain_the_resource -- --nocapture`. - The existing imported-heap GPU test passed individually. Ten processes each ran it alongside `real::readback_routing_tests::coherent_buffer_sanitizes_console_flags_and_state` with two threads: **20 passed, 0 failed, 0 skipped**, no access violations or stalls (0.27-0.36 seconds per pair). - Independent diff review and `git diff --check` passed. <details> <summary>Paired-test reproduction and exact GPU/debug skips</summary> Build with `cargo test -p xcl --lib --no-run`. Run the emitted library test executable ten times, one process at a time, with these arguments (each run must report exactly two passes and no skips): ```text --test-threads=2 --nocapture --exact hle::d3d12x::list_x::tests::write_buffer_immediate_on_open_existing_heap_visible_to_cpu hle::d3d12x::real::readback_routing_tests::coherent_buffer_sanitizes_console_flags_and_state ``` Full-suite GPU/debug skips: `gpu_geometry_wave32_prefix_count_over_a_mask` and `gpu_wave32_program_in_wave64_hardware` (no native wave64); `uploads_start_from_each_subresources_state` and `test_title_draws_with_a_root_signature_under_the_debug_layer` (debug layer unavailable). </details> **Regression run** - No retail smoke run. This diff only changes the inline test module; please review and apply the maintainer-controlled `test-only` label under CONTRIBUTING.md. The path-based description check otherwise requests retail smoke blocks. No runtime behavior changes. **Not tested** - AMD, Intel, Wine/RADV, release, retail titles, long stress runs, or the reporter's hardware/driver. Ten repetitions do not prove the broader intermittent issue resolved. No proprietary game data or issue attachments were used. **AI use** - Codex (GPT-6; exact variant unavailable) inspected the issue and code, implemented and reviewed the test-only fix, ran validation, and wrote this report under the user's direction.
GonZiin commented 2026-11-24 17:52:33 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by GonZiin on 2026-11-24T17:52:33Z.

Review: COMMENTED


Independent full-suite run on AMD RDNA4. Both the reference-count regression and the imported-heap GPU test passed. I checked the diff and all changed Rust lines are inside the test module.

Tested

  • Head 6159773d93e826b4c328ad7174334c7a12c75541, clean checkout. Windows 11 Pro build 26300, Ryzen 7 7800X3D, Radeon RX 9070 XT (driver 32.0.32029.2010), Rust 1.100.0 MSVC, DXC 1.8.2502.11, debug.
  • .\scripts\test.ps1 exited 0. Workspace totals were 771 passed, 0 failed, 41 ignored and 0 reported GPU skips. The bundled title end-to-end test passed.
  • The PR description job is asking for retail smoke blocks because the tests live inside list_x.rs. A maintainer can apply the documented test-only label after checking this revision.

Not tested

Retail smoke and the opt-in sample data tests.

AI use

Codex (gpt-6.2-sol) inspected the diff, ran the Windows tests, and wrote this review.

<!-- greyfinch-sync:ivall/xcl:review:6044527860 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1520#pullrequestreview-6044527860). Originally posted by [GonZiin](https://github.com/GonZiin) on 2026-11-24T17:52:33Z. **Review:** COMMENTED --- Independent full-suite run on AMD RDNA4. Both the reference-count regression and the imported-heap GPU test passed. I checked the diff and all changed Rust lines are inside the test module. **Tested** - Head `6159773d93e826b4c328ad7174334c7a12c75541`, clean checkout. Windows 11 Pro build 26300, Ryzen 7 7800X3D, Radeon RX 9070 XT (driver 32.0.32029.2010), Rust 1.100.0 MSVC, DXC 1.8.2502.11, debug. - `.\scripts\test.ps1` exited 0. Workspace totals were 771 passed, 0 failed, 41 ignored and 0 reported GPU skips. The bundled title end-to-end test passed. - The PR description job is asking for retail smoke blocks because the tests live inside `list_x.rs`. A maintainer can apply the documented `test-only` label after checking this revision. **Not tested** Retail smoke and the opt-in sample data tests. **AI use** Codex (`gpt-6.2-sol`) inspected the diff, ran the Windows tests, and wrote this review.
Bullet18x commented 2026-11-24 19:07:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Bullet18x on 2026-11-24T18:25:13Z.


Test report for head 6159773, with one finding about the new VirtualFree assert.

Tested

  • RTX 5090, driver 32.0.16.2114, Windows 11 Pro 10.0.28000, Rust 1.100.0 MSVC, debug, all XCL_SAMPLE_* unset.
  • imported_heap_test_barriers_do_not_retain_the_resource passes. The barriers no longer keep the resource alive.
  • cargo test -p xcl --lib -- --test-threads=32, 10 runs on 6159773: write_buffer_immediate_on_open_existing_heap_visible_to_cpu failed or was among the failures in 4 runs. In 1 of those 4 it was the only failure, on the new assert_ne!(VirtualFree(mem, 0, MEM_RELEASE), 0) (left: 0, right: 0). The other 3 also had an access violation (#1523's cause).
  • main 9e3831e + #1520 + #1523 + #1590, 25 runs at 32/16 threads: this assert failed 4 times, and nothing else in this test failed.

Cause (same as #1590)
D3D12CreateDevice returns the process's one device. Once another test has adopted it, buf is adopted too, and its last Release goes to late_release::hold. While another test's queue still has work, the resource is held and the imported heap keeps mem pinned. So the first VirtualFree fails with 87, even with the leak fixed.

Check
On the combined branch, I let this test retry VirtualFree for up to 10 s, the same as #1590 does for coherent_buffer_sanitizes_console_flags_and_state, and ran it 20 more times at 32 threads. The test failed 0 times. The first VirtualFree failed in 4 runs, and the retry freed the memory each time, after 5 to 27 ms.

Suggestion
Keep the assert, but wait for the held release first:

let start = std::time::Instant::now();
let mut freed = VirtualFree(mem, 0, MEM_RELEASE);
while freed == 0 && start.elapsed() < std::time::Duration::from_secs(10) {
    std::thread::sleep(std::time::Duration::from_millis(5));
    freed = VirtualFree(mem, 0, MEM_RELEASE);
}
assert_ne!(freed, 0, "the heap's pages were not let go within 10 s");

Not tested

  • AMD and Intel, the release build, Wine.

AI use: Claude Code with Claude Opus 5.5 ran the tests, found the cause and wrote this report. I checked each point.

<!-- greyfinch-sync:ivall/xcl:comment:7140619256 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1520#issuecomment-7140619256). Originally posted by [Bullet18x](https://github.com/Bullet18x) on 2026-11-24T18:25:13Z. --- Test report for head `6159773`, with one finding about the new `VirtualFree` assert. **Tested** - RTX 5090, driver 32.0.16.2114, Windows 11 Pro 10.0.28000, Rust 1.100.0 MSVC, debug, all `XCL_SAMPLE_*` unset. - `imported_heap_test_barriers_do_not_retain_the_resource` passes. The barriers no longer keep the resource alive. - `cargo test -p xcl --lib -- --test-threads=32`, 10 runs on `6159773`: `write_buffer_immediate_on_open_existing_heap_visible_to_cpu` failed or was among the failures in 4 runs. In 1 of those 4 it was the only failure, on the new `assert_ne!(VirtualFree(mem, 0, MEM_RELEASE), 0)` (`left: 0, right: 0`). The other 3 also had an access violation (#1523's cause). - main `9e3831e` + #1520 + #1523 + #1590, 25 runs at 32/16 threads: this assert failed 4 times, and nothing else in this test failed. **Cause (same as #1590)** `D3D12CreateDevice` returns the process's one device. Once another test has adopted it, `buf` is adopted too, and its last `Release` goes to `late_release::hold`. While another test's queue still has work, the resource is held and the imported heap keeps `mem` pinned. So the first `VirtualFree` fails with 87, even with the leak fixed. **Check** On the combined branch, I let this test retry `VirtualFree` for up to 10 s, the same as #1590 does for `coherent_buffer_sanitizes_console_flags_and_state`, and ran it 20 more times at 32 threads. The test failed 0 times. The first `VirtualFree` failed in 4 runs, and the retry freed the memory each time, after 5 to 27 ms. **Suggestion** Keep the assert, but wait for the held release first: ```rust let start = std::time::Instant::now(); let mut freed = VirtualFree(mem, 0, MEM_RELEASE); while freed == 0 && start.elapsed() < std::time::Duration::from_secs(10) { std::thread::sleep(std::time::Duration::from_millis(5)); freed = VirtualFree(mem, 0, MEM_RELEASE); } assert_ne!(freed, 0, "the heap's pages were not let go within 10 s"); ``` **Not tested** - AMD and Intel, the release build, Wine. AI use: Claude Code with Claude Opus 5.5 ran the tests, found the cause and wrote this report. I checked each point.
DavidM1911 commented 2026-11-24 19:07:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T18:54:00Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7141308228 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1520#issuecomment-7141308228). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T18:54:00Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified `main`.) Thanks!
crastinator commented 2026-11-24 19:20:15 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by crastinator on 2026-11-24T19:20:15Z.

Review: COMMENTED


Tested on RDNA2 under Wine (RADV). This also fixes the parallel device removal I traced in #1246: the VirtualFree of this test's imported memory while another test's GPU work ran on the shared device.

Tested (head 6159773, merged onto main c160d86: no conflicts)

  • AMD Radeon RX 6700 XT (RDNA2, gfx1031, RADV NAVI22, Mesa 26.3.1), Ryzen 7 5700X, Linux 7.3.5. Proton Experimental 11.0-20261112's Wine, vkd3d-proton v3.1 + #257's patch (-Db_ndebug=true, dxil-spirv 53aac418), DXVK v3.1.1-209 dxgi, DXC 1.9.2609.5. Cross-built for x86_64-pc-windows-msvc, Rust 1.99.1, debug.
  • The #1246 pair, --test-threads=2 --exact gpu::recomp::tests::jumps_to_outer_loop_heads_are_structured hle::d3d12x::list_x::tests::write_buffer_immediate_on_open_existing_heap_visible_to_cpu: main fails 3/3 (kernel dispatch: D3D12 device removed after ~0.15 s). With this PR it passes 3/3.
  • cargo test -p xcl --lib -- --test-threads=4, 2 runs: 801 / 9 / 22 and 804 / 6 / 22 (passed / failed / ignored), no device removal. The 6 are the Wine-lane set: #530 ×2, #676, #890 ×2, gpu_depth_buffer_created_for_unordered_access_is_placed (#1475). Run 1 also had the #718 trio. main in the same setup: 795 / 14 / 22, with 5 device-removed lines (the #1246 cascade through sparse, title_textures and vram).
  • This also explains what I couldn't in #1246. Dropping every object the test made before the VirtualFree didn't help there, because the four ManuallyDrop barrier clones still held the resource, so the imported heap never went away.

Not tested

  • Windows. A retail title (test-only change).
  • Anything that needs game files: no XCL_SAMPLE_* set.

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report; I checked the results.
<!-- greyfinch-sync:ivall/xcl:review:6045798562 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1520#pullrequestreview-6045798562). Originally posted by [crastinator](https://github.com/crastinator) on 2026-11-24T19:20:15Z. **Review:** COMMENTED --- Tested on RDNA2 under Wine (RADV). This also fixes the parallel device removal I traced in #1246: the `VirtualFree` of this test's imported memory while another test's GPU work ran on the shared device. **Tested** (head `6159773`, merged onto `main` `c160d86`: no conflicts) - AMD Radeon RX 6700 XT (RDNA2, gfx1031, RADV NAVI22, Mesa 26.3.1), Ryzen 7 5700X, Linux 7.3.5. Proton Experimental 11.0-20261112's Wine, vkd3d-proton v3.1 + #257's patch (`-Db_ndebug=true`, dxil-spirv `53aac418`), DXVK v3.1.1-209 `dxgi`, DXC 1.9.2609.5. Cross-built for `x86_64-pc-windows-msvc`, Rust 1.99.1, debug. - The #1246 pair, `--test-threads=2 --exact gpu::recomp::tests::jumps_to_outer_loop_heads_are_structured hle::d3d12x::list_x::tests::write_buffer_immediate_on_open_existing_heap_visible_to_cpu`: `main` fails 3/3 (`kernel dispatch: D3D12 device removed` after ~0.15 s). With this PR it passes 3/3. - `cargo test -p xcl --lib -- --test-threads=4`, 2 runs: 801 / 9 / 22 and 804 / 6 / 22 (passed / failed / ignored), no device removal. The 6 are the Wine-lane set: #530 ×2, #676, #890 ×2, `gpu_depth_buffer_created_for_unordered_access_is_placed` (#1475). Run 1 also had the #718 trio. `main` in the same setup: 795 / 14 / 22, with 5 device-removed lines (the #1246 cascade through `sparse`, `title_textures` and `vram`). - This also explains what I couldn't in #1246. Dropping every object the test made before the `VirtualFree` didn't help there, because the four `ManuallyDrop` barrier clones still held the resource, so the imported heap never went away. **Not tested** - Windows. A retail title (test-only change). - Anything that needs game files: no `XCL_SAMPLE_*` set. **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report; I checked the results.
Toons29 commented 2026-11-25 04:10:33 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Toons29 on 2026-11-25T03:32:45Z.


Regression run of 6159773d on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 4178e888, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: 6159773d93e826b4c328ad7174334c7a12c75541
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1629 (PresentX 1629)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14816 MB

Against the limits in CONTRIBUTING.md: 101 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; I checked the blocks before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7152014203 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1520#issuecomment-7152014203). Originally posted by [Toons29](https://github.com/Toons29) on 2026-11-25T03:32:45Z. --- Regression run of `6159773d` on the retail title, for this PR's **Regression run** section. Both blocks are from `scripts/smoke.ps1` as printed, not edited: `main` on `4178e888`, this PR on its head commit with no uncommitted changes, same title and time. ``` xcl-smoke v1 commit: 4178e888c0b5be50a2887eda45cdb832763b68a4 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1618 (PresentX 1618) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 14831 MB ``` ``` xcl-smoke v1 commit: 6159773d93e826b4c328ad7174334c7a12c75541 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1629 (PresentX 1629) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14816 MB ``` Against the limits in CONTRIBUTING.md: 101 % of `main`'s frames, 100 % of its peak commit, no crash, no device removal. AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, `cargo build --release -p xcl`, 60 s, `XCL_NETWORK=0`. This is a regression check only: it does not show whether the run reaches the code this PR changes. AI use: Claude Code (Claude Opus 5.5) built both trees and ran `scripts/smoke.ps1`; I checked the blocks before posting.
JJAutoCompare commented 2026-11-25 06:05:49 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T05:26:17Z.


Empirical test report (6159773d)

Verified PR #1520 at 6159773d93e826b4c328ad7174334c7a12c75541.

Hardware / environment

  • Windows x64 build 26200 on AMD64 (family 23, model 113, stepping 0). Rust 1.100.0 (0ef1bc386, 2026-11-09). DXC 1.9.2609.5 (01b62ad47). Unoptimized test profile with debug info and incremental compilation disabled.
  • The focused run took the Intel Arc A770 test lock with XCL_ADAPTER=A770 and RUST_TEST_NOCAPTURE=1. The imported-heap fixture creates a device on the Windows default D3D12 adapter, with WARP as a fallback. It does not read XCL_ADAPTER or log the resulting device, so the adapter and driver used by that fixture were unverified.

Commands and results

  • cargo test --workspace --no-run exited 0 outside the GPU lock.
  • Ran the prebuilt xcl library test executable under the lock, with these two exact filters. The executable and wrapper both returned exit code 0.
& Invoke-ArcTest.ps1 -Test {
    & $xclLibTest --exact `
        hle::d3d12x::list_x::tests::imported_heap_test_barriers_do_not_retain_the_resource `
        hle::d3d12x::list_x::tests::write_buffer_immediate_on_open_existing_heap_visible_to_cpu
}
  • 2 passed, 0 failed, 0 ignored, 0 skipped, and 742 filtered out. The harness reported 0.16 s. Skips were counted from case-sensitive SKIPPED log lines.

Observed behavior

  • The COM reference-count regression passed. The transition barriers left the resource at one reference, and dropping the resource brought the count to zero.
  • The imported-heap fixture passed its CPU readback assertions for DIRECT and COMPUTE writes and the DIRECT copy. Its VirtualFree(..., MEM_RELEASE) assertion also passed after the resource and heap were dropped.

Not tested

The full GPU workspace suite and game smoke runs were omitted.

AI use

Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr1520-focused.log and published.

<!-- greyfinch-sync:ivall/xcl:comment:7153769948 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1520#issuecomment-7153769948). Originally posted by [JJAutoCompare](https://github.com/JJAutoCompare) on 2026-11-25T05:26:17Z. --- ### Empirical test report (6159773d) Verified PR #1520 at `6159773d93e826b4c328ad7174334c7a12c75541`. **Hardware / environment** - Windows x64 build 26200 on AMD64 (family 23, model 113, stepping 0). Rust 1.100.0 (0ef1bc386, 2026-11-09). DXC 1.9.2609.5 (01b62ad47). Unoptimized test profile with debug info and incremental compilation disabled. - The focused run took the Intel Arc A770 test lock with `XCL_ADAPTER=A770` and `RUST_TEST_NOCAPTURE=1`. The imported-heap fixture creates a device on the Windows default D3D12 adapter, with WARP as a fallback. It does not read `XCL_ADAPTER` or log the resulting device, so the adapter and driver used by that fixture were unverified. **Commands and results** - `cargo test --workspace --no-run` exited 0 outside the GPU lock. - Ran the prebuilt xcl library test executable under the lock, with these two exact filters. The executable and wrapper both returned exit code 0. ```powershell & Invoke-ArcTest.ps1 -Test { & $xclLibTest --exact ` hle::d3d12x::list_x::tests::imported_heap_test_barriers_do_not_retain_the_resource ` hle::d3d12x::list_x::tests::write_buffer_immediate_on_open_existing_heap_visible_to_cpu } ``` - 2 passed, 0 failed, 0 ignored, 0 skipped, and 742 filtered out. The harness reported 0.16 s. Skips were counted from case-sensitive `SKIPPED ` log lines. **Observed behavior** - The COM reference-count regression passed. The transition barriers left the resource at one reference, and dropping the resource brought the count to zero. - The imported-heap fixture passed its CPU readback assertions for DIRECT and COMPUTE writes and the DIRECT copy. Its `VirtualFree(..., MEM_RELEASE)` assertion also passed after the resource and heap were dropped. **Not tested** The full GPU workspace suite and game smoke runs were omitted. **AI use** Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against `pr1520-focused.log` and published.
ivall commented 2026-11-25 20:08:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ivall on 2026-11-25T19:32:34Z.


The leak fix is right and worth having (it also explains the device removal of #1246). What holds it is the new VirtualFree assert: it fails at times because another test's work still holds the last Release (Bullet18x: 4 of 25 runs at 16 and 32 threads, 0 of 20 with a bounded retry). #1590 is merged and retries up to 10 s in coherent_buffer_sanitizes_console_flags_and_state; please do the same here. The diff is inside the test module, so the test-only label can be set after that push.

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

<!-- greyfinch-sync:ivall/xcl:comment:7172440984 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1520#issuecomment-7172440984). Originally posted by [ivall](https://github.com/ivall) on 2026-11-25T19:32:34Z. --- The leak fix is right and worth having (it also explains the device removal of #1246). What holds it is the new `VirtualFree` assert: it fails at times because another test's work still holds the last `Release` (Bullet18x: 4 of 25 runs at 16 and 32 threads, 0 of 20 with a bounded retry). #1590 is merged and retries up to 10 s in `coherent_buffer_sanitizes_console_flags_and_state`; please do the same here. The diff is inside the test module, so the `test-only` label can be set after that push. AI use: Claude Code (Claude Opus 5.5) wrote this on the maintainer's behalf.
ClosetPie107 commented 2026-11-28 12:41:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ClosetPie107 on 2026-11-28T12:41:50Z.


Test report on Wine + AMD (the "Not tested" of the reports above): this test's leak is what makes RADV reject a command submission in the lib suite (#3067).

Tested

  • RX 9070 16 GB (RDNA4), Mesa 26.3.1 RADV, Ryzen 5 9600X, CachyOS, Proton Experimental experimental-11.0-20261112, stock vkd3d-proton master 71cae091; debug, x86_64-pc-windows-gnu.
  • Tree: linux/stack 8b7faec7 (main e429936c plus the stack in #3067), once as is and once with this PR's diff to list_x.rs (head 6159773d) applied on top.
  • Without the change, cargo test --locked -p xcl --lib --target x86_64-pc-windows-gnu -- --test-threads=1 --exact hle::d3d12x::list_x::tests::write_buffer_immediate_on_open_existing_heap_visible_to_cpu hle::d3d12x::present::frame_dump_tests::compositor_blends_ui_plane_over_scene_plane:
    • this test passes;
    • the next test's submission gets radv/amdgpu: The CS has been rejected … (-14);
    • the device is removed (0x887a0005).
      I found it by bisecting the suite, and any later GPU test can be the one rejected (a sparse test when the compositor test is skipped). Without the VirtualFree the rejection is gone, so freeing the imported memory while the resource is still held is what triggers it.
  • With the change: the same pair, 2 passed, no rejection; imported_heap_test_barriers_do_not_retain_the_resource passes. The lib suite with --skip gpu:: and the two OOM tests skipped (failed_restore_stops_before_importing_an_unbacked_window, grooming_leaves_a_window_under_1_gib_only_its_hole): no CS rejection at --test-threads=1 or 2 (646 passed / 2 failed and 729 / 4). Both runs still end early at an access violation in vkd3d-proton's ExecuteCommandLists in a title_textures test. That is another issue (#3067), and that test crashes alone too (run without this PR, which does not touch it).

Not tested

  • Windows, NVIDIA, release build; Bullet18x's retry suggestion (I applied the head as is); more than one run of each.

AI use: Claude Code (Claude Opus 5.5) ran the tests and the bisection on my machine and wrote this; I checked each point.

<!-- greyfinch-sync:ivall/xcl:comment:7239404668 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1520#issuecomment-7239404668). Originally posted by [ClosetPie107](https://github.com/ClosetPie107) on 2026-11-28T12:41:50Z. --- Test report on Wine + AMD (the "Not tested" of the reports above): this test's leak is what makes RADV reject a command submission in the lib suite (#3067). **Tested** - RX 9070 16 GB (RDNA4), Mesa 26.3.1 RADV, Ryzen 5 9600X, CachyOS, Proton Experimental `experimental-11.0-20261112`, stock vkd3d-proton `master` `71cae091`; debug, `x86_64-pc-windows-gnu`. - Tree: `linux/stack` `8b7faec7` (`main` `e429936c` plus the stack in #3067), once as is and once with this PR's diff to `list_x.rs` (head `6159773d`) applied on top. - Without the change, `cargo test --locked -p xcl --lib --target x86_64-pc-windows-gnu -- --test-threads=1 --exact hle::d3d12x::list_x::tests::write_buffer_immediate_on_open_existing_heap_visible_to_cpu hle::d3d12x::present::frame_dump_tests::compositor_blends_ui_plane_over_scene_plane`: - this test passes; - the next test's submission gets `radv/amdgpu: The CS has been rejected … (-14)`; - the device is removed (`0x887a0005`). I found it by bisecting the suite, and any later GPU test can be the one rejected (a `sparse` test when the compositor test is skipped). Without the `VirtualFree` the rejection is gone, so freeing the imported memory while the resource is still held is what triggers it. - With the change: the same pair, 2 passed, no rejection; `imported_heap_test_barriers_do_not_retain_the_resource` passes. The lib suite with `--skip gpu::` and the two OOM tests skipped (`failed_restore_stops_before_importing_an_unbacked_window`, `grooming_leaves_a_window_under_1_gib_only_its_hole`): no CS rejection at `--test-threads=1` or `2` (646 passed / 2 failed and 729 / 4). Both runs still end early at an access violation in vkd3d-proton's `ExecuteCommandLists` in a `title_textures` test. That is another issue (#3067), and that test crashes alone too (run without this PR, which does not touch it). **Not tested** - Windows, NVIDIA, release build; Bullet18x's retry suggestion (I applied the head as is); more than one run of each. AI use: Claude Code (Claude Opus 5.5) ran the tests and the bisection on my machine and wrote this; I checked each point.
SlopTart commented 2026-11-28 16:23:33 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-28T16:23:33Z.


Second hardware confirmation, on RDNA3 this time. rig1: RX 7900 XT 20 GB (Navi 31), Ryzen 9 9900X, 96 GB, Arch, Mesa 26.2.5 RADV, wine 11.0 (proton build), --test-threads=2 --skip gpu::.

Without #1520, both current heads crash the suite on rig1:

  • main bb9a6b4b: exit 5, 577 ok, radv/amdgpu: The CS has been rejected (-14) then D3D12 device removed: 0x887a0005, last ok a real::queue_tests::newer_layout... neighbor.
  • linux/stack 0e1e766c: exit 5, 305 ok, same -14 rejection, drop site elsewhere (the site moves, matching ClosetPie107's poisoning explanation).

With #1520 merged locally (6159773d, merges applied clean at both heads: 51f9d74a and 159bc2b1), both complete:

  • main bb9a6b4b + #1520: 1213 passed / 6 failed / 5 ignored in 15.6 s
  • stack 0e1e766c + #1520: 1256 passed / 6 failed / 5 ignored in 15.8 s

The 6 reds, identical on both heads: gpu_promoted_uav_clear_values_pass_create_committed_resource, a_dispatch_with_a_pipeline_still_building_waits_at_the_submit, a_put_off_call_whose_close_fails_is_not_submitted, an_older_process_cannot_remove_a_replacement_blob, grooming_leaves_a_window_under_1_gib_only_its_hole, xma2_source_voice_decodes_and_manages_lifetime. That is rig2's (GTX 1070) veteran set minus write_buffer_immediate_on_open_existing_heap_visible_to_cpu (fixed here by exactly this PR) and minus failed_restore_stops_before_importing_an_unbacked_window (passed in this completed run; note it is still flaky solo on Wine - see my retraction row on #3067, child re-reserve race, not this PR's business).

So #1520 kills the suite poison on RDNA3 and RDNA4 under Wine, and it is the only thing standing between rig1 lanes and a completed suite count. Please merge it; every AMD/Wine tester is eating a fake crash without it.

Tested: both suites above, at the merged shas named, rig1.
Not tested: native Windows, NVIDIA with this merge (rig2's crash history is different), the flaky solo.
AI use: Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7242207138 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1520#issuecomment-7242207138). Originally posted by [SlopTart](https://github.com/SlopTart) on 2026-11-28T16:23:33Z. --- Second hardware confirmation, on RDNA3 this time. rig1: RX 7900 XT 20 GB (Navi 31), Ryzen 9 9900X, 96 GB, Arch, Mesa 26.2.5 RADV, wine 11.0 (proton build), `--test-threads=2 --skip gpu::`. **Without #1520, both current heads crash the suite on rig1:** - `main` `bb9a6b4b`: exit 5, 577 ok, `radv/amdgpu: The CS has been rejected (-14)` then `D3D12 device removed: 0x887a0005`, last ok a `real::queue_tests::newer_layout...` neighbor. - `linux/stack` `0e1e766c`: exit 5, 305 ok, same `-14` rejection, drop site elsewhere (the site moves, matching ClosetPie107's poisoning explanation). **With #1520 merged locally (`6159773d`, merges applied clean at both heads: `51f9d74a` and `159bc2b1`), both complete:** - main `bb9a6b4b` + #1520: **1213 passed / 6 failed / 5 ignored** in 15.6 s - stack `0e1e766c` + #1520: **1256 passed / 6 failed / 5 ignored** in 15.8 s The 6 reds, identical on both heads: `gpu_promoted_uav_clear_values_pass_create_committed_resource`, `a_dispatch_with_a_pipeline_still_building_waits_at_the_submit`, `a_put_off_call_whose_close_fails_is_not_submitted`, `an_older_process_cannot_remove_a_replacement_blob`, `grooming_leaves_a_window_under_1_gib_only_its_hole`, `xma2_source_voice_decodes_and_manages_lifetime`. That is rig2's (GTX 1070) veteran set minus `write_buffer_immediate_on_open_existing_heap_visible_to_cpu` (fixed here by exactly this PR) and minus `failed_restore_stops_before_importing_an_unbacked_window` (passed in this completed run; note it is still flaky solo on Wine - see my retraction row on #3067, child re-reserve race, not this PR's business). So #1520 kills the suite poison on RDNA3 and RDNA4 under Wine, and it is the only thing standing between rig1 lanes and a completed suite count. Please merge it; every AMD/Wine tester is eating a fake crash without it. **Tested:** both suites above, at the merged shas named, rig1. **Not tested:** native Windows, NVIDIA with this merge (rig2's crash history is different), the flaky solo. **AI use:** Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting.
SlopTart commented 2026-11-29 02:15:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-29T02:15:26Z.


Patch suggestion for the VirtualFree assert, verified on Wine + RDNA3.

Ivall's blocker ("fails at times because another test's work still holds the last Release") is the exact mechanism documented in the #1590 line: one device per adapter, other tests adopt it, the last Release of a placed resource waits for known queues, and until then the imported heap pins the pages, VirtualFree failing with ERROR_INVALID_PARAMETER. So the same bounded retry free_imported uses. Applied on top of this PR merged into main fa204595 (merge 4ca5da3b), replacing the assert:

            {
                // Same shape as `free_imported` in the real.rs readback tests (#1590): the last
                // `Release` of a placed resource can be held a few ms past this point while other
                // tests' queue work is in flight, and until it is gone the imported heap pins the
                // pages, so `VirtualFree` fails with ERROR_INVALID_PARAMETER.
                let start = std::time::Instant::now();
                loop {
                    if VirtualFree(mem, 0, MEM_RELEASE) != 0 {
                        break;
                    }
                    if start.elapsed() > std::time::Duration::from_secs(10) {
                        panic!("VirtualFree kept failing 10 s after the held release should be gone");
                    }
                    std::thread::sleep(std::time::Duration::from_millis(1));
                }
            }

rig1 (RX 7900 XT, Mesa 26.2.5 RADV, wine 11.0 proton build), --test-threads=2 --skip gpu:::

  • imported_heap_test_barriers_do_not_retain_the_resource (this PR's new unit test): solo 3/3 green.
  • write_buffer_immediate_on_open_existing_heap_visible_to_cpu with the retry: solo 3/3 green, 0.09-0.10 s each.
  • Full lib suite with the patch: identical behavior to the unpatched merge (crash point unchanged at 841 ok, and that is a different, newer poison unrelated to this PR, logged on #3067).

This also matches my flake data on Wine fixed-address (re)allocation over the same heap (#3067): when a release is racing, it is racing for a bounded time or never, and a retry with a timeout is the right shape on both sides.

Tested: the patch above on merge 4ca5da3b of main fa204595 + 6159773d, rig1 only.
Not tested: Windows, NVIDIA, Bullet18x's 25-run flake repro (0 failures seen in my 3 solo + 1 suite run either way).
AI use: Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7249310754 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1520#issuecomment-7249310754). Originally posted by [SlopTart](https://github.com/SlopTart) on 2026-11-29T02:15:26Z. --- Patch suggestion for the `VirtualFree` assert, verified on Wine + RDNA3. Ivall's blocker ("fails at times because another test's work still holds the last `Release`") is the exact mechanism documented in the #1590 line: one device per adapter, other tests adopt it, the last `Release` of a placed resource waits for known queues, and until then the imported heap pins the pages, `VirtualFree` failing with `ERROR_INVALID_PARAMETER`. So the same bounded retry `free_imported` uses. Applied on top of this PR merged into `main` `fa204595` (merge `4ca5da3b`), replacing the assert: ```rust { // Same shape as `free_imported` in the real.rs readback tests (#1590): the last // `Release` of a placed resource can be held a few ms past this point while other // tests' queue work is in flight, and until it is gone the imported heap pins the // pages, so `VirtualFree` fails with ERROR_INVALID_PARAMETER. let start = std::time::Instant::now(); loop { if VirtualFree(mem, 0, MEM_RELEASE) != 0 { break; } if start.elapsed() > std::time::Duration::from_secs(10) { panic!("VirtualFree kept failing 10 s after the held release should be gone"); } std::thread::sleep(std::time::Duration::from_millis(1)); } } ``` rig1 (RX 7900 XT, Mesa 26.2.5 RADV, wine 11.0 proton build), `--test-threads=2 --skip gpu::`: - `imported_heap_test_barriers_do_not_retain_the_resource` (this PR's new unit test): solo 3/3 green. - `write_buffer_immediate_on_open_existing_heap_visible_to_cpu` with the retry: solo 3/3 green, 0.09-0.10 s each. - Full lib suite with the patch: identical behavior to the unpatched merge (crash point unchanged at 841 ok, and that is a different, newer poison unrelated to this PR, logged on #3067). This also matches my flake data on Wine fixed-address (re)allocation over the same heap (#3067): when a release is racing, it is racing for a bounded time or never, and a retry with a timeout is the right shape on both sides. **Tested:** the patch above on merge `4ca5da3b` of `main` `fa204595` + `6159773d`, rig1 only. **Not tested:** Windows, NVIDIA, Bullet18x's 25-run flake repro (0 failures seen in my 3 solo + 1 suite run either way). **AI use:** Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting.
Royalflamejlh commented 2026-11-30 02:51:23 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-11-30T02:51:23Z.


@wileyGray the PR description check is what keeps this out of the merge queue (#3041): because the diff touches crates/xcl/src, it wants two xcl-smoke blocks under Regression run (this head 6159773d, and a commit of main). The change is inside a test module, so the other way CONTRIBUTING.md gives is a maintainer applying the test-only label. Could you add the blocks or ask for the label? It merges cleanly into main (1c5acde4). The Linux branch in #3067 carries it: without it these four tests leave references that break later tests on RADV.

AI use: Claude Code (Claude Fable 5.2) read the check's log and wrote this.

<!-- greyfinch-sync:ivall/xcl:comment:7267375973 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1520#issuecomment-7267375973). Originally posted by [Royalflamejlh](https://github.com/Royalflamejlh) on 2026-11-30T02:51:23Z. --- @wileyGray the `PR description` check is what keeps this out of the merge queue (#3041): because the diff touches `crates/xcl/src`, it wants two `xcl-smoke` blocks under **Regression run** (this head `6159773d`, and a commit of `main`). The change is inside a test module, so the other way CONTRIBUTING.md gives is a maintainer applying the `test-only` label. Could you add the blocks or ask for the label? It merges cleanly into `main` (`1c5acde4`). The Linux branch in #3067 carries it: without it these four tests leave references that break later tests on RADV. AI use: Claude Code (Claude Fable 5.2) read the check's log and wrote this.
Foniass commented 2026-12-01 05:59:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:59:42Z.


Triage (#1607) – head 6159773

No open or merged PR makes the same change; main's write_buffer_immediate_on_open_existing_heap_visible_to_cpu still clones buf into ManuallyDrop in its four barriers. #1600, #1628 and #1671 are also part of #1487 but fix other flaky tests.
The new imported_heap_test_barriers_do_not_retain_the_resource test checks the test helper heap_test_barrier, not runtime code. The diff is test-only in a runtime file, so the smoke check needs the test-only label.
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:7302358943 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1520#issuecomment-7302358943). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:59:42Z. --- **Triage (#1607)** – head 6159773 No open or merged PR makes the same change; main's write_buffer_immediate_on_open_existing_heap_visible_to_cpu still clones buf into ManuallyDrop in its four barriers. #1600, #1628 and #1671 are also part of #1487 but fix other flaky tests. The new imported_heap_test_barriers_do_not_retain_the_resource test checks the test helper heap_test_barrier, not runtime code. The diff is test-only in a runtime file, so the smoke check needs the test-only label. 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/1520:upstream-pr/1520'
git switch 'upstream-pr/1520'

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/1520'
git switch 'upstream-pr/1520'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1520'
git switch 'upstream-pr/1520'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1520'
git switch 'main'
git merge --squash 'upstream-pr/1520'
git switch 'main'
git merge --ff-only 'upstream-pr/1520'
git switch 'main'
git merge 'upstream-pr/1520'
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!1510
No description provided.