D3D12.X: a pipeline is forgotten before its address is free #2412
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2422"
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 veyn-sudo on 2026-11-25T18:24:58Z.
pso_releasedrops what XCL keeps of a pipeline by its address (forget_pso) after the driver has freed it. A pipeline that another thread makes in between can get the same address, register itself, and lose its own entries: a translated compute program then counts as untranslated (is_translated_compute) and its dispatches are skipped. Background workers make pipelines while titles release them, so nothing keeps the two apart.Found by reading the code while looking into #2403. I have not seen it happen in a title.
res_releasehas the same question, see #1404 and #1527; the stand-ins ofstandin.rsalready forget first. #2417 changespso_releasetoo, as part of a larger change; withXCL_LATE_RELEASE=0it still forgets after the release.What is in it
crates/xcl/src/hle/d3d12x/real.rs: on the last reference (AddRefsays 2)pso_releaseforgets before it releases. Two threads that release the last two references at once can both miss being the last: then it is forgotten after the release, as before.main(left: Some(true),right: Some(false)).Tested
cargo test --workspace --no-fail-fast -- --test-threads=4on349970c: 1364 passed, 0 failed, 46 ignored.SKIPPEDlines: 21 no wave64, 3 f16 forms refused, 1 no heap windows.Regression run
main:
this PR:
Not tested
AI use
🤖 Generated with Claude Code
https://claude.ai/code/session_01WStEFektfHt5AEbK6Wupac
Imported from ivall/xcl. Originally posted by emirduran707 on 2026-11-25T19:00:11Z.
Independent AMD RDNA4 (native wave64) test report on exact head
836ddedac40e3ef43164a17df941c950c26a3df4(clean detached checkout, no local changes).Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1288 passed, 3 failed, 46 ignored; 8 SKIPPED (6 inlower_dxil::tests::{f16,f32}_programs_on_the_gpurefused by per-lane form;heap_window_out_of_memory_falls_back_to_the_switch_form;pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.hle::d3d12x::real::pso_release_tests::a_pipeline_is_forgotten_before_its_address_is_free.main68a284a:gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1(seed 722) andfuzz_validate_and_gpu_3(seed 1599) on this GPU, plusgpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier(from50a9fde/ #2074).Regression run (60 s retail-title smoke,
XCL_NETWORK=0, release)(Matched
main68a284abaseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)Not tested
AI use
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T19:47:41Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: 1 real failure, deterministic (also fails--test-threads=1, 1219/1):The lowered program is missing an expected group barrier (or emits one where none is expected). Needs a fix before merge.
— Devin
Imported from ivall/xcl. Originally posted by bmjask on 2026-11-25T20:51:19Z.
Review: COMMENTED
P1: pso_release calls the original Release twice: f(this); then let n = f(this). Every caller Release therefore drops two COM references, risking premature pipeline destruction/use-after-free. The new test masks this by starting from two refs; after its first pso_release it sees one rather than proving the expected one-reference decrement. Remove the stray first call and assert exact one-release/one-ref behavior.
Imported from ivall/xcl. Originally posted by veyn-sudo on 2026-11-25T21:04:35Z.
That test was failing on
mainitself then (#2074's, fixed since). On this head (349970c, rebased) the suite is 1364 passed, 0 failed.AI use: Claude Code (Claude Opus 5.5) wrote this.
Imported from ivall/xcl. Originally posted by veyn-sudo on 2026-11-25T21:46:13Z.
The first
Releasebalances theAddRef(add(this)) above it, which is how the count is read. So a call takes off one reference: the test starts with two and sees one after the firstpso_release; two taken off would leave zero.AI use: Claude Code (Claude Opus 5.5) wrote this.
Imported from ivall/xcl. Originally posted by oni-swr on 2026-11-25T22:10:01Z.
Independent AMD report for
349970c0a7ad9d336675e3ea2a93263294c09511.Tested
XCL_ADAPTER=radeon. Exact PR head (not a local merge ontomain); main at the time was6d12f58a.cargo test --workspace --no-fail-fast -j 4 -- --test-threads=4: 1363 passed, 1 failed, 46 ignored. The one failure isgpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1(seed 722:res[30] = 0x1, CPU 0x7fffffff); it fails identically onmain6d12f58aon this adapter (cargo test -p xcl --lib fuzz_validate_and_gpu_1), so it is not caused by this PR.f16_programs_on_the_gpu/f32_programs_on_the_gpuper-lane cases refused forV_MUL_F16,V_PK_MUL_F16orV_CVT_F16_F32, andheap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).real::pso_release_tests::a_pipeline_is_forgotten_before_its_address_is_freepassed.Not tested
scripts/smoke.ps1/ a retail title (no regression run), other adapters, NVIDIA. No game data was used.AI use
Claude Code (Claude Sonnet 5.5) ran the tests and wrote this report. No game files, dumps or shader names are included.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T02:22:12Z.
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 itsSio on 2026-11-26T03:57:45Z.
Independent dual-PC NVIDIA full-workspace test report on clean head
349970c0a7ad9d336675e3ea2a93263294c09511.Tested
32.0.16.1088), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro build 26200,rustc 1.97.0(stable-x86_64-pc-windows-msvc), DXC1.9.2609.5, debug build (XCL_ADAPTER=NVIDIA)cargo build --workspace: exit 0cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1364 passed, 0 failed, 46 ignored (real::pso_release_tests::a_pipeline_is_forgotten_before_its_address_is_freepassed)SKIPPED: 26 (wave64-only GPU tests,#1426wave32 f16/cvt refusals,heap_window_out_of_memory_falls_back_to_the_switch_form,pso_measurement_compiles_an_exact_synthetic_record)32.0.16.1088), AMD Ryzen 5 5600X, 16 GB RAM, Windows 11 Pro build 26200,rustc 1.99.1(stable-x86_64-pc-windows-msvc), Windows SDK 10.0.26100 DXC1.8.2502.11, debug build (XCL_ADAPTER=NVIDIA)cargo build --workspace: exit 0cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1363 passed, 1 failed, 46 ignored (real::pso_release_tests::a_pipeline_is_forgotten_before_its_address_is_freepassed; the sole failure was unrelated intermittentxgameruntime::gamesave::tests::atomic_writes_preserve_xcltmp_blobs_and_skip_leftover_tempsatgamesave.rs:958, which passed 2/3 standalone reruns and 11/11 in thegamesavemodule)SKIPPED: 29 (same 26 as Machine 1 plus 3 requiringd3d12SDKLayers.dll)Not tested
scripts/smoke.ps1runs--release)AI use
Ran via Samaritan:
Imported from ivall/xcl. Originally posted by ClosetPie107 on 2026-11-26T06:49:14Z.
AMD RDNA4 / Linux (Proton Experimental) test report on head
349970c0(merged cleanly ontomainb49be183):Hardware & environment
experimental-11.0-20261112),vkd3d-protonmasterec207194(3.2.0) +dxil-spirvb540c8a2+ relaxed-vtable patch (-Db_ndebug=true), DXVKv3.1.1-209, DXC1.9.2609.5, Rustx86_64-pc-windows-gnuIsolated unit / GPU tests (
mainb49be183+ #2422349970c0, debug,--test-threads=1,WINEDLLOVERRIDES="d3d12,d3d12core=n"):xcl.exe hle::d3d12x::real:: -- --test-threads=1: 61 passed, 0 failed, 0 ignored (0 skipped).Combined 300 s retail sanity run (release,
mainb49be183+ #1540 + #1675 + #1844 + #1899 + #2123 + #2369 + #2422, retail 1.0.2.1 pressingApast menus):exit=0), 0 crashes, 0 device removals,2,014PresentXframes,131,072translated draws,660,943dispatches (44,546chained split-compute dispatches),102,631Opus packets (0 errors).Not tested
AI use
main, ran the Proton unit tests and combined retail run on this machine, and drafted this report.Imported from ivall/xcl. Originally posted by throny on 2026-11-26T16:18:18Z.
Test report: in the world on an RTX 4080 16 GB with
XCL_PSO_WAIT_MS=1. Tested together with #2581; with the two, no device loss in 2 runs against 2 of 2 without.Tested
main; they were ported by hand ontonvidia-devaf2cecc4+ #684 + #2697 + #2749 + #2729 + #2794 + #2817 (stack) + #2768 + #2782 + #2725. #2581:waits_bounded()afterwait_budget()inpso_async.rsand the early return as the first statement ofdeferinlist_x.rs. #2422: the AddRef probe and the forget-before-free order inpso_release(real.rs), keeping that branch'slate_release::hold_pipelinecall.cargo checkand a release build clean; the PRs' tests not run.XCL_PSO_WAIT_MS=1 XCL_GFX_PSO_WAIT_MS=200, world from about 170 s. Four runs, alternating: without, with, with, without.0x887a0005)0xc0000005in title code), no device loss0x887a0005)XCL_PSO_WAIT_MS(see #2688).dispatch with a pipeline still being built put off to the submitis in none of the four logs, also not in the two runs without the PR, andsplit command list … mid-list Waitappears 7–10 times in all four. So on this tree the put-off path was not what ran before the removals; if the fix works here, it is by another route, or the one that matters is #2422.E_OUTOFMEMORY/0x887a0001in any of the four.Not tested
main, their tests and the suite, AMD.AI use: Claude Code (Claude Sonnet 5.5 ported the two diffs, Claude Fable 5.2 ran the runs and wrote this).
Follow-up, same day: at default waits the two PRs do not stop the removal. Three more world runs of the same tree with both PRs and without
XCL_PSO_WAIT_MS: device removed (0x887a0005) in 3 of 3, after 76 s, 334 s and 114 s of world. So the 0 of 2 above is either specific toXCL_PSO_WAIT_MS=1or chance, and the removal this card has on this branch is a different one.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:00:38Z.
Triage (#1607) – head
349970cMain's
real.rs:pso_releasestill callsforget_psoonly afterReleasereturned 0, so the address-reuse race this PR describes is still there. #2417 also movesforget_psoahead of the final release, but only with late release on and as part of a much larger change. This PR is the targeted fix. The test drivespso_releasethrough a fake vtable and checks the state at free time. No problems found in the diff. Main'spso_releasenow also handlespso_manifestgenerations andlate_release::hold_pipeline, so the rebase has to keep those.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.