Author: Raphael Isemann Date: 2026-06-26T11:22:21+01:00 New Revision: a335f334f512be44ac02a07ffae27468d246a07d
URL: https://github.com/llvm/llvm-project/commit/a335f334f512be44ac02a07ffae27468d246a07d DIFF: https://github.com/llvm/llvm-project/commit/a335f334f512be44ac02a07ffae27468d246a07d.diff LOG: [lldb] Always lock in StreamLogHandler::Write (#205771) 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. Added: Modified: lldb/source/Utility/Log.cpp Removed: ################################################################################ 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
