Skip to content

Commit 93fecc2

Browse files
authored
[lldb] Fixed lldb-server crash (TestLogHandler was not thread safe) (#101326)
Host::LaunchProcess() requires to SetMonitorProcessCallback. This callback is called from the child process monitor thread. We cannot control this thread anyway. lldb-server may crash if there is a logging around this callback because TestLogHandler is not thread safe. I faced this issue debugging 100 simultaneous child processes. Note StreamLogHandler::Emit() in lldb/source/Utility/Log.cpp already contains the similar mutex.
1 parent 569d8ce commit 93fecc2

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lldb/tools/lldb-server/LLDBServerUtilities.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ class TestLogHandler : public LogHandler {
2727
: m_stream_sp(stream_sp) {}
2828

2929
void Emit(llvm::StringRef message) override {
30+
std::lock_guard<std::mutex> guard(m_mutex);
3031
(*m_stream_sp) << message;
3132
m_stream_sp->flush();
3233
}
3334

3435
private:
36+
std::mutex m_mutex;
3537
std::shared_ptr<raw_ostream> m_stream_sp;
3638
};
3739

0 commit comments

Comments
 (0)