Skip to content

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

Open
Bullet18x wants to merge 1 commit into
xcl-dev:mainfrom
Bullet18x:tests/coherent-buffer-late-release
Open

Bullet18x wants to merge 1 commit into
xcl-dev:mainfrom
Bullet18x:tests/coherent-buffer-late-release

Conversation

@Bullet18x

Copy link
Copy Markdown

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 Tests: the queue slot 18 test signals a fence object that is complete (#1487) #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

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.

…est's heap

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 xcl-dev#1487.

Assisted-by: Claude Code (Claude Opus 5.5)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fladit123

Copy link
Copy Markdown

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.

@DavidM1911

Copy link
Copy Markdown
Contributor

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!

@Toons29

Toons29 commented Nov 24, 2026

Copy link
Copy Markdown

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.

@JJAutoCompare

Copy link
Copy Markdown

Empirical test report (5a7307e)

Hardware / environment

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.

@throny throny added the off-goal Does not bear on the current goal (world loading); waits until it is reached label Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

off-goal Does not bear on the current goal (world loading); waits until it is reached

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants