https://github.com/daniilavdeev updated https://github.com/llvm/llvm-project/pull/179470
>From 3de1cf680906d12cb2d507efd06ad5d46b02ba74 Mon Sep 17 00:00:00 2001 From: Daniil Avdeev <[email protected]> Date: Tue, 3 Feb 2026 13:59:59 +0000 Subject: [PATCH] [lldb][NFC] Unify thread detaching 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. This is a preparatory refactoring for #177572, which addresses memory leakage in lldb-server. By unifying the logic of detaching, it would be possible to introduce the behavioral change in a more straightforward manner. --- 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
