[Lldb-commits] [lldb] [lldb][windows] fix a use before allocation crash (PR #170530)
Charles Zablit via lldb-commits
lldb-commits at lists.llvm.org
Wed Dec 3 10:53:39 PST 2025
https://github.com/charles-zablit updated https://github.com/llvm/llvm-project/pull/170530
>From c23a37e01277ba458d7aec4d777e64494054baa5 Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Wed, 3 Dec 2025 18:37:16 +0000
Subject: [PATCH 1/2] [lldb][windows] fix a use before allocation crash
---
.../Host/windows/ProcessLauncherWindows.cpp | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/lldb/source/Host/windows/ProcessLauncherWindows.cpp b/lldb/source/Host/windows/ProcessLauncherWindows.cpp
index 3c0da1a1e70db..73fff6b234eae 100644
--- a/lldb/source/Host/windows/ProcessLauncherWindows.cpp
+++ b/lldb/source/Host/windows/ProcessLauncherWindows.cpp
@@ -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;
+
const char *hide_console_var =
getenv("LLDB_LAUNCH_INFERIORS_WITHOUT_CONSOLE");
if (hide_console_var &&
>From 6ea9da8624d100fe019f3ce02607c7a0529a4ca7 Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Wed, 3 Dec 2025 18:53:27 +0000
Subject: [PATCH 2/2] fixup! [lldb][windows] fix a use before allocation crash
---
lldb/source/Host/windows/ProcessLauncherWindows.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lldb/source/Host/windows/ProcessLauncherWindows.cpp b/lldb/source/Host/windows/ProcessLauncherWindows.cpp
index 73fff6b234eae..2f78ef80f385e 100644
--- a/lldb/source/Host/windows/ProcessLauncherWindows.cpp
+++ b/lldb/source/Host/windows/ProcessLauncherWindows.cpp
@@ -87,7 +87,6 @@ ProcessLauncherWindows::LaunchProcess(const ProcessLaunchInfo &launch_info,
error.Clear();
std::string executable;
- std::vector<HANDLE> inherited_handles;
STARTUPINFOEXW startupinfoex = {};
STARTUPINFOW &startupinfo = startupinfoex.StartupInfo;
PROCESS_INFORMATION pi = {};
@@ -131,7 +130,7 @@ ProcessLauncherWindows::LaunchProcess(const ProcessLaunchInfo &launch_info,
error = Status(inherited_handles_or_err.getError());
return HostProcess();
}
- inherited_handles = *inherited_handles_or_err;
+ std::vector<HANDLE> inherited_handles = *inherited_handles_or_err;
const char *hide_console_var =
getenv("LLDB_LAUNCH_INFERIORS_WITHOUT_CONSOLE");
More information about the lldb-commits
mailing list