[Lldb-commits] [lldb] [lldb][Windows] Keep the process info when the parent pid lookup fails (PR #228455)

Charles Zablit via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 2 07:23:04 PDT 2026


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

`Host::GetProcessInfo` sets the executable and architecture from the PE header, then takes a [`Toolhelp`](https://learn.microsoft.com/en-us/windows/win32/api/_toolhelp/) snapshot whose only contribution is the parent process id. Every failure path in that second half returned `false`, discarding the architecture it had already determined.

The snapshot is racy and the pid can still be absent from the walk. When that happens on attach, `NativeProcessWindows` leaves `m_arch` unset and the first register context hits

```
 Assertion failed: target_arch.GetMachine() == llvm::Triple::x86_64,
   RegisterContextWindows_x86_64.cpp, line 138
```
which kills `lldb-server`, so a second attach in the same test reports 'lost connection'.

Leave the parent process id unset instead of failing the call.

In Swiftlang CI, this fixes `lldb-api :: python_api/hello_world/TestHelloWorld.py`.

>From 91b503e2189e3c8e24657ff6ac605cb36a77dd1f Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Fri, 25 Sep 2026 22:36:10 +0100
Subject: [PATCH] [lldb][Windows] Keep the process info when the parent pid
 lookup fails

---
 lldb/source/Host/windows/Host.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Host/windows/Host.cpp b/lldb/source/Host/windows/Host.cpp
index a9f6e65e38c10e..ebb978a05159fa 100644
--- a/lldb/source/Host/windows/Host.cpp
+++ b/lldb/source/Host/windows/Host.cpp
@@ -200,21 +200,21 @@ bool Host::GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &process_info) {
 
   AutoHandle snapshot(CreateProcessSnapshot());
   if (!snapshot.IsValid())
-    return false;
+    return true;
 
   PROCESSENTRY32W pe;
   pe.dwSize = sizeof(PROCESSENTRY32W);
   if (!Process32FirstW(snapshot.get(), &pe))
-    return false;
+    return true;
 
   do {
     if (pe.th32ProcessID == pid) {
       process_info.SetParentProcessID(pe.th32ParentProcessID);
-      return true;
+      break;
     }
   } while (Process32NextW(snapshot.get(), &pe));
 
-  return false;
+  return true;
 }
 
 llvm::Expected<HostThread> Host::StartMonitoringChildProcess(



More information about the lldb-commits mailing list