Repository navigation
Conversation
unmap_if_superseded holds placements::REGISTRY across vram::unmap_superseded_target. Its unmap_placed also collects every completed held unmap on the device and dropped those references before returning, so still under REGISTRY. If one of them is the last reference to a target the title already released while its unmap was held, the hooked Release runs res_release -> forget_for_recycle -> placements::released -> settle, which locks REGISTRY again on the same thread. That deadlocks the thread, and a stuck REGISTRY then blocks CreatePlacedResource, note_use and every later held unmap. unmap_placed and unmap_superseded_target now return the completed references (must_use); unmap_if_superseded decides and unmaps under REGISTRY, drops the guard, then drops them. unmap_superseded, whose callers hold no lock, drops them as before. REGISTRY is now locked through lock(), which keeps a thread-local "held" flag and fails a debug assertion on re-entry instead of deadlocking silently, so tests catch this kind of re-entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Review (head 15ae802, diff read, not a merge-check; checks red):
Fine: by reading, the hang described is real on main. The AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
|
Test report (not a merge-check: AI-written and posted by Foniass without a human check of each point. |
|
Test report (not a merge-check: Smoke blocks, if the author wants them for a regression run (base xcl-smoke v1 xcl-smoke v1 AI-written from a real run (OpenCode, DeepSeek V4.1 Flash 1017); posted only after the human checks each point. |
bmjask
left a comment
There was a problem hiding this comment.
Review of 15ae8026: 1 finding(s) (1 medium), most severe first.
- Medium
crates/xcl/src/hle/d3d12x/vram.rs:2575: see below.
On lines outside the diff:
- Medium
crates/xcl/src/hle/d3d12x/vram.rs:2575: Not certain about this one, because it depends on a queue-lease holder reaching REGISTRY:unmap_placedcallsnative_queue_signal, which waits forqueue_submit's per-queue lease, whileplacements::unmap_if_supersededstill holds REGISTRY, so here REGISTRY is taken before the queue lease. If thread B (drain_known->unmap_if_superseded) holds REGISTRY and waits for queue Q's lease, while thread A holds Q's lease (inside ExecuteCommandLists or XCL setup work) and reaches REGISTRY (a last Release ->res_release->forget_for_recycle->placements::released->settle->lock(), ornote_use), each waits on the other and the title hangs, the same class of hang this PR fixes. Returning the signals and issuing them after REGISTRY is dropped, as the PR now does for the references, would close it.
These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
Requested by Prime
placements::unmap_if_supersededholds the placementsREGISTRYmutex while it callsvram::unmap_superseded_target. That call also finishes the other held unmaps on the device whose fences have passed, and it dropped their resource references before returning, so still underREGISTRY. If one of those is the last reference to a target the title released while its unmap was held, the hooked Release runsres_release->forget_for_recycle->placements::released->settle, which locksREGISTRYagain on the same thread. The thread then waits for itself, and every laterCreatePlacedResource,note_useand held unmap waits behind it: the title hangs. We found it in our fork, where another change makes this case common; on main it is latent but the path is the same. Now the completed references are returned tounmap_if_superseded, which drops them after it letsREGISTRYgo.REGISTRYis also locked through a smalllock()helper that fails a debug assertion when a thread locks it twice, so tests catch this kind of re-entry instead of hanging.Related: #3577 (draft) changes how
note_usetakesREGISTRY; the two touch the same lock line innote_use, so whichever lands second needs a one-line rebase.What is in it
crates/xcl/src/hle/d3d12x/vram.rs:unmap_placedandunmap_superseded_targetreturn the completed held unmaps' references (#[must_use]) instead of dropping them;unmap_superseded, whose callers hold no lock, drops them as before.crates/xcl/src/hle/d3d12x/placements.rs:unmap_if_supersededdrops theREGISTRYguard, then the returned references.lock()replacesREGISTRY.lock().unwrap()and keeps a thread-local "held" flag that a debug assertion checks.Tested
cargo check -p xcl --lib --tests --target x86_64-pc-windows-gnupasses. The test suite was not run on this exact branch.Regression run
Not tested
scripts/smoke.ps1on this branch; AMD.AI use
🤖 Generated with Claude Code