-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[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
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 :) |
charles-zablit
left a comment
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!
|
@lb90 Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/211/builds/3323 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/18/builds/22358 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/197/builds/10355 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/141/builds/12624 Here is the relevant piece of the build log for the reference |
|
Hey @lb90, your PR broke some of the build bots. Can you please take a look? |
|
Uh, sorry for the breakage! Taking a look... |
This one is in fact due to earlier lldb-dap changes. |
…s" (#165717) Reverts #165281 Because our Windows on Arm buildbot is red all over: https://lab.llvm.org/buildbot/#/builders/141/builds/12624
|
I didn't realise this was breaking 100s of tests, on Windows on Arm and x86_64 (https://lab.llvm.org/buildbot/#/builders/211/builds/3323). So I've reverted it for now. |
|
Thanks for pushing a revert, I was just about to suggest that. I also ran into failures caused by this - see e.g. https://github.com/mstorsjo/llvm-mingw/actions/runs/18926652956/job/54057474985#step:6:1492. There, you don’t see the actual error message though. Locally I’ve reproduced it too - it seems the failure isn’t deterministic though: |
…reateProcess" (#165717) Reverts llvm/llvm-project#165281 Because our Windows on Arm buildbot is red all over: https://lab.llvm.org/buildbot/#/builders/141/builds/12624
…165281) 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
…s" (llvm#165717) Reverts llvm#165281 Because our Windows on Arm buildbot is red all over: https://lab.llvm.org/buildbot/#/builders/141/builds/12624
My guess is that the order of the handles matters, and using an I suggest using a vector and checking if the value already exists before inserting. The vector will always have less than 10 values so there is no performance issues with an O(n) search. |
|
|
Ah yes missed the fact that you do t want them shuffled. Yea UniqueVector should do |
|
Perhaps the HANDLE array should be kept alive until the CreateProcess call? |
That's worth ensuring as well. Given the non deterministic nature of the test failures, my bet is on the insertion order. In the original code, replacing |
…s" (llvm#165717) Reverts llvm#165281 Because our Windows on Arm buildbot is red all over: https://lab.llvm.org/buildbot/#/builders/141/builds/12624
…165281) 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
…s" (llvm#165717) Reverts llvm#165281 Because our Windows on Arm buildbot is red all over: https://lab.llvm.org/buildbot/#/builders/141/builds/12624
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