Repository navigation
Conversation
QueueHolds::remove_fence() erased the fence and returned when held_ was still zero. A queue that had already called pending() (seeing the fence unsatisfied) but had not yet counted its hold could then create that hold after the drop, and pump_ready() treated the now-unknown semaphore as satisfied and submitted the batch with a destroyed VkSemaphore. Bracket the pending()..hold() window with a reservation that remove_fence() waits for, and drop held batches while the fence is still registered so a concurrent pump_ready() cannot release them first. Only after the drop is the fence erased. Regression: two threads force remove_fence() into the window between a pending() decision and hold(). Red before (hold released), green after (hold dropped). CPU-only; no game data.
Kam471
left a comment
There was a problem hiding this comment.
Built and ran at 299c98f1 on Windows 11 (MSVC, RelWithDebInfo): queue_holds_release_test -> passed (ctest 1/1, 0.02 s; direct run exit 0, queue_holds: a fence released mid-decision drops the hold instead of submitting it). git diff --check clean.
The test is deterministic rather than probabilistic: it brackets begin_hold()/pending(), waits until remove_fence() is entered, then creates the hold inside the reservation, and asserts dropped, not released, and any_held()==0. Moving the fences_.erase after the drop and pumping with the fence still registered closes both halves of the window.
Overlap to coordinate: #4557 also rewrites runtime/src/queue_holds.h and both call sites in runtime/src/vulkan_backend.h (held_changed -> held_added/held_removed, plus the same execute_lists/Signal functions), and its d3d12_queue_handover_test uses held_changed. Whichever of #4557/#4570 lands first, the other needs a rebase and a re-run; if both are wanted, the reservation bracket should sit next to #4557's place accounting rather than be resolved mechanically.
Flyander
left a comment
There was a problem hiding this comment.
The new reservation closes the pre-existing pending-to-hold window, but there is still a window after the zero-reservation wait.
| std::lock_guard lock(mutex_); | ||
| fences_.erase(semaphore); | ||
| std::unique_lock reservation(reservation_mutex_); | ||
| reservation_cv_.wait(reservation, [this] { return hold_reservations_ == 0; }); |
There was a problem hiding this comment.
[P2] This wait only drains reservations that already exist. Once it returns and releases reservation_mutex_, a new execute() can call begin_hold() while this fence is still registered and unsatisfied. If that queue acquires its state lock after discard_waiting_on() passed it, it parks a batch; remove_fence() then erases the fence and pump_ready() treats the now-unknown semaphore as satisfied, submitting with a destroyed VkSemaphore. Please prevent new holds from entering until dropping and erasing this fence are complete, and add a deterministic test for this post-zero window.
|
Verdict: needs-work. The window this PR names is closed, but the adjacent one of the same kind is not, and I reproduced it on the PR head.
Reproduction: a two-thread counterexample in a scratch copy (a fake Suggested fix: hold Other findings:
Build/tests: Hygiene: no item ID in #4571 for this work; #4557 (D3D-203) edits the same two call sites, so one of the two needs a rebase — worth stating explicitly. AI-assisted review. |
|
Verified PR #4570 on Windows 11 (25H2
Agree with AI-assisted (Gemini, Antigravity). |
|
Tested
AI-assisted (Claude Code). |
Flyander and wavehs found that waiting for existing zero reservations was not enough: once that wait returned, a new execute() could open a bracket while the fence was still registered, park a hold, and let pump_ready() submit it after the semaphore was destroyed.\n\nPublish the removal before draining reservations so begin_hold() cannot open while the fence is still being removed, and take begin_hold() outside the queue lock so the drain can still take that lock. Add a deterministic two-thread regression for the post-zero window (red 4, green 0). Use an RAII reservation so an exception while copying held lists cannot hang every later remove_fence(), and update the thread comment.
|
Addressed in AI-assisted (OpenCode) |
|
Tested
Code read of the new
No game files. AI-assisted (Claude Code). |
|
Tested b17551c on Windows 11, MSVC 19.44 (Intel UHD 770 machine; the test is CPU-only): pass. Built |
|
Tested |
|
Integration finding for #4740 (D3D-496, stacked on #4663): this PR's |
QueueHolds::remove_fence() erased the fence and returned when held_ was still zero. A queue that had already called pending() (seeing the fence unsatisfied) but had not yet counted its hold could create that hold after the drop. pump_ready() then treated the unknown semaphore as satisfied and submitted the batch with a destroyed VkSemaphore.
Changes:
Validation: RTX 3090 / 621.24, validation on. Targeted 1/1; full CTest 155 passed, 0 failed; 0 validation errors. No game data.
AI-assisted (OpenCode)