Tests: wait for the late release before freeing the coherent buffer test's heap (#1487) #1590

Manually merged
github merged 1 commit from gh-pr/1590/head into gh-pr/1590/base 2026-11-26 04:58:34 +00:00
Owner

@⁠Bullet18x on GitHub · 2026-11-24 18:01 UTC · original
Bullet18x:tests/coherent-buffer-late-release → main · +10 −1 · 1 files · 1 commits · merged 2026-11-25 19:22 UTC

readback_routing_tests::coherent_buffer_sanitizes_console_flags_and_state fails intermittently in parallel runs on assert_ne!(VirtualFree(mem, 0, MEM_RELEASE), 0) (real.rs:5825). This is the failure #1523 lists as still open. Part of #1487; independent of #1520 and #1523.

Cause: D3D12CreateDevice(None, …) returns the process's one device. When another test has adopted it, the placed buffer this test makes on its imported heap is adopted too, so its last Release goes to late_release::hold. If a queue that another test created still has work, the buffer is held. The heap then pins mem, and VirtualFree fails with 87. This is the documented late_release behaviour (a title waits for its memory), so the test now waits too: it retries VirtualFree for up to 10 s and still asserts that it succeeds.

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs: in readback_routing_tests::coherent_buffer_sanitizes_console_flags_and_state, retry VirtualFree until the held release lets the pages go (10 s limit). Test-only, inside #[cfg(test)].

Tested

  • RTX 5090, driver 32.0.16.2114, Windows 11 Pro 10.0.28000, Rust 1.100.0 MSVC, debug, head 5a7307e on main 9e3831e (the runs below used this exact diff, uncommitted), all XCL_SAMPLE_* unset.
  • Deterministic repro (temporary test, not in the PR): adopt the device, stall a queue on an unsignalled fence, register it with present::note_execute, signal after 200 ms from another thread, and call this test. On main it fails at real.rs:5825:17 (left: 0, right: 0). With this change: 1 passed. The resource was adopted, VirtualFree returned 0 with GetLastError 87 while the queue was stalled, and returned 1 about 10 ms after the signal.
  • main, cargo test -p xcl --lib -- --test-threads=16 ×5 and =32 ×5: one run failed this test, and one run ended with 0xc0000005 (the #1523 cause).
  • This change, same 10 runs: 10/10 with 727 passed, 0 failed, 21 ignored.
  • .\scripts\test.ps1: 776 passed, 0 failed, 41 ignored.
  • SKIPPED: 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).

Regression run

  • Test-only diff inside real.rs's #[cfg(test)] module, with no retail smoke run. Please apply the test-only label after reviewing the diff.

Not tested

  • AMD, Intel, Wine. Release build. No retail title.
  • Ten repetitions do not prove #1487 is fully closed. The access violation from #1523's cause still occurs on main without that PR.
  • list_x's write_buffer_immediate_on_open_existing_heap_visible_to_cpu (as changed in #1520) also frees an imported heap's memory right after release, and may hit the same hold. It is not changed here.

AI use

  • Claude Code with Claude Opus 5.5: reproduced the failure, found the cause, wrote the change, ran the tests and wrote this description. I reviewed the diff and the results.
