You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix WorkQueue destructor deadlock by merging into AppRuntime
WorkQueue::~WorkQueue() had a race condition where cancel() + notify_all()
fired without the queue mutex, so the signal could be lost if the worker
thread hadn't entered condition_variable::wait() yet, causing join() to
hang forever.
This change merges WorkQueue into AppRuntime, eliminating split-lifetime
issues, and dispatches cancellation as a work item via Append(). Since
push() acquires the queue mutex, it blocks until the worker enters wait(),
guaranteeing the notification is delivered.
Changes:
- Merge WorkQueue members into AppRuntime (thread, dispatcher, cancel
source, env, suspension lock)
- Remove WorkQueue.h and WorkQueue.cpp
- Update AppRuntime_JSI.cpp TaskRunnerAdapter to use AppRuntime::Dispatch
- Add deterministic regression test using arcana testing hooks
- Fix member declaration order so m_options outlives worker thread
The regression test uses arcana::set_before_wait_callback() to sleep while
holding the queue mutex before wait(), deterministically triggering the race.
See #146 for the test running against the old broken code.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
0 commit comments