Skip to content

Commit 65250c7

Browse files
committed
[LLDB][Windows]: Don't pass duplicate HANDLEs to CreateProcess
Fixes msys2/MINGW-packages#26030
1 parent 9a0aa92 commit 65250c7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lldb/source/Host/windows/ProcessLauncherWindows.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "llvm/Support/ConvertUTF.h"
1616
#include "llvm/Support/Program.h"
1717

18+
#include <algorithm>
1819
#include <string>
1920
#include <vector>
2021

@@ -122,6 +123,11 @@ ProcessLauncherWindows::LaunchProcess(const ProcessLaunchInfo &launch_info,
122123
act->GetFD() == act->GetActionArgument())
123124
inherited_handles.push_back(reinterpret_cast<HANDLE>(act->GetFD()));
124125
}
126+
// Remove duplicate HANDLEs
127+
std::sort(inherited_handles.begin(), inherited_handles.end());
128+
inherited_handles.erase(
129+
std::unique(inherited_handles.begin(), inherited_handles.end()),
130+
inherited_handles.end());
125131
if (!inherited_handles.empty()) {
126132
if (!UpdateProcThreadAttribute(
127133
startupinfoex.lpAttributeList, /*dwFlags=*/0,

0 commit comments

Comments
 (0)