[Lldb-commits] [lldb] [lldb] Fix race condition in Process::WaitForProcessToStop() (PR #144919)

via lldb-commits lldb-commits at lists.llvm.org
Thu Jul 3 11:47:29 PDT 2025


athierry-oct wrote:

I've just pushed a new version that moves the pending events from the previous listener to the hijack listener when hijacking, and vice-versa when restoring the previous listener.

In the patch:

- Transferring the events between listeners is done atomically with adding/removing the hijack listener (by holding `m_listeners_mutex`), It should not be possible for an event to be received in the previous listener after the transfer of events but before the switch of listeners, because `m_listeners_mutex` is also locked by `PrivateBroadcastEvent()`
- In `HijackBroadcaster()` and `RestoreBroadcaster()`, we're holding both `m_listeners_mutex` and the listeners' `m_events_mutex`. So in theory, a deadlock is possible if some other thread locks `m_events_mutex` and then `m_listeners_mutex`. I've not seen any place in the code where that happens, but please let me know if I missed something.

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


More information about the lldb-commits mailing list