summaryrefslogtreecommitdiff
path: root/src/debug/Log.cpp
diff options
context:
space:
mode:
authorDave Walker <email@daviey.com>2025-10-05 15:24:49 +0100
committerGitHub <noreply@github.com>2025-10-05 16:24:49 +0200
commitcfac27251af5df4352f747c4539ea9f65450f05a (patch)
tree3df05fe2f8616558ad4155df4cb91d74bb38f995 /src/debug/Log.cpp
parent76d998743ac10e712238c1016db4d8e8d16f1049 (diff)
debug: fix data race in Debug::log() (#11931)
* debug: fix data race in Debug::log() The templated Debug::log() had mutex protection but the non-template overload it calls didn't, causing crashes when plugins called log from background threads (like hypr-dynamic-cursors loading cursor themes). Fixed by moving the mutex lock from the template version into the non-template version, so all writes to shared state are protected. Fixes: hyprwm/Hyprland#11929 Fixes: VirtCode/hypr-dynamic-cursors#99 * debug: apply clang-format to Log.cpp Fix formatting to satisfy CI clang-format check. --------- Co-authored-by: Dave Walker <dave@daviey.com>
Diffstat (limited to 'src/debug/Log.cpp')
-rw-r--r--src/debug/Log.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/debug/Log.cpp b/src/debug/Log.cpp
index b5865f0a..8d84840e 100644
--- a/src/debug/Log.cpp
+++ b/src/debug/Log.cpp
@@ -24,7 +24,9 @@ void Debug::log(eLogLevel level, std::string str) {
if (m_shuttingDown)
return;
- std::string coloredStr = str;
+ std::lock_guard<std::mutex> guard(m_logMutex);
+
+ std::string coloredStr = str;
//NOLINTBEGIN
switch (level) {
case LOG: