Skip to content

D3D12.X: unpin retired split segments from alloc_pool and guard title_list::release ABA - #1453

Open
b3IKK wants to merge 1 commit into
xcl-dev:mainfrom
b3IKK:d3d12x/title-list-segment-leak-and-aba
Open

b3IKK wants to merge 1 commit into
xcl-dev:mainfrom
b3IKK:d3d12x/title-list-segment-leak-and-aba

Conversation

@b3IKK

@b3IKK b3IKK commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Fixes two lifecycle bugs in title_list split segments and wrapper release:

  • When a title_list split onto an extra PC segment and later returned that segment to spares via Reset or KickoffX, alloc_pool::forget_list was never called on the retired segment. The segment stayed pinned in its backing allocator's users set indefinitely, preventing reuse of that backing allocator and leaking new PC ID3D12CommandAllocators on subsequent Resets.
  • In title_list::release, after f(pc) freed the primary PC command list, WRAPPER_OF.remove(&pc) and bind::forget(pc) ran unconditionally. If another thread created a new command list that reused the freed pc heap address in the window after f(pc), the old wrapper's cleanup detached the new wrapper and wiped the new list's bind state.

This calls alloc_pool::forget_list(list) inside list_x::clear_segment_state (covering both title_list::reset and KickoffX) and before releasing spare segments; in title_list::release, it only removes WRAPPER_OF entries still mapped to this and skips the redundant bind::forget(pc) when pc was adopted (already cleaned up inside real::cl_release).

What is in it

  • crates/xcl/src/hle/d3d12x/list_x.rs: call alloc_pool::forget_list(list) in clear_segment_state.
  • crates/xcl/src/hle/d3d12x/title_list.rs: guard WRAPPER_OF removal against address reuse, skip redundant bind::forget(pc) for adopted lists, forget spare segments from alloc_pool before release, and add unit tests reset_releases_retired_split_segment_from_alloc_pool and release_does_not_remove_reused_pc_from_wrapper_map (both verified failing before the fix).

Tested

  • hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (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): 772 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2 no wave64 — gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware)
  • cargo test -p xcl --lib title_list: 3 passed, 0 failed (both new tests failed before the fix)

Regression run

main:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1226 (PresentX 1226)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15341 MB

PR:

xcl-smoke v1
commit: d827520e3d4741137e4b569fde77e415024cb186
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1640 (PresentX 1641)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14602 MB

Not tested

  • AMD GPUs and native wave64 hardware
  • other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine

AI use

  • OpenCode, Gemini 4 Neon: audited title_list.rs and list_x.rs, wrote the fixes and unit tests, ran the test suite and scripts/smoke.ps1 regression runs, and drafted this PR description.

…_list::release ABA

Two bugs in title_list segment and wrapper lifecycle:
- When a title_list split onto an extra PC segment and later returned
  that segment to `spares` via Reset or KickoffX, `alloc_pool::forget_list`
  was never called on the retired segment. The segment stayed in its
  backing allocator's `users` set indefinitely, preventing that backing
  allocator from being reused and leaking new PC allocators on every Reset.
- In `title_list::release`, after `f(pc)` freed the primary PC list,
  `WRAPPER_OF.remove(&pc)` and `bind::forget(pc)` ran unconditionally.
  If another thread created a new command list that reused the freed `pc`
  address in the window after `f(pc)`, the old wrapper's cleanup detached
  the new wrapper and wiped the new list's bind state.

Call `alloc_pool::forget_list(list)` inside `list_x::clear_segment_state`
(covering both `title_list::reset` and `KickoffX`) and before releasing
spare segments; in `title_list::release`, only remove `WRAPPER_OF` entries
still mapped to `this` and skip redundant `bind::forget(pc)` when `pc` was
adopted (already cleaned up inside `real::cl_release`).

Assisted-by: OpenCode (Gemini 4 Neon)
@crosettiremi

Copy link
Copy Markdown

Tested the change at d827520 on 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.

Last 2 s sample containing a present Terminal event
Without #1453 96.3 s Guest write to address zero at +0x23cf683
With #1453 238.2 s Guest breakpoint at +0x2474606 after 248 s; sampled process commit reached 28,052 MB

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.

@LocranKing

Copy link
Copy Markdown

Independent Windows 11 + NVIDIA GeForce RTX 3060 Ti (8 GB) test report for d827520e3d4741137e4b569fde77e415024cb186.

Tested

  • Commit: d827520e3d4741137e4b569fde77e415024cb186 (clean tree, merge-base b7aa9f3)
  • Hardware / software: Windows 11 Home Build 26200, AMD Ryzen 5 5500, 31.8 GB RAM, NVIDIA GeForce RTX 3060 Ti (8024 MiB VRAM, driver 32.0.16.2101), rustc 1.100.0 (x86_64-pc-windows-msvc, MSVC 14.44.35207), DXC 1.9.2602.17 (SDK 10.0.26100.0), --release
  • cargo build --release --workspace: ok (exit 0)
  • cargo test --workspace --release --no-fail-fast -- --test-threads=4: 772 passed, 0 failed, 41 ignored, exit 0
    • New tests passed: hle::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_map
    • SKIPPED (no wave64): gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware

Regression run
main baseline (b7aa9f3bd212088e0d927439284dc5ed325ce3c7):

xcl-smoke v1
commit: b7aa9f3bd212088e0d927439284dc5ed325ce3c7
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1508 (PresentX 1508)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14730 MB

PR head (d827520e3d4741137e4b569fde77e415024cb186):

xcl-smoke v1
commit: d827520e3d4741137e4b569fde77e415024cb186
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1597 (PresentX 1597)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14706 MB

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.

@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, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

IvyNotFound added a commit to IvyNotFound/xcl that referenced this pull request Nov 25, 2026
# Conflicts:
#	crates/xcl/src/hle/d3d12x/title_list.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants