[all-commits] [llvm/llvm-project] b63ea1: [lldb][Windows] Lock the thread list when lldb-ser...

Charles Zablit via All-commits all-commits at lists.llvm.org
Wed Sep 30 04:08:52 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b63ea1c16751bf205d43ecb4f9a2c010c0a4daa6
      https://github.com/llvm/llvm-project/commit/b63ea1c16751bf205d43ecb4f9a2c010c0a4daa6
  Author: Charles Zablit <c_zablit at apple.com>
  Date:   2026-09-30 (Wed, 30 Sep 2026)

  Changed paths:
    M lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp

  Log Message:
  -----------
  [lldb][Windows] Lock the thread list when lldb-server accesses it (#226974)

`NativeProcessProtocol::Threads()` returns a `LockingAdaptedIterable`
that holds `m_threads_mutex` for the lifetime of the iteration, so
callers may hold references into `m_threads` across the loop body. On
Windows, this is only done when removing threads:

```
  // OnCreateThread
  m_threads.push_back(std::move(thread));
...
  // OnExitThread
  std::lock_guard<std::recursive_mutex> guard(m_threads_mutex);
  llvm::erase_if(m_threads, ...);
```

`m_threads` is a `std::vector<std::unique_ptr<NativeThreadProtocol>>`.
When the debug-event thread appends and the vector reallocates, every
reference held by a concurrent iteration on the main loop dangles. This
takes lldb-server down with an access violation:

```
Exception Code: 0xC0000005
 #0 NativeThreadProtocol::GetID   NativeThreadProtocol.h:40
 #1 GetJSONThreadsInfo            GDBRemoteCommunicationServerLLGS.cpp:819
 #4 Handle_jThreadsInfo
 #8 GetPacketAndSendResponse
 #9 DataAvailableCallback         :1271
```

---

This patch takes `m_threads_mutex` everywhere `NativeProcessWindows`
touches `m_threads`: when adding threads in `OnDebuggerConnected` and
`OnCreateThread`, and when reading them in `Resume`, `StopThread`,
`UpdateThreads`, the halt path of `HandleBreakpointException`, and
`OnLoadDll`/`OnUnloadDll`.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list