-
Couldn't load subscription status.
- Fork 15k
[LLDB][Windows]: Don't pass duplicate HANDLEs to CreateProcess #165281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
|
@llvm/pr-subscribers-lldb Author: None (lb90) ChangesFixes msys2/MINGW-packages#26030 Full diff: https://github.com/llvm/llvm-project/pull/165281.diff 1 Files Affected:
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,
|
|
Thanks for submitting this patch! This looks good to me, I just wonder if it would make sense to convert this I think It would make it clearer that we should only have unique handles in this data structure. What do you think? |
65250c7 to
76cf6d1
Compare
|
Nice idea! Changed :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this patch!
CreateProcess fails with ERROR_INVALID_PARAMETER when duplicate HANDLEs are passed via
PROC_THREAD_ATTRIBUTE_HANDLE_LIST. This can happen, for example, if stdout and stdin are the same device (e.g. a bidirectional named pipe), or if stdout and stderr are the same device.Fixes msys2/MINGW-packages#26030