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

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Fri Jun 20 05:13:35 PDT 2025


labath wrote:

Jim is the process state king here, but FWIW, I think you are onto something here -- I just think it needs to be done more carefully. Fetching the events from the non-hijack listener in this way is racy as there could be another thread trying to do the same (that's sort of why we bother with hijacking in the first place). Instead, what I think could work is to -- in the process of installing the hijack listener -- take (hijack) the *pending* events from the real listener and enqueue them to the hijack listener instead. This should be done while holding the event mutex of the real listener to make sure the other thread doesn't trample over this.

Then you should be able to listen on the hijack listener to your heart's content.

(I don't know if this would matter in practice, but for completeness, we probably should also re-enqueue any unlistened-for events from the hijack listener back to the real listener.)

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


More information about the lldb-commits mailing list