From fa35501c4f0ac57ffe18479791ddf209c817aa39 Mon Sep 17 00:00:00 2001 From: marco <*~=`'#}+{/-|&$^_@721217.xyz> Date: Wed, 10 Jun 2026 15:34:28 +0200 Subject: [PATCH] Mark Waiter m_cv as guarded by m_mutex --- include/mp/proxy-io.h | 4 ++-- test/mp/test/test.cpp | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/mp/proxy-io.h b/include/mp/proxy-io.h index 9260593e..092ea42e 100644 --- a/include/mp/proxy-io.h +++ b/include/mp/proxy-io.h @@ -384,7 +384,7 @@ struct Waiter } template - void wait(Lock& lock, Predicate pred) + void wait(Lock& lock, Predicate pred) MP_REQUIRES(m_mutex) { m_cv.wait(lock.m_lock, [&]() MP_REQUIRES(m_mutex) { // Important for this to be "while (m_fn)", not "if (m_fn)" to avoid @@ -410,7 +410,7 @@ struct Waiter //! EventLoop::m_mutex as long as Waiter::mutex is locked first and //! EventLoop::m_mutex is locked second. Mutex m_mutex; - std::condition_variable m_cv; + std::condition_variable m_cv MP_GUARDED_BY(m_mutex); std::optional> m_fn MP_GUARDED_BY(m_mutex); }; diff --git a/test/mp/test/test.cpp b/test/mp/test/test.cpp index 13fc8e30..05762b93 100644 --- a/test/mp/test/test.cpp +++ b/test/mp/test/test.cpp @@ -510,6 +510,7 @@ KJ_TEST("Make simultaneous IPC calls on single remote thread") [&running, &tc, i](auto&& results) { assert(results.getResult() == static_cast(100 * (i+1))); running -= 1; + Lock lock(tc.waiter->m_mutex); tc.waiter->m_cv.notify_all(); })); }