Repository navigation
Conversation
SYNC_GRAPH.title_fences stored the title's raw ID3D12Fence pointer without a reference. If the title released the fence while an entry still had waits or signals, the next prune_title_fence called GetCompletedValue on a freed object (also for a new fence allocated at the same address). TitleFenceSync now holds its own reference, taken when the entry is created. Entries are removed once their waits and signals are empty (completed, or u64::MAX after device removal). The removed references are dropped after SYNC_GRAPH is unlocked so Release never runs under the global lock. Tests use a synthetic COM ID3D12Fence that counts AddRef/Release and records a GetCompletedValue made at refcount 0; they fail without the owned reference. The queue_dispatch test's fake fence gets AddRef/Release slots. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Independent Linux/Wine verification of Tested: Windows MSVC target, Rust 1.98.1, Wine 11.0, single test thread, 9 GiB memory / 512 MiB swap cgroup limits and 180 s timeout. Fresh
These are CPU/mock-COM lifetime tests, not a GPU run. The mock detects accesses at refcount zero but does not physically free its backing allocation. The machine has an RTX 4060 Laptop GPU / 16 GiB RAM and a diagnostic-relaxed vkd3d installation, but neither establishes native GPU coverage for these fixtures. Not tested: full suite, native Windows, real D3D12 fence destruction, title launch, RAM savings, or correction of our Game Init stall ( Suggested additional regression: make the mock's Local evidence: |
|
Test report: passes on NVIDIA. Exact head Tested
Not tested
Claude Code (Claude Opus 5.5) ran the tests and wrote this report. |
luckyteagirl
left a comment
There was a problem hiding this comment.
Can normal queue activity periodically prune completed entries for older fences? Each signal note prunes only the fence being signaled, then calls take_idle_title_fences, which checks whether the other entries are already empty and never queries their completion. The pre-signal cycle check also returns immediately when the new fence has no graph entry. A workload that creates a fresh fence, signals it once, waits for completion on the CPU, and releases it can therefore retain one graph-owned COM reference per iteration, even as it keeps issuing signals.
I reproduced this with the PR's signal-note and pruning functions and its mock COM fence in a standalone Windows CPU harness. After 64 completed one-shot fences had each lost the title's reference, all 64 still had a graph entry and one reference. An explicit completion sweep followed by idle removal and drop after unlock released all 64. The existing comment about pending fences awaiting observed completion is a different case: these fences have completed, and subsequent ordinary signals to new fences never inspect them.
Signal note · Idle cleanup · Cycle-check early return
AI-assisted review (GPT-6.2 Sol).
Each title Signal/Wait note pruned only the fence it named, so a fence that was signalled once, completed on the GPU and was released by the title kept its graph entry and our COM reference indefinitely: nothing queried the other entries' completion. The signal and wait notes now also inspect up to 8 other entries per call, resuming where the last sweep stopped, drop those left without waits or signals, and release their references after SYNC_GRAPH is unlocked. Test: 64 one-shot fences complete and are released by the title; later signals on another fence release every graph reference. It fails with the sweep disabled. Assisted-by: Claude Code (Claude Sonnet 5.5) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Thanks, the leak is real and I reproduced it from your description. Fixed in 9c05410.
Tested on the PR branch (CPU only, no GPU used for this change): AI-assisted (Claude Sonnet 5.5). |
Fixes #2840
SYNC_GRAPH.title_fenceskept the title's rawID3D12Fencepointer without a reference. If the title released the fence while an entry still had waits or signals, the nextprune_title_fencecalledGetCompletedValueon a freed object.TitleFenceSyncnow owns a reference taken when the entry is created, and the entry is removed (reference released) once it has no waits or signals left. The released references are dropped afterSYNC_GRAPHis unlocked, soReleasenever runs under the global lock. XCL does not wrap title fences with a release hook (the title gets PC fences directly), so the owned reference is the fix that covers every path.What is in it
crates/xcl/src/hle/d3d12x/list_x.rs:TitleFenceSync.fence,prune_title_fence(tf),take_idle_title_fence(s),title_fence_entry;note_title_queue_wait/signalandbreak_cycles_before_title_signaldrop the released references after unlocking. Two unit tests with a synthetic COM fence (countsAddRef/Release, records aGetCompletedValueat refcount 0).crates/xcl/src/hle/d3d12x/real.rs: the fake fence inqueue_slot_18_before_the_layout_is_known_writes_8_bytesgetsAddRef/Releaseslots (the graph now calls them).would_signal_close_cycleare removed on the next wait/signal note, not in that call (it runs under a lock held by its caller).Tested
cargo check --workspace --tests -j 4: finished, no new warnings.cargo test -p xcl --lib -j 4 title_fence_entry: 2 passed, 0 failed, 0 ignored.cargo test -p xcl --lib -j 4 queue_slot_18_before: 1 passed, 0 failed, 0 ignored.refs == 2.Regression run
Pending: the paired
scripts/smoke.ps1runs (main and this head) and the full GPU workspace suite wait for the GPU slot. This PR stays a draft until they are pasted here.Not tested
cargo test --workspaceon a GPU, including the GPU sync-graph tests inlist_x.rs(one of them buildsTitleFenceSync { .., ..Default::default() }; it compiles but was not run).AI use
🤖 Generated with Claude Code