Skip to content

Conversation

ashgti
Copy link
Contributor

@ashgti ashgti commented Oct 14, 2025

This adjusts the monitor tear down to only call CancelIoEx a single time, which should cancel all IO operations in the monitoring thread, instead of calling it in a loop.

This removes the m_monitor_thread.native_handle() call that returns a different type on windows/mingw compiles with pthreads enabled and should fix #162801.

This adjusts the monitor tear down to only call CancelIoEx a single time, which should cancel all IO operations in the monitoring thread, instead of calling it in a loop.

This removes the `m_monitor_thread.native_handle()` call that returns a different type on windows/mingw compiles with pthreads enabled and should fix llvm#162801.
@ashgti ashgti requested a review from JDevlieghere as a code owner October 14, 2025 16:24
@ashgti ashgti requested a review from mstorsjo October 14, 2025 16:24
@llvmbot llvmbot added the lldb label Oct 14, 2025
@llvmbot
Copy link
Member

llvmbot commented Oct 14, 2025

@llvm/pr-subscribers-lldb

Author: John Harrison (ashgti)

Changes

This adjusts the monitor tear down to only call CancelIoEx a single time, which should cancel all IO operations in the monitoring thread, instead of calling it in a loop.

This removes the m_monitor_thread.native_handle() call that returns a different type on windows/mingw compiles with pthreads enabled and should fix #162801.


Full diff: https://github.com/llvm/llvm-project/pull/163419.diff

1 Files Affected:

  • (modified) lldb/source/Host/windows/MainLoopWindows.cpp (+1-5)
diff --git a/lldb/source/Host/windows/MainLoopWindows.cpp b/lldb/source/Host/windows/MainLoopWindows.cpp
index c0b10797e506a..9b7df10258bcd 100644
--- a/lldb/source/Host/windows/MainLoopWindows.cpp
+++ b/lldb/source/Host/windows/MainLoopWindows.cpp
@@ -55,11 +55,7 @@ class PipeEvent : public MainLoopWindows::IOEvent {
     if (m_monitor_thread.joinable()) {
       m_stopped = true;
       SetEvent(m_ready);
-      // Keep trying to cancel ReadFile() until the thread exits.
-      do {
-        CancelIoEx(m_handle, /*lpOverlapped=*/NULL);
-      } while (WaitForSingleObject(m_monitor_thread.native_handle(), 1) ==
-               WAIT_TIMEOUT);
+      CancelIoEx(m_handle, /*lpOverlapped=*/NULL);
       m_monitor_thread.join();
     }
     CloseHandle(m_event);

@ashgti ashgti merged commit 5ef56f1 into llvm:main Oct 14, 2025
12 checks passed
akadutta pushed a commit to akadutta/llvm-project that referenced this pull request Oct 14, 2025
This adjusts the monitor tear down to only call CancelIoEx a single
time, which should cancel all IO operations in the monitoring thread,
instead of calling it in a loop.

This removes the `m_monitor_thread.native_handle()` call that returns a
different type on windows/mingw compiles with pthreads enabled and
should fix llvm#162801.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LLDB build broken on mingw with libstdc++ with posix threads

3 participants