D3D12.X: fix HEAP_UMA lifetime issue for placed buffers (XCL-BT-001) #2086
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!2086
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2086"
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?
@saurabhbhoir456 on GitHub · 2026-11-25 03:34 UTC · original
saurabhbhoir456:fix/xcl-bt-001-heap-uma-lifetime-v2→main· +103 −26 · 4 files · 4 commits · openWhat changes and why
Fix XCL-BT-001: HEAP_UMA lifetime issue for placed buffers.
When a HEAP_UMA heap was released (refcount reached 0), its backing memory block was freed immediately even if placed buffers still referenced it. This caused memory corruption when the title's last
Releaseof a buffer raced with the heap'sRelease.The fix tracks
live_buffersper HEAP_UMA heap:live_bufferswhen a buffer is placed in a HEAP_UMA heap (2 insertion sites pass a non-zero heap:place_console_bufferandplace_at_title_addressfor heap-allocated buffers)res_release: decrementlive_buffers; if it reaches 0 and the heap was already released (block isSome), free the blockmem_heap_release: iflive_buffers == 0, free block immediately and remove entry; otherwise keep the entry and its block so the last buffer'sReleasecan free itThis defers the block free until all buffers in the heap are released.
Commits:
D3D12.X: fix HEAP_UMA lifetime issue for placed buffers (XCL-BT-001)(crates/xcl/src/hle/d3d12x/real.rs)live_buffers: usizefield toHeapUmastructUmaBuffertype from(usize, usize, bool)to(usize, usize, bool, usize)to store the heap referencelive_buffersres_releaseto decrementlive_buffersand defer block freemem_heap_releaseto defer block free when buffers are still aliveD3D12.X: keep HEAP_UMA block until all placed buffers are released(crates/xcl/src/hle/d3d12x/real.rs)mem_heap_releaseno longer discardse.blockwhen buffers are still alive, sores_releasecan free the block oncelive_buffersreaches zeroWhat is in it
D3D12.X: fix HEAP_UMA lifetime issue for placed buffers (XCL-BT-001)(crates/xcl/src/hle/d3d12x/real.rs)D3D12.X: keep HEAP_UMA block until all placed buffers are released(crates/xcl/src/hle/d3d12x/real.rs)Tested
cargo build --workspace; cargo test --workspace -- --test-threads=4Regression run
scripts/smoke.ps1 -Game <folder>on main and this branch head and paste both xcl-smoke blocks when a title is available.Not tested
AI use
🤖 Generated with Claude Code
@frenziedcoder on GitHub · 2026-11-25 04:23 UTC · original
NVIDIA test report for
697caca: no new test failures (the 4 that fail also fail oncbc296a), no own test to run, and a clean smoke pair on the retail title (1605 vs 1655 frames).Tested
stable-x86_64-pc-windows-msvc, DXC 1.8.2502.11 (SDK 10.0.26100.0). Exact head697cacae7a8ad7e6897dc4d7d7c8a9f00e836014, no local changes.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4(debug): 1150 passed, 4 failed, 46 ignored; the PR adds no test of its own. SKIPPED:gpu::recomp::lower::tests::a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu(no wave64),gpu::recomp::lower::tests::coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu(no wave64),gpu::recomp::lower::tests::cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu(no wave64),gpu::recomp::lower::tests::the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu(no wave64),gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu(no wave64),gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu(const_mask, wave64: no wave64),gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu(f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu(f16 arithmetic, wave64: no wave64),gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu(f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu(f16 packed, wave64: no wave64),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 arithmetic, wave64: no wave64),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 compares, wave64: no wave64),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 conversions, wave64: no wave64),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 rounding, wave64: no wave64),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 three-source, wave64: no wave64),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 transcendentals, wave64: no wave64),gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu(f64, wave64: no wave64),gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu(integer arithmetic, wave64: no wave64),gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu(integer carries, wave64: no wave64),gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu(mask_ff0_flbit, wave64: no wave64),gpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu_wave32_program_in_wave64_hardware(no wave64),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).fuzz_validate_and_gpu_0,fuzz_validate_and_gpu_1,fuzz_validate_and_gpu_2,fuzz_validate_and_gpu_3ingpu::dxil::fuzz_tests. They fail the same way on the basecbc296ahere (0x8007000EfromCreateComputePipelineStateon seeds 70, 545, 1019 and 1507, the NVIDIA refusal @PHeitor1 reported on #1679), so this PR adds no failure.test_title_draws_with_a_root_signature_under_the_debug_layerreports ok, but this machine has no D3D12 debug layer (debug layer requested but unavailable … (0x887A002D)), so it ran without the layer and is no evidence either way.Regression run (
scripts/smoke.ps1 -Seconds 60, release, the retail title of #505 at its start screen;XCL_PSO_PRELOAD=0for both builds, because this machine's preload list holds the program of #1307)base (
cbc296a, this PR's merge base withmain):this PR:
Not tested: the world load (the smoke runs stop at the start screen, so code that only runs later is not exercised there); AMD.
AI use: Claude Code (Claude Opus 5.5) built and ran the tests and smoke runs on my machine and wrote this report; I checked it.
@JoaoPauluu on GitHub · 2026-11-25 05:22 UTC · original
A regression run under Wine on Linux on the retail title: no device removal, no crash, frames level with
main(1365 here; 1371 and 1356 on the twomainruns). Nothing in the log points to the placed-bufferHEAP_UMApath, so I cannot tell whether this run reached it; this is a regression run only.Tested
x86_64-pc-windows-gnu.697cacaas it is (based oncbc296a) andmainf5c5bdf, no uncommitted changes. Retail title 1.0.2.1,scripts/linux/smoke.sh(#257) for 60 s, no input. Runs in order: main, this PR (with other PRs in between), main.Regression run
main (first run):
this PR:
The second
mainrun: 1356 frames,exit: 0x0, no device removal, no crash. Under Wine,peak commitreads 0 MB, so these blocks do not check memory.Not tested
AI use
@DavidM1911 on GitHub · 2026-11-25 05:26 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@Toons29 on GitHub · 2026-11-25 09:38 UTC · original
Regression run of
e11ce9b7on the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainon568e7db7, this PR on its head commit with no uncommitted changes, same title and time.Against the limits in CONTRIBUTING.md: 105 % 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; a script posted this right after the run, with both blocks exactly as printed.@raylitebull on GitHub · 2026-11-25 10:48 UTC · original
Code review on
e11ce9b:runner.rs(already landed via #2022) anddstorage.rs/dstorage/parallel.rs(overlapping #2094 / #2159).HEAP_UMAblock lifetime (eal.rs):
res_releasefreese.blockas soon ase.live_buffers == 0without checking whether the heap itself was released (mem_heap_release hit== 0). If a title keeps a HEAP_UMA heap alive, places and releases a first buffer, and later places a second buffer on the same heap,
e.blockwill already have been freed (leaving e.block == None). Tracking an explicit heap_released: bool on HeapUma (removing the entry + freeing e.block only once both heap_released && live_buffers == 0) fixes this safely.@fromthemoonx on GitHub · 2026-11-25 12:53 UTC · original
The suite passes on NVIDIA, but nothing in it reaches the changed release order. I agree with @raylitebull's review above: the block is freed under a live heap, and the
heap_releasedflag fixes that. It would also fix the entry of a heap released before its buffers, which the last buffer frees but never removes. Three more points:HEAP_UMAones would cover both orders: release the heap before its buffer and check that the block is freed once and the entry is gone; and release a live heap's only buffer, place a new one at the same offset, and check that its data stays where it was.late_release::holdkeeps the block until the queues are past it). Worth agreeing with that claim before both land.Tested (RTX 3060 12 GB, driver 610.88, Windows 11 Pro 26300, Rust 1.100.0 MSVC, DXC 1.9.2602.17, debug; on
maincbc296a):cargo build --workspace+cargo test --workspace --no-fail-fast -- --test-threads=4: 1154 passed, 0 failed, 46 ignored, at bothfe97ba1and697caca. 24 SKIPPED (no wave64, the per-lane refusals, no heap windows; the same as onmain). TheHEAP_UMAcode is unchanged ate11ce9b.Not tested: a title, the two release orders at run time.
AI use: Claude Code (Claude Opus 5.5) ran the suite, read the diff and wrote this comment.
@throny on GitHub · 2026-11-25 17:24 UTC · original
Two contributors checked independently and found that #1648 solves the same problem (for #1488) in a different way: #1607, group D88. 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.
@DavidM1911 on GitHub · 2026-11-26 07:28 UTC · original
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
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.