Repository navigation
D3D12.X: fix HEAP_UMA lifetime issue for placed buffers (XCL-BT-001) - #2086
saurabhbhoir456 wants to merge 4 commits into
Conversation
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 Release of a buffer raced with the heap's Release. The fix tracks live_buffers per HEAP_UMA heap: - Increment live_buffers when a buffer is placed in the heap (5 insertion sites) - In res_release: decrement live_buffers; if it reaches 0 and the heap was already released (block is Some), free the block - In mem_heap_release: if live_buffers == 0, free block immediately and remove entry; otherwise set block = None and keep entry so last buffer's Release can free it This defers the block free until all buffers in the heap are released.
mem_heap_release set e.block = None when buffers were still alive, discarding the pointer res_release needs to free the block when live_buffers reaches zero. This leaked the backing block whenever a heap was released before its placed buffers. Keep the entry and its block so res_release frees the block once live_buffers hits 0 (checked via e.block.is_some()). Build: cargo build --workspace passes. Tests: cargo test --workspace 1153 passed, 0 failed (GPU tests skipped: no wave64 on AMD RDNA3). Co-Authored-By: Claude Code <noreply@anthropic.com>
|
NVIDIA test report for Tested
Regression run ( base ( 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. |
|
A regression run under Wine on Linux on the retail title: no device removal, no crash, frames level with Tested
Regression run main (first run): this PR: The second Not tested
AI use
|
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
…st runner Fixes xcl-dev#2016: XCL_D3D12_DEBUG=1 removes the GPU test runner's device once a test starts the D3D12.X backend. The GPU test runner creates its D3D12 device in runner::init(), but the debug layer was being enabled in the D3D12.X backend after the device already existed. The debug layer must be enabled before any device is created. Enable the debug layer in runner::init() when XCL_D3D12_DEBUG is set, before adapter selection and device creation. Co-Authored-By: Claude Code <noreply@anthropic.com>
Fixes xcl-dev#2059: DirectStorage byte counter includes failed reads. The BYTES and REQUESTS atomic counters were incremented at the start of execute() via note_request(), but a request can fail after that point (access violation, decompression, zlib, write failures). This caused failed requests to be counted in the byte/request totals. Split note_request() into: - note_request(): logging only (called at start of execute) - note_request_success(n): increments REQUESTS/BYTES counters (called only after successful completion in both execute() and retire_one()) This ensures only successfully completed requests are counted. Co-Authored-By: Claude Code <noreply@anthropic.com>
|
Regression run of Against the limits in CONTRIBUTING.md: 105 % of AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, AI use: Claude Code (Claude Opus 5.5) built both trees and ran |
|
Code review on
|
|
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
Tested (RTX 3060 12 GB, driver 610.88, Windows 11 Pro 26300, Rust 1.100.0 MSVC, DXC 1.9.2602.17, debug; on 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. |
What 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