Repository navigation
queue_holds: scope in_pump per instance with RAII and allow re-entrant detach/cancel_after (RT-QUEUE-HOLDS-REENTRY) - #680
Conversation
…t detach/cancel_after (RT-QUEUE-HOLDS-REENTRY)
lixonik
left a comment
There was a problem hiding this comment.
Independent CPU-only verification at d705fc9f: all five standalone queue_holds cases pass. The same test source against main fails the sibling-instance case, as expected.
I found one re-entrancy case that still calls the wrong callback. In a synthetic Holder::oldest_held_seq(), cancel the current barrier's owner and register a replacement with after_held() for the same owner without advancing the work sequence. Return 0 so the barrier can run. Expected: original 0 calls, replacement 1. Observed: original 1, replacement 0. Registering the replacement with a different owner gives the expected result.
run_barriers() copies the original front before calling the holder. After the cancellation and replacement, the owner and work sequence still match, so it pops the new front and calls the old copy. Could the validation use a distinct registration identity and get a regression test for cancellation followed by same-owner registration? Front validation
AI-assisted review and synthetic test. No GPU required.
abnalstlll-byte
left a comment
There was a problem hiding this comment.
Reviewed and verified fix for QueueHolds re-entrancy (RT-QUEUE-HOLDS-REENTRY). Scoping in_pump per instance using RAII PumpGuard eliminates cross-instance pump state corruption, while fast-pathing re-entrant detach and cancel_after under mutex_ prevents self-deadlocks during callback execution. Added test cases in
untime/test/queue_holds_test.cpp verify all 5 concurrency and re-entrancy scenarios cleanly. Approved.
|
Tested d705fc9 applied onto main 23c4596 on an AMD Radeon RX 7900 XT: the new queue_holds test passes 3/3, the five existing queue/sync tests I picked behave the same as on main, and the full ctest run has the same five failures as main and no new ones. Hardware/software: AMD Radeon RX 7900 XT (RDNA3), AMD driver 32.0.32029.2010 (Adrenalin 26.11.2), Windows 11 build 26300, VS 2022 (x64, RelWithDebInfo), Vulkan SDK 1.4.363.0. Build (no warnings from queue_holds.h or queue_holds_test.cpp): Targeted tests, 3 runs each on main and on the PR (third run with
The printed lines match between main and the PR for the passing tests: vk_presenter_sync prints the same six "presenter sync:" lines and "vk_presenter_sync_test: ok", d3d12_fence_timing ends with "fences and timing: multiple-fence waits, held CPU signals, clock calibration, adapter LUID and custom heap properties all checked", and vk_overlapping_occlusion prints the same "crossing 80/20; nested 84/16; 261 segments summed ..." row. No validation messages in any of the validation-on runs. vk_queue_query_sync already fails on main on this machine and is not affected by this PR. Sections 1 to 4 print the same lines on both trees in every run. Only section 5 (progress-counter device loss) changes from run to run: and on a passing run: Because main passed once with validation on, I ran it twice more with As a check that the new test covers the bug, I built queue_holds_test.cpp by hand (cl /std:c++20 /EHsc /O2 /MD) against main's queue_holds.h, running each case on its own:
The same hand build against the PR's header prints "queue_holds tests passed (5/5)". So four of the five cases fail on main, and the cross-thread case passes on both trees, which is expected since that behaviour hasn't changed. Full ctest on the PR build, run once:
Both runs have the same failures. All five also fail on main on this machine and none of them involves queue_holds.h. gameinput is disabled in both runs. |
…ging-upload-128 GPU: use the host upload path for texture staging copies
|
#680 | head d705fc9 (merged cleanly with main c7753ed) | |
|
Verified by OreoFR
AI-assisted (Claude Code, Claude Opus 5.5). |
Claimed in the coordination issue as: RT-QUEUE-HOLDS-REENTRY (#14 (comment))
AI-assisted: yes
No game files touched or included.
Summary
Fixes three re-entrancy and lifetime bugs in
runtime/src/queue_holds.hand adds standalone unit tests inruntime/test/queue_holds_test.cpp:in_pump()tracking: replaces the single globalthread_local boolwith a per-QueueHolds*thread-local stack managed by an RAIIPumpGuard. SiblingQueueHoldsinstances running on the same thread no longer suppress each other'spump_ready()/remove_fence()calls, and exceptions thrown from callbacks no longer leavein_pump()stucktrue.detach()andcancel_after(): when called from within an activepump_ready()/remove_fence()pass on the same thread,detach()andcancel_after()updateholders_/barriers_undermutex_and setdirty_without attempting to re-acquirepump_mutex_(preventing a self-deadlock), while external threads continue waiting onpump_mutex_.snapshot()inpump_ready(),run_barriers(), andremove_fence()re-checkis_attached(holder)before invoking callbacks on a holder so a sibling holder detached mid-pass is never called after teardown.Verification
14.44.35207+ Windows SDK10.0.26100.0(scripts\build_runtime.ps1):239/239affected targets built cleanly with zero new warnings.ctest --test-dir runtime\build --output-on-failure -V -R "^(queue_holds|d3d12_fence_timing|vk_presenter_sync|vk_queue_query_sync|vk_overlapping_occlusion|vk_queue_constructor_oom)$"on Windows 11 + NVIDIA GeForce RTX 4060 (driver621.35): 6/6 passed (100%), includingqueue_holds tests passed (5/5).main(runtime/src/queue_holds.h):queue_holdsfailed immediately (sibling_instance failed, exit code8).python -I scripts/check_no_game_data.py runtime/src/queue_holds.h runtime/test/queue_holds_test.cpp runtime/CMakeLists.txt-> exit0;git diff --checkclean.