[Lldb-commits] [lldb] Fix the modal private state thread we use for running expressions on the private state thread (PR #179799)

Kyungtak Woo via lldb-commits lldb-commits at lists.llvm.org
Tue Feb 10 23:00:41 PST 2026


kevinwkt wrote:

👋  Looks like the recent changes introduced a memory leak that makes asan very unhappy when running the test suite:

A bunch of tests (e.g., target_tests, expression_tests) are failing during teardown with:

```SUMMARY: AddressSanitizer: 112 byte(s) leaked in 1 allocation(s).
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Direct leak of 112 byte(s) in 1 object(s) allocated from:
    #0 0x563965aa2c9d in operator new(unsigned long) compiler-rt/lib/asan/asan_new_delete.cpp:109:35
    #1 0x7f517888ade5 in lldb_private::Process::PrivateStateThread::PrivateStateThread(...) lldb/include/lldb/Target/Process.h:3210:5
    #2 0x7f5178889dcf in lldb_private::Process::Process(...) lldb/source/Target/Process.cpp:446:42
    #3 0x7f517afdeca1 in std::make_shared<DummyProcess>(...)/libcxx/include/__memory/shared_ptr.h:690:10
```
Could you take a look? 🙏 

It's pointing to the initial construction inside the Process::Process member initializer list:

```
Process::Process(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
                 const UnixSignalsSP &unix_signals_sp)
    : ProcessProperties(this),
      // ...
      m_current_private_state_thread(new PrivateStateThread(             <<<<<<< ASAN points here
          *this, eStateUnloaded, eStateUnloaded, false, "rename-this-thread")),
      // ...
```

I believe it's most likely because Process::~Process() deletes or clears out its other members, but it is completely missing a delete m_current_private_state_thread; to pair with this raw pointer allocation. So any time a `Process` instance completes its lifecycle (particularly prominent in unit tests spinning up mock targets/processes), it leaves an orphaned `PrivateStateThread` behind, but that's just my theory.

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


More information about the lldb-commits mailing list