https://github.com/charles-zablit created 
https://github.com/llvm/llvm-project/pull/170530

This patch fixes a crash in `ProcessLauncherWindows::GetInheritedHandles` which 
was introduced by https://github.com/llvm/llvm-project/pull/170301.

`ProcessLauncherWindows::GetInheritedHandles` was trying to use 
`startupinfoex.lpAttributeList` which was still `NULL`.

>From c23a37e01277ba458d7aec4d777e64494054baa5 Mon Sep 17 00:00:00 2001
From: Charles Zablit <[email protected]>
Date: Wed, 3 Dec 2025 18:37:16 +0000
Subject: [PATCH] [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 &&

_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to