[Lldb-commits] [lldb] a2f9da5 - [lldb][windows] fix race condition in ConPTY on process exit (#194631)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Apr 28 07:39:51 PDT 2026
Author: Charles Zablit
Date: 2026-04-28T15:39:47+01:00
New Revision: a2f9da54cb84838c106037baed0d9fc60c5637ab
URL: https://github.com/llvm/llvm-project/commit/a2f9da54cb84838c106037baed0d9fc60c5637ab
DIFF: https://github.com/llvm/llvm-project/commit/a2f9da54cb84838c106037baed0d9fc60c5637ab.diff
LOG: [lldb][windows] fix race condition in ConPTY on process exit (#194631)
Added:
Modified:
lldb/source/Host/windows/ConnectionConPTYWindows.cpp
lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
Removed:
################################################################################
diff --git a/lldb/source/Host/windows/ConnectionConPTYWindows.cpp b/lldb/source/Host/windows/ConnectionConPTYWindows.cpp
index 46e1f68744ba3..dd097b16fa190 100644
--- a/lldb/source/Host/windows/ConnectionConPTYWindows.cpp
+++ b/lldb/source/Host/windows/ConnectionConPTYWindows.cpp
@@ -117,9 +117,14 @@ size_t ConnectionConPTY::Read(void *dst, size_t dst_len,
const Timeout<std::micro> &timeout,
lldb::ConnectionStatus &status,
Status *error_ptr) {
- std::unique_lock<std::mutex> guard(m_pty->GetMutex());
- if (m_pty->IsStopping()) {
- m_pty->GetCV().wait(guard, [this] { return !m_pty->IsStopping(); });
+ {
+ std::unique_lock<std::mutex> guard(m_pty->GetMutex());
+ if (m_pty->IsStopping())
+ m_pty->GetCV().wait(guard, [this] { return !m_pty->IsStopping(); });
+ if (!m_pty->IsConnected()) {
+ status = eConnectionStatusEndOfFile;
+ return 0;
+ }
}
char *out = static_cast<char *>(dst);
diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
index 73374a7c07bde..460225ea455e3 100644
--- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
@@ -656,8 +656,9 @@ void ProcessWindows::OnExitProcess(uint32_t exit_code) {
if (m_pty) {
m_pty->SetStopping(true);
- m_stdio_communication.InterruptRead();
m_pty->Close();
+ m_stdio_communication.InterruptRead();
+ m_stdio_communication.StopReadThread();
}
TargetSP target = CalculateTarget();
More information about the lldb-commits
mailing list