llvm-project
a562a10f - lldb-dap: Fix race condition in event threads creation (#194012)

Commit
2 days ago
lldb-dap: Fix race condition in event threads creation (#194012) Move the registration of the SBListener to before the event threads (`ProgressEventThread` and `EventThread`) start This prevents a race condition where a stop event could be missed if it was sent immediately after thread creation, which would lead to a deadlock. It is most likely to happen under heavy CPU load with test that fails early like TestDAP_commands::test_command_directive_abort_on_error_init_commands. Relevant logs. ```sh # Event thread deadlock. 0x00007348BC000BE0 Listener('lldb-dap.progress.listener')::GetEventInternal, timeout = 1000000 us, event_mask = 0 0x00005b72419d1640 Broadcaster("lldb-dap")::BroadcastEvent (event_sp = 0x5b7241eebb60 Event: broadcaster = 0x5b72418e0df0 (lldb-dap), type = 0x00000001, data = <NULL>, unique=false) hijack = 0x0000000000000000 0x00005B7241898440 Listener('lldb.Debugger')::GetEventInternal, timeout = 1000000 us, event_mask = 0 0x7348bc000be0 Listener::GetEventInternal() timed out for lldb-dap.progress.listener 0x00007348BC000BE0 Listener('lldb-dap.progress.listener')::GetEventInternal, timeout = 1000000 us, event_mask = 0 ``` ```sh # Progress thread deadlock. 0x000057798AB6B440 Listener('lldb.Debugger')::GetEventInternal, timeout = <infinite>, event_mask = 0 0x000057798aca4640 Broadcaster("lldb-dap")::BroadcastEvent (event_sp = 0x57798b0b9d80 Event: broadcaster = 0x57798abb3df0 (lldb-dap), type = 0x00000001, data = <NULL>, unique=false) hijack = 0x0000000000000000 0x57798ab6b440 Listener('lldb.Debugger')::AddEvent (event_sp = {0x57798b0b9d80}) 0x57798ab6b440 'lldb.Debugger' Listener::FindNextEventInternal(broadcaster=(nil), event_type_mask=0x00000000, remove=1) event 0x57798b0b9d80 0x000057798aca4640 Broadcaster("lldb-dap")::BroadcastEvent (event_sp = 0x57798b1be800 Event: broadcaster = 0x57798abb3df0 (lldb-dap), type = 0x00000002, data = <NULL>, unique=false) hijack = 0x0000000000000000 0x000078023C000BE0 Listener('lldb-dap.progress.listener')::GetEventInternal, timeout = <infinite>, event_mask = 0 ```
Author
Parents
Loading