[Lldb-commits] [lldb] [LLDB][Windows]: Don't pass duplicate HANDLEs to CreateProcess (PR #165281)

via lldb-commits lldb-commits at lists.llvm.org
Mon Oct 27 10:19:05 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: None (lb90)

<details>
<summary>Changes</summary>

Fixes https://github.com/msys2/MINGW-packages/issues/26030

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


1 Files Affected:

- (modified) lldb/source/Host/windows/ProcessLauncherWindows.cpp (+6) 


``````````diff
diff --git a/lldb/source/Host/windows/ProcessLauncherWindows.cpp b/lldb/source/Host/windows/ProcessLauncherWindows.cpp
index f5adadaf061bf..ab151f1a9a0ac 100644
--- a/lldb/source/Host/windows/ProcessLauncherWindows.cpp
+++ b/lldb/source/Host/windows/ProcessLauncherWindows.cpp
@@ -15,6 +15,7 @@
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/Program.h"
 
+#include <algorithm>
 #include <string>
 #include <vector>
 
@@ -122,6 +123,11 @@ ProcessLauncherWindows::LaunchProcess(const ProcessLaunchInfo &launch_info,
         act->GetFD() == act->GetActionArgument())
       inherited_handles.push_back(reinterpret_cast<HANDLE>(act->GetFD()));
   }
+  // Remove duplicate HANDLEs
+  std::sort(inherited_handles.begin(), inherited_handles.end());
+  inherited_handles.erase(
+      std::unique(inherited_handles.begin(), inherited_handles.end()),
+      inherited_handles.end());
   if (!inherited_handles.empty()) {
     if (!UpdateProcThreadAttribute(
             startupinfoex.lpAttributeList, /*dwFlags=*/0,

``````````

</details>


https://github.com/llvm/llvm-project/pull/165281


More information about the lldb-commits mailing list