D3D12.X: forget a command list before the runtime frees it #2681
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2691"
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?
Imported from ivall/xcl. Originally posted by SergeAx on 2026-11-26T06:27:24Z.
Fixes #2690.
real::cl_releasedropped what XCL keeps by a command list's address only after the runtime's finalReleasehad freed the list, so a list created on another thread in between could get the address and lose its bind state, allocator, last submit and DRED marks. Asres_releaseand #2422 do, the last reference (AddRefreturns 2) now forgets the list first. When two last-but-one releases race, both miss it and the list is forgotten after its release, as before.What is in it
crates/xcl/src/hle/d3d12x/real.rs:cl_releaseforgets the list before the runtime's finalRelease(forget_command_list).crates/xcl/src/hle/d3d12x/real.rs(list_release_tests):a_new_list_at_a_released_lists_address_keeps_its_state, a fake list whoseReleasehands its address to a new list at once.Tested
cargo test --workspace --no-fail-fast -- --test-threads=4at008fc961(onmainb49be183), with a retail title running on the same GPU: 1430 passed, 6 failed, 47 ignored. The 6: #1905 (fuzz_validate_and_gpu_0.._3);vram::tests::d32s8_targets_take_their_own_size_of_video_memory(#2588, which #2593 fixes);list_x::tests::a_reset_while_the_last_submit_runs_records_on_another_pc_list(#42, parallel-only; not explained by this change, see #2690).V_MUL_F16,V_PK_MUL_F16,V_CVT_F16_F32);heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windowsmain'scl_release(the new list's bind state is gone) and passes with this change.--test-threads=4 hle::d3d12x::list_x, builds alternating:a_dispatch_with_a_pipeline_still_building_waits_at_the_submitfailed in 13 of 200 runs onmainand 6 of 200 with this change. Most of it istitle_list::release's longer window, which #1453 closes (0 of 400 with #1453, 0 of 400 with both).Regression run
main:
this PR:
Not tested
cl_release: the two conflict there textually (forget_command_listwould take #2138's order)AI use
Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-26T06:50:54Z.
Tested on the Linux/Wine lane, full standard env (AMD rig: Ryzen 9 9900X, 96 GB DDR5, RX 7900 XT 20 GB, Arch kernel 7.2.15, Mesa 26.2.5 RADV, wine-11.0 Proton, rustc 1.94.0;
d3d12,d3d12core,dxgi,d3d11,d3d10core=n,boverrides, official DXC kit,VKD3D_CONFIG=ignore_shared_fence, threads=2), head008fc961, mergeable against mainb49be183:non-gpu suite (
--skip gpu::): 597 passed, 3 failed, 4 ignored, 733 filtered.The failure set is identical to bare main
b49be183measured on the same rig the same day (596 passed, 3 failed): gpu_promoted_uav_clear (our #2490), xma2_source_voice (#2481, vendored-FAudio gate). The third red, the sparse tile video-memory test, is a known batch flake (green solo).Zero delta from this PR; every test it adds passes inside the suite.
Not tested: gpu suite, Windows native.
Correction: an earlier version of this row reported three extra reds; those runs lacked the
d3d12,d3d12core=n,bDLL overrides and hit stub-DLL NOTIMPL artifacts. Re-ran with the standard env, artifacts gone.AI use: Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting.
Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T07:09:18Z.
RX 6800M verification at exact PR head
008fc9618549088436a454a2247bfd4d62aeb5ccagainst current mainb49be1836844fe0b0cdb3211dce3cb7fb4e21ac7(Windows 11, AMD driver30.0.13002.13003, Rust 1.99.0 MSVC):cargo test --locked -p xcl --lib -j 1 hle::d3d12x::real::list_release_tests::a_new_list_at_a_released_lists_address_keeps_its_state -- --exact --test-threads=1 --nocapture: 1 passed, 0 failed, 0 ignored, 1,336 filtered. This is the synthetic pointer-reuse fixture.cargo build --locked --release -p xcl -j 1: passed; head executable SHA-256D81895D827BCDFEEAB5C971FAADC03D381C521690D74C7C40E36AFC948BD8F81.scripts/smoke.ps1 -Seconds 12,XCL_ADAPTER=6800M, and separate data/DXIL cache directories, on the same locally owned title build (hash2ef5fd64):b49be183008fc9610x00x0I attempted a longer 60-second clean-main control. A separate low-memory monitor stopped that control after about 22 seconds when available commit fell to 1,015 MB, so there is no comparable 60-second result. These short runs show startup and presentation; they do not trigger the command-list address-reuse race or establish world-load/performance behavior. I did not run the full workspace suite on this head. AI-assisted test report with Codex.
Imported from ivall/xcl. Originally posted by sage-sage on 2026-11-26T07:40:23Z.
Test report: passes on NVIDIA, and with #1453 the dispatch flake from #2690 did not show in 300 parallel runs. Exact head
008fc961(its base is currentmainb49be18, so head = merged).Tested
cargo test --workspace -- --test-threads=4on this head: 1436 passed, 0 failed, 47 ignored; onmain+ #2691 + #1453: 1438 passed, 0 failed, 47 ignoredmainon this machine (wave64, debug layer, Developer Mode, heap windows)main+ #2691 + #1453 merged locally (fc8561d), the lib test binary withhle:: --test-threads=12, 300 runs:a_dispatch_with_a_pipeline_still_building_waits_at_the_submitfailed 0 times. Onmain(with only a test-only acphal change, #2700) the same setting failed it 32 times in 300 runs. The other failures in the 300 wereacphal::tests::xapu_connect_returns_oom_and_cleans_up_on_failure(5), a test-only flake #2700 fixes.Not tested
Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
Imported from ivall/xcl. Originally posted by KDenKC on 2026-11-26T09:12:09Z.
A data point from our AMD iGPU (RDNA2),
list_xwith--test-threads=4. The flakya_dispatch_with_a_pipeline_still_building_waits_at_the_submit(stand-in lost,0x0skipped) failed 3 of 5 runs onmain, 3 of 11 with this PR alone, 0 of 50 with #1453, and 0 of 50 with both. So on this fixture the remaining failures come from thetitle_listpath #1453 fixes. The two merge cleanly together. Details are in #1453: https://github.com/xcl-dev/xcl/pull/1453AI use: Claude Code (Claude Opus 5.5) ran the arms and wrote this.
Imported from ivall/xcl. Originally posted by KDenKC on 2026-11-26T16:23:18Z.
@SergeAx a small suggestion for the concurrent-release case that the description leaves open, in case it is useful.
On
008fc961, two releases that race can both miss the last-reference probe and take the late cleanup path. That path removesbind::STATESby address after the nativeRelease, so it can remove the state of a new list that already reuses the address. The patch below:Release;Scope is the binding state only.
LISTS, allocator associations and DRED keep this PR's cleanup.Test: a GPU-free fake final release that checks a replacement at the same address, an absent old entry, and ordinary final cleanup. On
008fc961it fails (the replacement's state is erased); with the patch both release tests pass (2/2). About 70 changed lines on008fc961.Not tested: a full suite or a title run with the patch.
patch on
008fc961AI use: Codex (GPT-6.2-Sol) wrote the patch and test and ran them. Claude Code (Claude Opus 5.5) reviewed it and wrote this.
Imported from ivall/xcl. Originally posted by SergeAx on 2026-11-26T18:48:41Z.
@KDenKC thanks, the generation check is right for what it covers. I read it against
008fc961: every place that starts a list's bind state (reset,inherit_for_splitand the first insert inwith) takes a fresh generation, so a list made at the address in the window keeps its state.I'd still keep it out of this PR:
bind::STATESonly. The same late path also drops the list'salloc_poolentries (throughlist_x::on_release) and its DRED marks by address. A fix of that window should guard all three the same way, and that is a second change, of about the same size again.If you want to take it on, a follow-up PR stacked on this one, with your test and the guard for all three, is the way I'd go; I'd test it here.
AI use: Claude Code (Claude Opus 5.5) checked the patch against the code and wrote this reply.
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-26T20:44:14Z.
Independent desktop NVIDIA verification of PR #2691 at head
008fc9618549088436a454a2247bfd4d62aeb5cc(1commit; exact parent & merge-base:b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7, pre-#2555ancestor ofmain).Environment
7956 MiBreported by D3D12), driver32.0.16.2114(NVIDIA621.14, WDDM 3.2)31.9 GiBusable), Windows 11 Home26200(Developer Mode off)rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, DXC1.9.2609.5,--releaseTargeted release tests & build (
008fc961)cargo test --release -p xcl --lib a_new_list_at_a_released_lists_address_keeps_its_state -- --nocapture1 passed; 0 failed; 0 ignored; 1336 filtered out(0.00s)cargo test --release -p xcl --lib hle::d3d12x::real:: -- --test-threads=4(3 consecutive runs)61 passed; 0 failed; 0 ignored; 1276 filtered out× 3 (0.72s,0.70s,0.66s)cargo test --release -p xcl --lib hle::d3d12x::list_x:: -- --test-threads=4(3 consecutive runs)40 passed; 0 failed; 0 ignored; 1297 filtered out× 3 (0.62s,0.62s,0.61s;a_dispatch_with_a_pipeline_still_building_waits_at_the_submitpassed3/3)cargo build --release -p xcl --bin xcl1m 11s, exit0)Paired quiet 60 s retail smoke (
title: 29640639)Exact parent & merge-base (
b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7, cached baseline on the same machine):PR #2691 (
008fc9618549088436a454a2247bfd4d62aeb5cc):Runtime log observations (
xcl.log)9219log lines,0[ERROR]/ device-removal / panic lines.19507 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped); last memory sample14017 MB committed by the process; video memory 6116 MB local, 4683 MB non-local.Limits of coverage
--test-threads=4) ofhle::d3d12x::real::andhle::d3d12x::list_x::(3/3 clean ona_dispatch_with_a_pipeline_still_building_waits_at_the_submit) alongsidea_new_list_at_a_released_lists_address_keeps_its_stateand a 60 s retail smoke confirms clean behavior and zero regression on RTX 4060, but 3 runs are not a high-iteration statistical flake stress run (the remainingtitle_list::releaserace window noted in the PR description is tracked separately in#1453).1599vs.1518frames) reflects normal single-run startup variance and is not attributed to this PR.AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).
Imported from ivall/xcl. Originally posted by SergeAx on 2026-11-28T06:36:54Z.
This change is on
mainnow as309e3557, which came in with #2959's stack. Its code andlist_release_testsmatch008fc961line for line, and only the commit message was reworded. So I'm closing this PR as merged there. #2690 is fixed by that commit. #2852 makes the same change.Thanks @luckyteagirl, @sage-sage, @KDenKC and @Decodere for the test reports. KDenKC's generation guard for two releases that race is still open, for a stacked follow-up.
Pull request closed