-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[lldb][windows] fix a use before allocation crash #170530
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
Merged
charles-zablit
merged 2 commits into
llvm:main
from
charles-zablit:charles-zablit/lldb/windows/fix-use-before-allocation
Dec 3, 2025
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -107,14 +107,6 @@ ProcessLauncherWindows::LaunchProcess(const ProcessLaunchInfo &launch_info, | |||||
| ::CloseHandle(stderr_handle); | ||||||
| }); | ||||||
|
|
||||||
| auto inherited_handles_or_err = GetInheritedHandles( | ||||||
| launch_info, startupinfoex, stdout_handle, stderr_handle, stdin_handle); | ||||||
| if (!inherited_handles_or_err) { | ||||||
| error = Status(inherited_handles_or_err.getError()); | ||||||
| return HostProcess(); | ||||||
| } | ||||||
| inherited_handles = *inherited_handles_or_err; | ||||||
|
|
||||||
| SIZE_T attributelist_size = 0; | ||||||
| InitializeProcThreadAttributeList(/*lpAttributeList=*/nullptr, | ||||||
| /*dwAttributeCount=*/1, /*dwFlags=*/0, | ||||||
|
|
@@ -133,6 +125,14 @@ ProcessLauncherWindows::LaunchProcess(const ProcessLaunchInfo &launch_info, | |||||
| auto delete_attributelist = llvm::make_scope_exit( | ||||||
| [&] { DeleteProcThreadAttributeList(startupinfoex.lpAttributeList); }); | ||||||
|
|
||||||
| auto inherited_handles_or_err = GetInheritedHandles( | ||||||
| launch_info, startupinfoex, stdout_handle, stderr_handle, stdin_handle); | ||||||
| if (!inherited_handles_or_err) { | ||||||
| error = Status(inherited_handles_or_err.getError()); | ||||||
| return HostProcess(); | ||||||
| } | ||||||
| inherited_handles = *inherited_handles_or_err; | ||||||
|
||||||
| inherited_handles = *inherited_handles_or_err; | |
| std::vector<HANDLE> inherited_handles; = *inherited_handles_or_err; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I know you're just moving existing code, but this does not conform to LLVM's guidelines regarding
autouse. The type isn't obvious from the RHS. I guess the old code was closer to whereinherited_handlesis declared, but that begs the questions why this is written in C89-style with all the variables declared at the start of the function. Can you move this to line 134?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.
When #168729 eventually gets merged,
inherited_handleswill be assigned to in anifstatement, and is later used outside of the scope of thatifstatement. I decided to just declare it at the top of the method as it was the case before #170301 was merged: https://github.com/llvm/llvm-project/pull/170301/files#diff-e88204c0b3183c22166588028caaa5bc946c63fc9e90af696f60603325b1d08dL116Outside of the context of #168729, it does not make much sense, I reverted that change and moved it to line 134.