https://github.com/daniilavdeev created 
https://github.com/llvm/llvm-project/pull/179470

Remove the Detach() method from HostThreadPosix and instead override the 
virtual Reset() function from HostNativeThreadBase, following the pattern 
already used by HostThreadWindows. This provides a consistent interface for 
platform-specific thread cleanup on all platforms.

The HostThreadPosix::Reset() implementation first calls pthread_detach() before 
delegating to the base implementation HostNativeThreadBase::Reset(), similar to 
how HostThreadWindows calls CloseHandle() in its Reset() override.

>From a2f107377251e4bfc4074dec1e73b6cefa9ba750 Mon Sep 17 00:00:00 2001
From: Daniil Avdeev <[email protected]>
Date: Tue, 3 Feb 2026 13:59:59 +0000
Subject: [PATCH] [lldb] Unify thread cleanup by making HostThreadPosix
 override Reset()

Remove the Detach() method from HostThreadPosix and instead override
the virtual Reset() function from HostNativeThreadBase, following the
pattern already used by HostThreadWindows. This provides a consistent
interface for platform-specific thread cleanup on all platforms.

The HostThreadPosix::Reset() implementation first calls
pthread_detach() before delegating to the base implementation
HostNativeThreadBase::Reset(), similar to how HostThreadWindows calls
CloseHandle() in its Reset() override.
---
 lldb/include/lldb/Host/posix/HostThreadPosix.h |  2 +-
 lldb/source/Host/posix/HostThreadPosix.cpp     | 12 ++++--------
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/lldb/include/lldb/Host/posix/HostThreadPosix.h 
b/lldb/include/lldb/Host/posix/HostThreadPosix.h
index 6c8e09fc11030..32be7154fa1d8 100644
--- a/lldb/include/lldb/Host/posix/HostThreadPosix.h
+++ b/lldb/include/lldb/Host/posix/HostThreadPosix.h
@@ -25,7 +25,7 @@ class HostThreadPosix : public HostNativeThreadBase {
   Status Join(lldb::thread_result_t *result) override;
   Status Cancel() override;
 
-  Status Detach();
+  void Reset() override;
 };
 
 } // namespace lldb_private
diff --git a/lldb/source/Host/posix/HostThreadPosix.cpp 
b/lldb/source/Host/posix/HostThreadPosix.cpp
index a53a8cc9d8389..92f172ecd00a5 100644
--- a/lldb/source/Host/posix/HostThreadPosix.cpp
+++ b/lldb/source/Host/posix/HostThreadPosix.cpp
@@ -50,12 +50,8 @@ Status HostThreadPosix::Cancel() {
   return error;
 }
 
-Status HostThreadPosix::Detach() {
-  Status error;
-  if (IsJoinable()) {
-    int err = ::pthread_detach(m_thread);
-    error = Status(err, eErrorTypePOSIX);
-  }
-  Reset();
-  return error;
+void HostThreadPosix::Reset() {
+  if (IsJoinable())
+    ::pthread_detach(m_thread);
+  HostNativeThreadBase::Reset();
 }

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

Reply via email to