[Lldb-commits] [lldb] 035d649 - [lldb] Don't let a reader starve ConnectionFileDescriptor::Disconnect (#236558)
via lldb-commits
lldb-commits at lists.llvm.org
Thu Oct 29 12:49:09 PDT 2026
Author: Charles Zablit
Date: 2026-10-29T12:49:03-07:00
New Revision: 035d649dce56894613995fb62911676fe0c48c99
URL: https://github.com/llvm/llvm-project/commit/035d649dce56894613995fb62911676fe0c48c99
DIFF: https://github.com/llvm/llvm-project/commit/035d649dce56894613995fb62911676fe0c48c99.diff
LOG: [lldb] Don't let a reader starve ConnectionFileDescriptor::Disconnect (#236558)
On Windows the command pipe cannot wake a reader blocked in `select()`,
so `Disconnect` waits for the connection mutex. The reader drops the
mutex between two reads but takes it straight back. This makes it
possible for `Disconnect` to wait forever.
Because of this, the `TestPlatformAttach.py` can hang in `Kill()` during
`tearDown`.
This patch sets `m_shutting_down` before waiting, so the reader's next
read returns instead of blocking again, and re-enables the test on
Windows.
Tested on Windows under load: before, runs took up to 81 s, in 5 s
steps; after, 640 of 640 passed in under 10 s.
Fixes #234982.
rdar://191148946
Added:
Modified:
lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
lldb/test/API/functionalities/gdb_remote_client/TestPlatformAttach.py
Removed:
################################################################################
diff --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
index e65a67fe1bd15b..1fb03865b97fe3 100644
--- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -197,6 +197,9 @@ ConnectionStatus ConnectionFileDescriptor::Disconnect(Status *error_ptr) {
return eConnectionStatusSuccess;
}
+ // Prevents reads and writes during shutdown.
+ m_shutting_down = true;
+
// Try to get the ConnectionFileDescriptor's mutex. If we fail, that is
// quite likely because somebody is doing a blocking read on our file
// descriptor. If that's the case, then send the "q" char to the command
@@ -219,9 +222,6 @@ ConnectionStatus ConnectionFileDescriptor::Disconnect(Status *error_ptr) {
locker.lock();
}
- // Prevents reads and writes during shutdown.
- m_shutting_down = true;
-
Status error = m_io_sp->Close();
if (error.Fail())
status = eConnectionStatusError;
diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestPlatformAttach.py b/lldb/test/API/functionalities/gdb_remote_client/TestPlatformAttach.py
index 551c0b6b998574..f7b1af24f9f014 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestPlatformAttach.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestPlatformAttach.py
@@ -7,9 +7,6 @@
class TestPlatformAttach(GDBRemoteTestBase):
@skipIfRemote
- # Sometimes times out on Windows.
- # https://github.com/llvm/llvm-project/issues/234e982
- @skipIfWindows
def test_attach(self):
"""Test attaching by name"""
More information about the lldb-commits
mailing list