Skip to content

Commit 5cf3278

Browse files
committed
fix: EventLoop::post() deadlocks when posted function throws
1 parent 22bec91 commit 5cf3278

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/mp/proxy.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,9 @@ void EventLoop::loop()
245245
if (read_bytes != 1) throw std::logic_error("EventLoop wait_stream closed unexpectedly");
246246
Lock lock(m_mutex);
247247
if (m_post_fn) {
248-
Unlock(lock, *m_post_fn);
248+
KJ_IF_MAYBE(exception, kj::runCatchingExceptions([&]() { Unlock(lock, *m_post_fn); })) {
249+
MP_LOG(*this, Log::Error) << "EventLoop: m_post_fn threw: " << kj::str(*exception).cStr();
250+
}
249251
m_post_fn = nullptr;
250252
m_cv.notify_all();
251253
} else if (done()) {

0 commit comments

Comments
 (0)