upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/xma_decoder/tests/ffi_cpp_smoke.cpp
diff options
context:
space:
mode:
authorIlyassRS <ilyassroussi2000@gmail.com>2026-11-25 13:04:22 +0100
committerIlyassRS <ilyassroussi2000@gmail.com>2026-11-25 13:04:22 +0100
commit3e6e229a642e3c4c7787291d9d975dff74b535a9 (patch)
tree10fc814b81cca7fd98e3c78647a1fe3969a93916 /runtime/xma_decoder/tests/ffi_cpp_smoke.cpp
parent0d80bc5df7c873f40965f34f185cb96913786765 (diff)
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
Diffstat (limited to 'runtime/xma_decoder/tests/ffi_cpp_smoke.cpp')
0 files changed, 0 insertions, 0 deletions