Tests: stop leaking imported heap resource references #1520
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1520
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1520"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@wileyGray on GitHub · 2026-11-24 17:12 UTC · original
wileyGray:codex/test-heap-lifetime→main· +57 −18 · 1 files · 1 commits · openPart of #1487. Four transition barriers in the imported-heap GPU test cloned a resource into
ManuallyDropand 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, checkVirtualFree, and add a CPU-only reference-count regression. All 75 changed lines are inside#[cfg(test)] mod tests.Tested
6159773d93e826b4c328ad7174334c7a12c75541, based on mainb7aa9f3; 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. AllXCL_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.(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.real::readback_routing_tests::coherent_buffer_sanitizes_console_flags_and_statewith two threads: 20 passed, 0 failed, 0 skipped, no access violations or stalls (0.27-0.36 seconds per pair).git diff --checkpassed.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):Full-suite GPU/debug skips:
gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware(no native wave64);uploads_start_from_each_subresources_stateandtest_title_draws_with_a_root_signature_under_the_debug_layer(debug layer unavailable).Regression run
test-onlylabel under CONTRIBUTING.md. The path-based description check otherwise requests retail smoke blocks. No runtime behavior changes.Not tested
AI use
@Bullet18x on GitHub · 2026-11-24 18:25 UTC · original
Test report for head
6159773, with one finding about the newVirtualFreeassert.Tested
XCL_SAMPLE_*unset.imported_heap_test_barriers_do_not_retain_the_resourcepasses. The barriers no longer keep the resource alive.cargo test -p xcl --lib -- --test-threads=32, 10 runs on6159773:write_buffer_immediate_on_open_existing_heap_visible_to_cpufailed or was among the failures in 4 runs. In 1 of those 4 it was the only failure, on the newassert_ne!(VirtualFree(mem, 0, MEM_RELEASE), 0)(left: 0, right: 0). The other 3 also had an access violation (#1523's cause).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)
D3D12CreateDevicereturns the process's one device. Once another test has adopted it,bufis adopted too, and its lastReleasegoes tolate_release::hold. While another test's queue still has work, the resource is held and the imported heap keepsmempinned. So the firstVirtualFreefails with 87, even with the leak fixed.Check
On the combined branch, I let this test retry
VirtualFreefor up to 10 s, the same as #1590 does forcoherent_buffer_sanitizes_console_flags_and_state, and ran it 20 more times at 32 threads. The test failed 0 times. The firstVirtualFreefailed 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:
Not tested
AI use: Claude Code with Claude Opus 5.5 ran the tests, found the cause and wrote this report. I checked each point.
@DavidM1911 on GitHub · 2026-11-24 18:54 UTC · original
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 unmodifiedmain.)Thanks!
@Toons29 on GitHub · 2026-11-25 03:32 UTC · original
Regression run of
6159773don the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainon4178e888, this PR on its head commit with no uncommitted changes, same title and time.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 on GitHub · 2026-11-25 05:26 UTC · original
Empirical test report (
6159773d)Verified PR #1520 at
6159773d93e826b4c328ad7174334c7a12c75541.Hardware / environment
XCL_ADAPTER=A770andRUST_TEST_NOCAPTURE=1. The imported-heap fixture creates a device on the Windows default D3D12 adapter, with WARP as a fallback. It does not readXCL_ADAPTERor log the resulting device, so the adapter and driver used by that fixture were unverified.Commands and results
cargo test --workspace --no-runexited 0 outside the GPU lock.SKIPPEDlog lines.Observed behavior
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.logand published.@ivall on GitHub · 2026-11-25 19:32 UTC · original
The leak fix is right and worth having (it also explains the device removal of #1246). What holds it is the new
VirtualFreeassert: it fails at times because another test's work still holds the lastRelease(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 incoherent_buffer_sanitizes_console_flags_and_state; please do the same here. The diff is inside the test module, so thetest-onlylabel can be set after that push.AI use: Claude Code (Claude Opus 5.5) wrote this on the maintainer's behalf.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.