[Lldb-commits] [lldb] [lldb][Windows] handle exception first to keep track of the stop reason (PR #206469)

Charles Zablit via lldb-commits lldb-commits at lists.llvm.org
Mon Jun 29 09:51:21 PDT 2026


charles-zablit wrote:

> > The launch thread blocks on that event in `WaitForDebuggerConnection()`
> 
> I feel like there's something missing in the PR description.
> 
> If I understand correctly:
> 
> 1. `ProcessDebugger::WaitForDebuggerConnection` waits for `m_initial_stop_event`
> 2. We get a debug exception.
> 3. `NativeProcessWindows::OnDebugException` is called.
> 4. `ProcessDebugger::OnDebuggerError` is called first - this triggers `m_initial_stop_event` waking up the launch thread.
> 5. `NativeProcessWindows::Handle{...}Exception` will modify the state of the process.
> 
> Now usually 5 happens before the launch thread wakes up. But in some cases, it might wake up before 5 and would see the wrong state. Is this correct?

Yes, if you add a `Sleep(500)` in https://github.com/llvm/llvm-project/blob/45829d78f3c9cc0660a9abbfad4b01cf87e82fee/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp#L578, the race is deterministic.

I've edited the description of the PR to make it clearer.

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


More information about the lldb-commits mailing list