4 Commits

Author SHA1 Message Date
1aefed0dac runtime: fix present_mutex AB-BA deadlock, cross-queue relay cycle, and held-queue stalls 2026-11-29 21:05:26 -05:00
314b4e73dd Merge upstream ProjectLeonida/mandy main (b589e0fe0) into round10 base
# Conflicts:
#	docs/design.md
#	runtime/shims/d3d12_vulkan_device.cpp
#	runtime/src/queue_holds.h
#	runtime/src/shader_library.h
#	runtime/src/vulkan_backend.h
#	runtime/src/vulkan_replay.h
#	runtime/test/vk_harness.cpp
#	tests/semantic/test_wave32_lane_select.py
#	tools/lane_masks.py
#	tools/rdna2spirv.py
2026-11-29 06:33:39 -05:00
eee02b7699 runtime: preserve dirty handoff in QueueHolds::pump_ready on exception 2026-11-25 13:28:33 +01:00
3e6e229a64 runtime: make QueueHolds pump handoff race-free, exception-safe, and per-instance
Fix three bugs in runtime/src/queue_holds.h (the cross-queue Wait-before-Signal
and Present barrier scheduler):

1. Lost-wakeup handoff race in pump_ready(): previously a thread exiting
   pump_ready() called pump.unlock() (release) followed by dirty_.load(acquire),
   while a concurrent caller wrote dirty_.store(true, release) followed by a
   failing pump_mutex_.try_lock(). Under the C++ memory model and on weak
   architectures (ARM64), a release followed by an acquire does not prevent
   Store-Load reordering, allowing both threads to exit with dirty_ == true
   and ready batches/presents stuck indefinitely. Serialize dirty_ and
   pump_active_ transitions under the leaf mutex_ (preserving strict
   pump_mutex_ -> mutex_ lock ordering).
2. Exception-safety deadlock: in_pump() was toggled manually around
   discard_waiting_on(), release_ready(), and run_barriers(); any exception
   left in_pump() permanently true on that thread, silently suppressing every
   future pump_ready() and remove_fence(). Use an RAII PumpScope and
   ActiveGuard so state always unwinds cleanly.
3. Cross-instance collision: in_pump() used a single process-wide
   thread_local bool shared across all QueueHolds instances, causing a nested
   pump_ready()/remove_fence() on a second instance to be skipped. Track
   re-entrancy per instance with a stack-allocated intrusive PumpScope chain.

Add portable unit and concurrency stress suite runtime/test/queue_holds_test.cpp.

Item: RT-QUEUE-HOLDS-PUMP-SAFETY
2026-11-25 13:04:22 +01:00