From 7b26641aa3eb6cfd63f075d029cd4318b3f35a45 Mon Sep 17 00:00:00 2001 From: hulxv Date: Fri, 27 Mar 2026 21:54:06 +0200 Subject: [PATCH 1/2] event loop: tolerate unexpected exceptions in `post()` callbacks --- src/mp/proxy.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mp/proxy.cpp b/src/mp/proxy.cpp index da22ae6..166c421 100644 --- a/src/mp/proxy.cpp +++ b/src/mp/proxy.cpp @@ -245,7 +245,12 @@ void EventLoop::loop() if (read_bytes != 1) throw std::logic_error("EventLoop wait_stream closed unexpectedly"); Lock lock(m_mutex); if (m_post_fn) { - Unlock(lock, *m_post_fn); + // m_post_fn throwing is never expected. If it does happen, the caller + // of EventLoop::post() will return without any indication of failure, + // which will likely cause other bugs. Log the error and continue. + KJ_IF_MAYBE(exception, kj::runCatchingExceptions([&]() { Unlock(lock, *m_post_fn); })) { + MP_LOG(*this, Log::Error) << "EventLoop: m_post_fn threw: " << kj::str(*exception).cStr(); + } m_post_fn = nullptr; m_cv.notify_all(); } else if (done()) { From 0dfe095015d200d0f1e0dd74bdc478df784bdb09 Mon Sep 17 00:00:00 2001 From: hulxv Date: Sat, 4 Apr 2026 01:41:58 +0200 Subject: [PATCH 2/2] missed header --- src/mp/proxy.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mp/proxy.cpp b/src/mp/proxy.cpp index 166c421..c3ec9b4 100644 --- a/src/mp/proxy.cpp +++ b/src/mp/proxy.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include