https://github.com/Teemperor updated https://github.com/llvm/llvm-project/pull/205771
>From 38ef5044eaf531bcf81e8a9f6a41dc4e1c7db516 Mon Sep 17 00:00:00 2001 From: Raphael Isemann <[email protected]> Date: Thu, 25 Jun 2026 11:32:34 +0100 Subject: [PATCH] [lldb] Always lock in StreamLogHandler::Write This code assumes that writing to an unbuffered raw_fd_ostream from multiple threads is somehow safe. raw_fd_ostream doesn't make any guarantees about this from what I can see. The current raw_fd_ostream implementation also uses a looping write call to write the content in chunks, and doing this from multiple threads leads to interleaving log messages. This patch unconditionally make us aquire the stream lock. --- lldb/source/Utility/Log.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lldb/source/Utility/Log.cpp b/lldb/source/Utility/Log.cpp index 1921573996196..6b077a3766e9f 100644 --- a/lldb/source/Utility/Log.cpp +++ b/lldb/source/Utility/Log.cpp @@ -378,12 +378,8 @@ void StreamLogHandler::Flush() { } void StreamLogHandler::Emit(llvm::StringRef message) { - if (m_stream.GetBufferSize() > 0) { - std::lock_guard<std::mutex> guard(m_mutex); - m_stream << message; - } else { - m_stream << message; - } + std::lock_guard<std::mutex> guard(m_mutex); + m_stream << message; } CallbackLogHandler::CallbackLogHandler(lldb::LogOutputCallback callback, _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
