[Lldb-commits] [lldb] [lldb][Windows] Keep the process info when the parent pid lookup fails (PR #228455)
via lldb-commits
lldb-commits at lists.llvm.org
Fri Oct 2 07:24:02 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Charles Zablit (charles-zablit)
<details>
<summary>Changes</summary>
`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`.
---
Full diff: https://github.com/llvm/llvm-project/pull/228455.diff
1 Files Affected:
- (modified) lldb/source/Host/windows/Host.cpp (+4-4)
``````````diff
diff --git a/lldb/source/Host/windows/Host.cpp b/lldb/source/Host/windows/Host.cpp
index a9f6e65e38c10..ebb978a05159f 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(
``````````
</details>
https://github.com/llvm/llvm-project/pull/228455
More information about the lldb-commits
mailing list