**@⁠Bullet18x** on GitHub · 2026-11-24 18:01 UTC · [original](https://github.com/xcl-dev/xcl/pull/1590) `Bullet18x:tests/coherent-buffer-late-release` → `main` · +10 −1 · 1 files · 1 commits · merged 2026-11-25 19:22 UTC `readback_routing_tests::coherent_buffer_sanitizes_console_flags_and_state` fails intermittently in parallel runs on `assert_ne!(VirtualFree(mem, 0, MEM_RELEASE), 0)` (real.rs:5825). This is the failure #1523 lists as still open. Part of #1487; independent of #1520 and #1523. Cause: `D3D12CreateDevice(None, …)` returns the process's one device. When another test has adopted it, the placed buffer this test makes on its imported heap is adopted too, so its last `Release` goes to `late_release::hold`. If a queue that another test created still has work, the buffer is held. The heap then pins `mem`, and `VirtualFree` fails with 87. This is the documented `late_release` behaviour (a title waits for its memory), so the test now waits too: it retries `VirtualFree` for up to 10 s and still asserts that it succeeds. **What is in it** - `crates/xcl/src/hle/d3d12x/real.rs`: in `readback_routing_tests::coherent_buffer_sanitizes_console_flags_and_state`, retry `VirtualFree` until the held release lets the pages go (10 s limit). Test-only, inside `#[cfg(test)]`. **Tested** - RTX 5090, driver 32.0.16.2114, Windows 11 Pro 10.0.28000, Rust 1.100.0 MSVC, debug, head 5a7307e on main 9e3831e (the runs below used this exact diff, uncommitted), all `XCL_SAMPLE_*` unset. - Deterministic repro (temporary test, not in the PR): adopt the device, stall a queue on an unsignalled fence, register it with `present::note_execute`, signal after 200 ms from another thread, and call this test. On main it fails at real.rs:5825:17 (`left: 0, right: 0`). With this change: 1 passed. The resource was adopted, `VirtualFree` returned 0 with GetLastError 87 while the queue was stalled, and returned 1 about 10 ms after the signal. - main, `cargo test -p xcl --lib -- --test-threads=16` ×5 and `=32` ×5: one run failed this test, and one run ended with 0xc0000005 (the #1523 cause). - This change, same 10 runs: 10/10 with 727 passed, 0 failed, 21 ignored. - `.\scripts\test.ps1`: 776 passed, 0 failed, 41 ignored. - SKIPPED: `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). **Regression run** - Test-only diff inside `real.rs`'s `#[cfg(test)]` module, with no retail smoke run. Please apply the `test-only` label after reviewing the diff. **Not tested** - AMD, Intel, Wine. Release build. No retail title. - Ten repetitions do not prove #1487 is fully closed. The access violation from #1523's cause still occurs on main without that PR. - `list_x`'s `write_buffer_immediate_on_open_existing_heap_visible_to_cpu` (as changed in #1520) also frees an imported heap's memory right after release, and may hit the same hold. It is not changed here. **AI use** - Claude Code with Claude Opus 5.5: reproduced the failure, found the cause, wrote the change, ran the tests and wrote this description. I reviewed the diff and the results.
D3D12CreateDevice gives every test the process's one device. Once another
test adopted it (gpu_placed_console_depth_target_with_clear_value and
others), the buffer coherent_buffer_sanitizes_console_flags_and_state
places on its imported heap is adopted too, and its last Release goes to
late_release::hold. While a queue of a test running in parallel still has
work, the buffer is held, the heap pins the pages, and VirtualFree fails
with ERROR_INVALID_PARAMETER (87). The test now retries VirtualFree for up
to 10 s and still asserts that it succeeds.

Part of #1487.

Assisted-by: Claude Code (Claude Opus 5.5)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:58:31 +00:00
github manually merged commit 5a7307ed7f into gh-pr/1590/base 2026-11-26 04:58:34 +00:00
Author
Owner

@⁠fladit123 on GitHub · 2026-11-24 18:52 UTC · original

Independent validation of exact HEAD 5a7307ed7f4aa8a262bbe7c5eecae8effb855c13 on NVIDIA Ada Lovelace.

Environment

  • NVIDIA RTX 4060 8 GB, driver 610.88
  • Intel Core i5-12400F, 32 GB RAM
  • Windows 11 Pro build 26300
  • Rust 1.100.0 MSVC, debug
  • XCL_ADAPTER=4060, sample variables unset.

Tested

  • Focused coherent_buffer_sanitizes_console_flags_and_state test: 1 passed, 0 failed.
  • cargo test --locked -p xcl --lib -- --test-threads=4 --show-output: five consecutive runs.
Revision Successful runs Failed runs
Main 9e3831e 20/20 0
PR 5a7307e 5/5 0

All five PR runs reported 727 passed, 0 failed and 21 ignored. Two explicit hardware skips were included in the passed count in each run:

  • gpu_geometry_wave32_prefix_count_over_a_mask: no wave64
  • gpu_wave32_program_in_wave64_hardware: no wave64

The real RTX 4060 backend was confirmed in the first run. The worktree remains clean.

Review: The change is narrowly scoped to test code. The bounded retry preserves the assertion rather than silently accepting a failed VirtualFree.

Limitations: No regressions observed, but the original failure did not reproduce in my baseline runs. I did not independently demonstrate that the retry path was exercised. No retail title tested.

AI use: ChatGPT (GPT-6.2) assisted with code review, test commands and reporting. All tests were executed locally on my hardware.

**@⁠fladit123** on GitHub · 2026-11-24 18:52 UTC · [original](https://github.com/xcl-dev/xcl/pull/1590#issuecomment-7141278420) Independent validation of exact HEAD `5a7307ed7f4aa8a262bbe7c5eecae8effb855c13` on NVIDIA Ada Lovelace. **Environment** - NVIDIA RTX 4060 8 GB, driver 610.88 - Intel Core i5-12400F, 32 GB RAM - Windows 11 Pro build 26300 - Rust 1.100.0 MSVC, debug - `XCL_ADAPTER=4060`, sample variables unset. **Tested** - Focused `coherent_buffer_sanitizes_console_flags_and_state` test: 1 passed, 0 failed. - `cargo test --locked -p xcl --lib -- --test-threads=4 --show-output`: five consecutive runs. | Revision | Successful runs | Failed runs | |---|---:|---:| | Main `9e3831e` | 20/20 | 0 | | PR `5a7307e` | 5/5 | 0 | All five PR runs reported 727 passed, 0 failed and 21 ignored. Two explicit hardware skips were included in the passed count in each run: - `gpu_geometry_wave32_prefix_count_over_a_mask`: no wave64 - `gpu_wave32_program_in_wave64_hardware`: no wave64 The real RTX 4060 backend was confirmed in the first run. The worktree remains clean. **Review:** The change is narrowly scoped to test code. The bounded retry preserves the assertion rather than silently accepting a failed VirtualFree. **Limitations:** No regressions observed, but the original failure did not reproduce in my baseline runs. I did not independently demonstrate that the retry path was exercised. No retail title tested. **AI use:** ChatGPT (GPT-6.2) assisted with code review, test commands and reporting. All tests were executed locally on my hardware.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 20:12 UTC · original

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

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

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 20:12 UTC · [original](https://github.com/xcl-dev/xcl/pull/1590#issuecomment-7143182828) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified `main`.) Thanks!
Author
Owner

@⁠Toons29 on GitHub · 2026-11-24 21:43 UTC · original

Regression run of 5a7307ed 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: 5a7307ed7f4aa8a262bbe7c5eecae8effb855c13
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: 14813 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.

**@⁠Toons29** on GitHub · 2026-11-24 21:43 UTC · [original](https://github.com/xcl-dev/xcl/pull/1590#issuecomment-7145301588) Regression run of `5a7307ed` 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: 5a7307ed7f4aa8a262bbe7c5eecae8effb855c13 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: 14813 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.
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-25 05:14 UTC · original

Empirical test report (5a7307ed)

Hardware / environment

  • Windows 11 Enterprise Evaluation x64 build 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 16 GiB (driver 32.0.101.9175).
  • rustc 1.100.0 (0ef1bc386 2026-11-09)
  • DXC dxcompiler.dll: 1.9(5512-01b62ad4)(1.9.2609.5) - 1.9.2609.5 (01b62ad47)
  • PR #1590 head 5a7307ed7f4aa8a262bbe7c5eecae8effb855c13.

Commands and results

  • cargo test --workspace --no-run exited 0 outside the Arc lock and built the workspace test executables.
  • cargo test -p xcl --lib hle::d3d12x::real::readback_routing_tests::coherent_buffer_sanitizes_console_flags_and_state --no-run exited 0 outside the lock and confirmed that the focused artifact was ready.
  • Inside the Arc lock (Invoke-ArcTest.ps1 -Test), with XCL_ADAPTER=A770 and RUST_TEST_NOCAPTURE=1, the following command exited 0.
cargo test -p xcl --lib hle::d3d12x::real::readback_routing_tests::coherent_buffer_sanitizes_console_flags_and_state -- --exact --nocapture
  • 1 passed, 0 failed, 0 ignored, 0 skipped. The harness reported 747 filtered out and a runtime of 1.88 s. The log contained zero lines beginning with SKIPPED .

Observed behavior

The coherent-buffer fixture passed. DXGI enumeration identified the Intel Arc A770 as adapter 0, which is the default adapter requested by the fixture's direct D3D12 device creation. The fixture emits no retry count, so this run cannot establish whether the first heap release succeeded or a retry was needed.

Not tested

Coverage was limited to workspace test compilation and the single fixture. The full GPU workspace suite, the parallel-test interaction described in #1487, 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 pr1590-focused.log and published.

**@⁠JJAutoCompare** on GitHub · 2026-11-25 05:14 UTC · [original](https://github.com/xcl-dev/xcl/pull/1590#issuecomment-7153584864) ### Empirical test report (5a7307ed) **Hardware / environment** - Windows 11 Enterprise Evaluation x64 build 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 16 GiB (driver 32.0.101.9175). - `rustc 1.100.0 (0ef1bc386 2026-11-09)` - DXC `dxcompiler.dll: 1.9(5512-01b62ad4)(1.9.2609.5) - 1.9.2609.5 (01b62ad47)` - PR #1590 head `5a7307ed7f4aa8a262bbe7c5eecae8effb855c13`. **Commands and results** - `cargo test --workspace --no-run` exited 0 outside the Arc lock and built the workspace test executables. - `cargo test -p xcl --lib hle::d3d12x::real::readback_routing_tests::coherent_buffer_sanitizes_console_flags_and_state --no-run` exited 0 outside the lock and confirmed that the focused artifact was ready. - Inside the Arc lock (`Invoke-ArcTest.ps1 -Test`), with `XCL_ADAPTER=A770` and `RUST_TEST_NOCAPTURE=1`, the following command exited 0. ```powershell cargo test -p xcl --lib hle::d3d12x::real::readback_routing_tests::coherent_buffer_sanitizes_console_flags_and_state -- --exact --nocapture ``` - 1 passed, 0 failed, 0 ignored, 0 skipped. The harness reported 747 filtered out and a runtime of 1.88 s. The log contained zero lines beginning with `SKIPPED `. **Observed behavior** The coherent-buffer fixture passed. DXGI enumeration identified the Intel Arc A770 as adapter 0, which is the default adapter requested by the fixture's direct D3D12 device creation. The fixture emits no retry count, so this run cannot establish whether the first heap release succeeded or a retry was needed. **Not tested** Coverage was limited to workspace test compilation and the single fixture. The full GPU workspace suite, the parallel-test interaction described in #1487, 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 `pr1590-focused.log` and published.
Author
Owner

@⁠ivall on GitHub · 2026-11-25 19:22 UTC · original

Merging: VirtualFree is retried while the held release still pins the pages. main failed here in this test once in 5 runs of hle::d3d12x on 16 threads, with this PR not in 5 (too few to prove it, but it is the failure described).

Tested on AMD RDNA4 (native wave64), Windows, DXC 1.8.2502.11, debug, main 2898511 with 27 test PRs merged locally, this one included: the whole suite 3 times, 1419 passed, 2 failed, 46 ignored each time (fuzz_validate_and_gpu_1 and _3, which fail the same way on main); hle::d3d12x on 16 threads 5 times, no failure.

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

**@⁠ivall** on GitHub · 2026-11-25 19:22 UTC · [original](https://github.com/xcl-dev/xcl/pull/1590#issuecomment-7172213777) Merging: `VirtualFree` is retried while the held release still pins the pages. `main` failed here in this test once in 5 runs of `hle::d3d12x` on 16 threads, with this PR not in 5 (too few to prove it, but it is the failure described). Tested on AMD RDNA4 (native wave64), Windows, DXC 1.8.2502.11, debug, `main` `2898511` with 27 test PRs merged locally, this one included: the whole suite 3 times, 1419 passed, 2 failed, 46 ignored each time (`fuzz_validate_and_gpu_1` and `_3`, which fail the same way on `main`); `hle::d3d12x` on 16 threads 5 times, no failure. AI use: Claude Code (Claude Opus 5.5) reviewed and tested this and wrote the comment on the maintainer's behalf.
This discussion has been locked. Commenting is limited to contributors.
No description provided.