D3D12.X: unpin retired split segments from alloc_pool and guard title_list::release ABA #1443
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1453"
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 b3IKK on 2026-11-24T16:19:44Z.
Fixes two lifecycle bugs in
title_listsplit segments and wrapper release:title_listsplit onto an extra PC segment and later returned that segment tosparesviaResetorKickoffX,alloc_pool::forget_listwas never called on the retired segment. The segment stayed pinned in its backing allocator'susersset indefinitely, preventing reuse of that backing allocator and leaking new PCID3D12CommandAllocators on subsequentResets.title_list::release, afterf(pc)freed the primary PC command list,WRAPPER_OF.remove(&pc)andbind::forget(pc)ran unconditionally. If another thread created a new command list that reused the freedpcheap address in the window afterf(pc), the old wrapper's cleanup detached the new wrapper and wiped the new list'sbindstate.This calls
alloc_pool::forget_list(list)insidelist_x::clear_segment_state(covering bothtitle_list::resetandKickoffX) and before releasing spare segments; intitle_list::release, it only removesWRAPPER_OFentries still mapped tothisand skips the redundantbind::forget(pc)whenpcwas adopted (already cleaned up insidereal::cl_release).What is in it
crates/xcl/src/hle/d3d12x/list_x.rs: callalloc_pool::forget_list(list)inclear_segment_state.crates/xcl/src/hle/d3d12x/title_list.rs: guardWRAPPER_OFremoval against address reuse, skip redundantbind::forget(pc)for adopted lists, forget spare segments fromalloc_poolbefore release, and add unit testsreset_releases_retired_split_segment_from_alloc_poolandrelease_does_not_remove_reused_pc_from_wrapper_map(both verified failing before the fix).Since the last push: rebased onto
main06c9f55. The conflicts were in the test module (main'snewer_layout_slot_139_resets_primary_and_reclaims_split_segmentsandslot_139_keeps_the_title_caller_for_the_backing_layout_guard, both kept) and inrelease's loop, wheremainiteratesextra_active,sparesandfirst: the PR's ABA guard now applies to all three.Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1).\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 1267 passed, 0 failed, 46 ignored (SKIPPED: the wave64 / direct-DXIL per-lane tests that need 64-lane hardware or a semantics mode this adapter refuses,no heap windows, andcannot disable the driver cache (Windows Developer Mode is required))cargo test -p xcl --lib title_list: 3 passed, 0 failed (both new tests failed before the fix)Regression run
main (
426a5a7, clean tree, no local changes):PR (
0bfea00, clean tree, no local changes):(The main block is
426a5a7, an ancestor of the currentmain, from the same machine and data folder.)Not tested
AI use
main06c9f55, resolved the conflicts, ran the suite and thescripts/smoke.ps1pair at the head above.Imported from ivall/xcl. Originally posted by crosettiremi on 2026-11-24T16:39:42Z.
Tested the change at
d827520on Windows with an RX 7900 XT, on a downstream XCL stack that includes #1422 and a local direct texture upload change. Both split-segment tests and the existing in-flight allocator lifetime test passed individually. The release build passed.I ran one game comparison per build with the same saved Series X profile, separate copies of the same populated DXIL/PSO caches, two DXC workers, a 28 GiB whole-job limit, and the same scripted Player1 selection at 33 s.
With the patch, at 256 allocator replacements the runtime logged 197 created and 197 put aside. The warm control ended before that counter appeared. An earlier run with the control executable and different cache history reached 256 replacements with 184 put aside. These counts include in-flight work and do not isolate a leak. The later run still had a dark captured frame. I could not verify a visible world or player control. One run per variant does not establish a timing improvement.
Imported from ivall/xcl. Originally posted by LocranKing on 2026-11-24T16:55:26Z.
Independent Windows 11 + NVIDIA GeForce RTX 3060 Ti (8 GB) test report for
d827520e3d4741137e4b569fde77e415024cb186.Tested
d827520e3d4741137e4b569fde77e415024cb186(clean tree, merge-baseb7aa9f3)8024 MiB VRAM, driver32.0.16.2101),rustc 1.100.0(x86_64-pc-windows-msvc, MSVC14.44.35207), DXC1.9.2602.17(SDK10.0.26100.0),--releasecargo build --release --workspace: ok (exit 0)cargo test --workspace --release --no-fail-fast -- --test-threads=4: 772 passed, 0 failed, 41 ignored, exit0hle::d3d12x::title_list::tests::reset_releases_retired_split_segment_from_alloc_pool,hle::d3d12x::title_list::tests::release_does_not_remove_reused_pc_from_wrapper_mapSKIPPED(no wave64):gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardwareRegression run
mainbaseline (b7aa9f3bd212088e0d927439284dc5ed325ce3c7):PR head (
d827520e3d4741137e4b569fde77e415024cb186):Not tested: debug build,
XCL_SAMPLE_*tests on this branch, AMD / native wave64 hardware, extended gameplay sessions past 60 s.AI use: Antigravity (
Gemini 4 Hydrogen) ran the build, tests, and smoke runs and drafted this report from the command outputs.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T18:52:48Z.
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!
Imported from ivall/xcl. Originally posted by SergeAx on 2026-11-26T03:11:24Z.
Test report: #1453's diff (head
0bfea00) applied ontomainb49be183, measured on the parallel-only failure oflist_x::tests::a_dispatch_with_a_pipeline_still_building_waits_at_the_submitreported in #42.That failure is the second bug this PR fixes. In a failing run on
main, an instrumentedbind::forgetremoved the dispatch test's stand-in state (pso == 0x7E57_D001) on the thread ofa_reset_while_the_last_submit_runs_records_on_another_pc_list, fromtitle_list::release'sbind::forget(pc). A split segment the dispatch test had just made had the address of the reset test's freed primary list.bind::dispatchthen saw no pending pipeline and stopped splitting (273, 289, 301 or 5 segments instead of 421).Tested
--test-threads=4 hle::d3d12x::list_x, the builds alternating run by run: the dispatch test failed in 13 of 200 runs onmainand in 0 of 400 with this PR.list_xtest could not create a queue or allocator (E_OUTOFMEMORY,0x8007000E). The same error came on a build without this PR too (mainplus another change);mainitself had 1 other failure in 200 runs, output not kept.Not tested
real::cl_releasestill forgets a list after the runtime frees it (the same order, with a shorter window); that is not this PR's to fix.AI use: Claude Code (Claude Opus 5.5) found the cause, ran the measurements and wrote this report.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T05:27:32Z.
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
Imported from ivall/xcl. Originally posted by sage-sage on 2026-11-26T07:40:24Z.
Test report: passes on NVIDIA merged onto current
main, and with #2691 the dispatch flake from #2690 did not show in 300 parallel runs. Head0bfea00emerged locally ontomainb49be18(clean, merge289952d).Tested
cargo test --workspace -- --test-threads=4onmain+ this PR: 1437 passed, 0 failed, 47 ignored; onmain+ #2691 + this PR: 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
main); this PR without #2691 under the stress run; no game; AMD / Intel.Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
Imported from ivall/xcl. Originally posted by KDenKC on 2026-11-26T08:18:07Z.
Source review of
0bfea00e, no run yet. Two things:1. The spare pool's in-flight check may lose its data. This PR adds
alloc_pool::forget_list(list)tolist_x::clear_segment_state(list_x.rs:857).title_list::resetcalls that for every segment it has just moved tob.spares(title_list.rs:~185-196).forget_listremoves the segment'slast_submit(alloc_pool.rs:92), and with it itsrecordingsand its entry in the backing'susers. But a title may reset a list while its last submission still runs, andpop_sparedecides reuse withalloc_pool::in_flight(p)(title_list.rs:285), which reads that samelast_submit. So a retired segment still on the GPU now looks idle and can be taken and reset at once. That is the case the check is there for. Keepinglast_submit(and the recordings) until the segment is really released or done, and clearing only the list's own state here, would keep the guard working.2. Our flake looks like yours. On an AMD iGPU (RDNA2, Ryzen 7 9800X3D), with the
list_xfixtures pointed at it,a_dispatch_with_a_pipeline_still_building_waits_at_the_submitfailed once in 6 parallel runs. The skipped dispatches showed pipeline0x0instead of the stand-in, and it gave 317 segments instead of 421. The standalone and serial runs passed. That matches what you describe (273/289/301 instead of 421). We'll runmain, #2691, this PR, and both together, 50 times each on that iGPU, and post the counts here.AI use: Gemini (Antigravity) found point 1 in a review; Claude Code (Claude Opus 5.5) checked it against
0bfea00eandmainand wrote this.Imported from ivall/xcl. Originally posted by KDenKC on 2026-11-26T09:12:07Z.
The repetition counts promised in 7186429674: this PR removes the flake on our AMD iGPU.
AMD Radeon integrated graphics (RDNA2) of a Ryzen 7 9800X3D, Windows 11, debug,
XCL_ADAPTER=amdwith a test-only fixture change so thelist_xdevices honour it (the fixture printed the AMD adapter on every run),cargo test -p xcl --lib list_x -- --test-threads=4. Up to 50 runs per arm; an arm stopped at its third failure.mainb49be18008fc961)0bfea00e)Every failure was
a_dispatch_with_a_pipeline_still_building_waits_at_the_submit, withDispatch with a pipeline that has no translated console shader (0x0) skipped: the stand-in's state was gone, as you describe. The two PRs merge cleanly together.Point 1 of my earlier comment (the spare pool's
last_submit) still stands. These tests don't reach it.Not tested: NVIDIA (never seen to fail there, 0 of 11 earlier runs); a title.
AI use: Claude Code (Claude Opus 5.5) ran the arms and wrote this.
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-26T16:03:49Z.
Focused follow-up on head
0bfea00e: I reproduced the retired-stand-in fence issue from the earlier review through the actual wrapper spare path.I extended the existing
a_reset_while_the_last_submit_runs_records_on_another_pc_listtest. While the queue was held behind its fence, the second stand-in had been moved tospares. At that pointin_flight(second[0])was false andpop_spare(w)returned a pending list. The test restores that pointer before releasing the gate, so it never resubmits a busy list. With #1071'srelease_recordingbehavior substituted locally forclear_segment_state'sforget_list, the same test passed. That helper removes the backing pin while retaining the submit record used by the spare check.On Windows 11 build 26300, RTX 3080 Ti / driver 621.35, Ryzen 7 9800X3D, rustc 1.99.1 MSVC,
cargo test --offline --locked -p xcl --lib a_reset_while_the_last_submit_runs_records_on_another_pc_list -- --test-threads=1: 0 passed, 1 failed with only the added assertions on #1453; 1 passed, 0 failed with the retirement change and #1071's small helper. No skips in either run. No full suite or retail run on this combined, uncommitted experiment.The production correction already exists in #1071, so I suggest coordinating that shared change rather than implementing it twice. The test below adds end-to-end coverage of
title_list::reset→ spare selection for both wrapper layouts; #1071's current test checksrelease_recordingdirectly.Focused regression diff against #1453
AI use: Codex (GPT-6.2 Sol) inspected the paths, wrote and ran the regression, checked both outcomes, and drafted this comment. Codex (GPT-6.2 Astra) independently reviewed the lifecycle and located the overlapping #1071 fix.
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-26T15:57:56Z.
NVIDIA test report for
0bfea00: RTX 3070 8 GB (Ampere, driver 616.56), Windows 11 26100, Rust 1.100.0, debug.cargo test -p xcl --lib -- --skip hle::xaudio2 --test-threads=4on the head as it is (on06c9f55, not merged withmain): 1189 passed, 0 failed, 26 ignored; all 5title_listand 34list_xtests ok. 25 SKIPPED: 21no wave64, 3 wave32 per-lane forms the translator refuses (#1426), 1pso_measurement_compiles_an_exact_synthetic_recordwithout Developer Mode. None is in this PR's files.reset_releases_retired_split_segment_from_alloc_poolandrelease_does_not_remove_reused_pc_from_wrapper_map,--exact --test-threads=1 --nocapture, 3 runs each: 6/6 passed, 0 SKIPPED.Lib tests only; no title run. Not tested: the spare-pool
last_submitcase from KDenKC's review.AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-26T23:44:12Z.
Independent desktop NVIDIA verification of PR #1453 at head
0bfea00ee34df738436dbf2d2f098b6c36f2ed1e(1commit; exact parent & merge-base:06c9f5505f63f10c5ec49ef932d75b2c28177324, 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 (
0bfea00e)cargo test --release -p xcl --lib reset_releases_retired_split_segment_from_alloc_pool -- --nocapture1 passed; 0 failed; 0 ignored; 1223 filtered out(0.02s)cargo test --release -p xcl --lib release_does_not_remove_reused_pc_from_wrapper_map -- --nocapture1 passed; 0 failed; 0 ignored; 1223 filtered out(0.02s)cargo test --release -p xcl --lib hle::d3d12x::title_list:: -- --test-threads=4(3 consecutive runs)5 passed; 0 failed; 0 ignored; 1219 filtered out× 3 (0.02s,0.02s,0.02s)cargo test --release -p xcl --lib hle::d3d12x::list_x:: -- --test-threads=1(3 consecutive runs)34 passed; 0 failed; 0 ignored; 1190 filtered out× 3 (0.70s,0.65s,0.64s)cargo test --release -p xcl --lib hle::d3d12x::list_x:: -- --test-threads=4(8 runs on0bfea00evs. 5 runs on unmodified exact parent06c9f550)7/8passed on0bfea00e;4/5passed on unmodified exact parent06c9f550(same pre-existing parallelCreateCommandQueuefailure, see note below)cargo build --release -p xcl --bin xcl1m 06s, exit0)Note on parallel
list_x:: -- --test-threads=4isolation: In1/8parallel runs on0bfea00e,mid_list_write64_wait64_split_avoids_cycle_and_reuses_sparespanicked atCreateCommandQueue(list_x.rs:6731) withHRESULT(0x8007000E)(E_OUTOFMEMORY), cascadingHRESULT(0x887A0005)(DXGI_ERROR_DEVICE_REMOVED) to 3 concurrent GPU tests (rotating_queue_self_deadlock_and_non_monotonic_rescue_do_not_hang,timestamps_outside_unified_memory_land_after_the_queue,cross_queue_wait64_before_signal_does_not_deadlock_submit_thread). Rerunning the exact same command on unmodified parent06c9f5505f63f10c5ec49ef932d75b2c28177324reproduced the exact same 4-testCreateCommandQueue0x887A0005(DXGI_ERROR_DEVICE_REMOVED) failure in1/5runs (list_x.rs:6730/5882). Under--test-threads=1,list_x::passed3/3(34/0/0). This confirms the parallelCreateCommandQueuecontention is pre-existing on06c9f550and not a PR#1453regression.Paired quiet 60 s retail smoke (
title: 29640639)Exact parent & merge-base (
06c9f5505f63f10c5ec49ef932d75b2c28177324, cached baseline on the same machine):PR #1453 (
0bfea00ee34df738436dbf2d2f098b6c36f2ed1e):Runtime log observations (
xcl.log)9205log lines,0[ERROR]/ device-removal / panic lines.19474 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped); last memory sample14427 MB committed by the process; video memory 6115 MB local, 4650 MB non-local; sparse pools 896 MB (838 MB mapped).Limits of coverage
alloc_poolandtitle_list::releaseABA guarding passed via both targeted tests, 3×title_list:: -- --test-threads=4(5/0/0), 3×list_x:: -- --test-threads=1(34/0/0), and the paired 60 s retail smoke (title: 29640639).06c9f550parallelCreateCommandQueuecontention (1/8on PR,1/5on unmodified parent) prevented clean unbounded parallellist_x::stress on this older base.AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).
Imported from ivall/xcl. Originally posted by throny on 2026-11-27T06:08:33Z.
Two contributors checked independently and found that #1071 #2707 #2936 solves the same problem in a different way: #1607, group D147. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.
This is a hint from the community triage in #1607, not a maintainer decision.
AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
Imported from ivall/xcl. Originally posted by throny on 2026-11-28T03:16:36Z.
merge-check claim
head:
0bfea00ee3Imported from ivall/xcl. Originally posted by throny on 2026-11-28T03:30:29Z.
merge-check
base:
753e8b1ahead:
0bfea00ee3merge: clean on
753e8b1a; conflicting on the current mainbuild: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1514 passed, 0 failed, 47 ignored (on
753e8b1a; GitHub now shows the PR as conflicting with the current main) (26 SKIPPED lines); base alone: 1512 passed, 0 failed, 47 ignoredreview: blocking, read in the code and not reproduced: the PR adds alloc_pool::forget_list(list) to list_x::clear_segment_state. On main forget_list also removes the list's last_submit entry, and title_list::pop_spare picks a spare by !alloc_pool::in_flight(p), which reads last_submit. kickoff_x calls clear_segment_state on segments it has just submitted, so once their last_submit is gone pop_spare can hand such a segment out at once and it is recorded and submitted again while the GPU still runs it. #2936 does the same unpin with a function that keeps last_submit, so this PR's first part duplicates #2936 in the unsafe form. The other hunks look right: the wrapper guard against address reuse, and skipping bind::forget for adopted lists. Open from the thread and unexplained: commit grew in a tester's run and in the PR's own smoke pair.
performance: none.
verdict: not yet: drop the clear_segment_state hunk in favour of #2936's park (or merge #2936 first), rebase (it conflicts now); the release hunks could go in alone.
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-28T08:36:49Z.
The primary wrapper-map guard already in #1453 head
0bfea00eis still needed on currentmaine429936c. This is rebase guidance for the existing PR, not a new fix: main has changed around the other hunks, and GitHub currently reports a merge conflict.I copied this PR's
release_does_not_remove_reused_pc_from_wrapper_mapfixture into a local test-only overlay on clean main. It failed 0/1: native Release registered a new wrapper at the same PC address, then the old wrapper's cleanup removed that new mapping. Applying only the existing ownership guard to main passed the same test 1/1;cargo test --offline --locked -j 4 -p xcl --lib hle::d3d12x::title_list::tests -- --test-threads=1passed 9/9, zero skips.git diff --checkpassed. Windows 11 build 26300, RTX 3080 Ti / 621.35, Ryzen 7 9800X3D, rustc 1.99.1 MSVC. This is a synthetic wrapper-lifetime test; it does not exercise the GPU.Minimal guard on current main
The PR's original regression can be retained on rebase. Its old spare-retirement and bind hunks should be reconciled against current main and the separate pending-submission review, rather than applied wholesale. No full workspace suite or title smoke was run on this uncommitted main-based overlay. AI use: Codex (GPT-6.2 Sol) reproduced the issue, tested the scoped guard, and wrote this note.
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-28T22:43:34Z.
Correction to my earlier main-based review: current
mainat7db2f391already has theWRAPPER_OFownership check from04a1768c, including guarded segment removals. The related bind cleanup and recording-retirement paths have also changed. Please treat my suggested diff as superseded and reassess #1453 against current main before applying it.AI use: Codex (GPT-6.2 Sol) checked the current source and drafted this correction.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:49:17Z.
Triage (#1607) – head
0bfea00This change is already on main as commit
04a1768(same subject, same +83/-3 inlist_x.rsandtitle_list.rs, and both testsreset_releases_retired_split_segment_from_alloc_poolandrelease_does_not_remove_reused_pc_from_wrapper_mapare in main'stitle_list.rs). Main has since moved the segment unpinning fromclear_segment_statetoalloc_pool::retire_recording(aa3bc6b4), which the test still covers.Recommendation: close (superseded by main commit
04a1768).AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by throny on 2026-12-01T12:46:19Z.
Closing as superseded: this change is already on
main(04a1768). added/removed lines of the PR diff are byte-identical to those of main commit04a1768(list_x.rs +1, title_list.rs +85/-3)Two independent checks found this: Foniass's close list on #1607 and ours against current
main. If something here is still missing onmain, say so and reopen it, or ask and I will.AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.
Pull request closed