From b3e6ec5383b1f8f661d0dffed7ce73e8262a98df Mon Sep 17 00:00:00 2001 From: lx-s Date: Wed, 8 Jul 2026 10:43:11 +0200 Subject: [PATCH] Fixed possible block on wndMutex in WMLog. --- WinMute/WMLog.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/WinMute/WMLog.cpp b/WinMute/WMLog.cpp index 3cbbb50..7f65dff 100644 --- a/WinMute/WMLog.cpp +++ b/WinMute/WMLog.cpp @@ -156,8 +156,15 @@ void WMLog::StoreMessage(LogLevel level, const wchar_t* msg) } { - const std::scoped_lock lock(wndMutex_); - for (const auto hWnd : registeredWindows_) { + // Copy the window list first: holding wndMutex_ across SendMessageW + // deadlocks if the UI thread is simultaneously blocked on wndMutex_ + // in (Un)RegisterForLogUpdates. + std::vector logWindows; + { + const std::scoped_lock lock(wndMutex_); + logWindows = registeredWindows_; + } + for (const auto hWnd : logWindows) { if (IsWindow(hWnd)) { SendMessageW(hWnd, WM_LOG_UPDATED, 0, reinterpret_cast(&lm)); } -- 2.43.0