[Lldb-commits] [lldb] [lldb][windows] fix race condition in ConPTY on process exit (PR #194631)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Apr 28 06:59:41 PDT 2026
================
@@ -118,17 +65,21 @@ size_t ConnectionConPTY::Read(void *dst, size_t dst_len,
lldb::ConnectionStatus &status,
Status *error_ptr) {
std::unique_lock<std::mutex> guard(m_pty->GetMutex());
- if (m_pty->IsStopping()) {
+ if (m_pty->IsStopping())
m_pty->GetCV().wait(guard, [this] { return !m_pty->IsStopping(); });
+ guard.unlock();
+
+ if (!m_pty->IsConnected()) {
----------------
Nerixyz wrote:
Don't we need the guard to check for `IsConnected()`?
To avoid the explicit `unlock`, you can wrap this inside a block:
```cpp
{
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()) // ...
```
https://github.com/llvm/llvm-project/pull/194631
More information about the lldb-commits
mailing list