[Lldb-commits] [lldb] [lldb][windows] Fix HostThreadWindows::Join dead-code on GetExitCodeThread failure (PR #199014)

David Spickett via lldb-commits lldb-commits at lists.llvm.org
Thu May 21 05:39:40 PDT 2026


================
@@ -31,18 +31,22 @@ HostThreadWindows::~HostThreadWindows() { Reset(); }
 void HostThreadWindows::SetOwnsHandle(bool owns) { m_owns_handle = owns; }
 
 Status HostThreadWindows::Join(lldb::thread_result_t *result) {
+  if (!IsJoinable())
+    return Status(ERROR_INVALID_HANDLE, eErrorTypeWin32);
+
   Status error;
-  if (IsJoinable()) {
-    DWORD wait_result = ::WaitForSingleObject(m_thread, INFINITE);
-    if (WAIT_OBJECT_0 == wait_result && result) {
+  DWORD wait_result = ::WaitForSingleObject(m_thread, INFINITE);
+  if (wait_result == WAIT_OBJECT_0) {
+    if (result) {
       DWORD exit_code = 0;
-      if (!::GetExitCodeThread(m_thread, &exit_code))
+      if (::GetExitCodeThread(m_thread, &exit_code))
----------------
DavidSpickett wrote:

I was going to say you don't need to if here, because either it writes to exit_code or it doesn't.
But A: it looks weird to not check the result and B: we'd have to check it doesn't modify exit_code in case of failure too, it might be undefined.

https://github.com/llvm/llvm-project/pull/199014


More information about the lldb-commits mailing list