KLapshin updated this revision to Diff 36005. KLapshin added a comment. I realized what m_events.empty check in Listener::FindNextEventInternal() method returned event collection is NOT empty - probably because list.empty() just compare begin != end pointers, but pointers may be absolutely invalid.
So, as another workaround - switch to m_events.size() == 0 check. I know - this looks funny because list.size() has O(N) complexity - i.e. - linear and time consuming, but works in this case because it do real empty list check. I consider latest diff at moment just as some hint. Actually two threads may modify events collection - one associated with Process and another one with GDBProcess module. Full log (process and events) below corresponding to m_events.empty replaced with m_events collection size checking: 0x7f9f3d535110 Listener::WaitForEventsInternal (timeout = { 0x0 }) for lldb.process.internal_state_listener -exec-abort 0x7f9f3d534fa0 Broadcaster("lldb.process.internal_state_broadcaster")::HijackBroadcaster (listener("lldb.process.halt_listener")=0x7fff5ac24580) Process::SetPrivateState (stopped) 0x7fff5ac24580 Listener::WaitForEventsInternal (timeout = { 0x7fff5ac244e0 }) for lldb.process.halt_listener Process::SetPrivateState (stopped) stop_id = 16 0x7f9f3d534fa0 Broadcaster("lldb.process.internal_state_broadcaster")::BroadcastEvent (event_sp = {0x7f9f39f16ff0 Event: broadcaster = 0x7f9f3d534fa0 (lldb.process.internal_state_broadcaster), type = 0x00000001, data = { process = 0x7f9f3d534e00 (pid = 258), state = stopped}}, unique =0) hijack = 0x7fff5ac24580 0x7fff5ac24580 Listener('lldb.process.halt_listener')::AddEvent (event_sp = {0x7f9f39f16ff0}) 0x7f9f3d536660 Listener::WaitForEventsInternal (timeout = { 0x0 }) for lldb.process.gdb-remote.async-listener 0x7fff5ac24580 'lldb.process.halt_listener' Listener::FindNextEventInternal(broadcaster=0x0, broadcaster_names=0x0[0], event_type_mask=0x00000000, remove=1) event 0x7f9f39f16ff0 0x7f9f3d534fa0 Broadcaster("lldb.process.internal_state_broadcaster")::RestoreBroadcaster (about to pop listener("lldb.process.halt_listener")=0x7fff5ac24580) 0x7f9f3d534fa0 Broadcaster("lldb.process.internal_state_broadcaster")::BroadcastEvent (event_sp = {0x7f9f39f16ff0 Event: broadcaster = 0x7f9f3d534fa0 (lldb.process.internal_state_broadcaster), type = 0x00000001, data = { process = 0x7f9f3d534e00 (pid = 258), state = stopped}}, unique =0) hijack = 0x0 0x7f9f3d535110 Listener('lldb.process.internal_state_listener')::AddEvent (event_sp = {0x7f9f39f16ff0}) 0x7f9f3d535110 'lldb.process.internal_state_listener' Listener::FindNextEventInternal(broadcaster=0x0, broadcaster_names=0x0[0], event_type_mask=0x00000000, remove=1) event 0x7f9f39f16ff0 Process::StopForDestroyOrDetach() About to stop. 0x700000428840 Listener::StartListeningForEvents (broadcaster = 0x7f9f3d5356a0, mask = 0x00000020) acquired_mask = 0x00000020 for Communication::SyncronizeWithReadThread 0x7f9f3d534fa0 Broadcaster("lldb.process.internal_state_broadcaster")::BroadcastEvent (event_sp = {0x7f9f39e16fa0 Event: broadcaster = 0x7f9f3d534fa0 (lldb.process.internal_state_broadcaster), type = 0x00000002, data = <NULL>}, unique =0) hijack = 0x0 0x7f9f3d535110 Listener('lldb.process.internal_state_listener')::AddEvent (event_sp = {0x7f9f39e16fa0}) Process::WaitForProcessToStop (timeout = 0x7fff5ac25b40) Process::WaitForStateChangedEvents (timeout = 0x7fff5ac25b40, event_sp)... 0x7f9f3b0ed920 Listener::WaitForEventsInternal (timeout = { 0x7fff5ac25b40 }) for 0x7f9f3b0ed920 Listener::WaitForEventsInternal() unknown error for Process::WaitForStateChangedEvents (timeout = 0x7fff5ac25b40, event_sp) => invalid Process::StopForDestroyOrDetach() failed to stop, state is: invalid 0x7f9f3d535db8 Broadcaster("gdb-remote.client")::HijackBroadcaster (listener("lldb.NotifyHijacker")=0x109d0bfa8) Process::ShouldBroadcastEvent (0x7f9f39f16ff0) stopped due to an interrupt, state: stopped Process::ShouldBroadcastEvent (0x7f9f39f16ff0) => new state: stopped, last broadcast state: stopped - YES Process::HandlePrivateEvent (pid = 258) broadcasting new state stopped (old state running) to public 0x7f9f3d534e38 Broadcaster("lldb.process")::BroadcastEvent (event_sp = {0x7f9f39f16ff0 Event: broadcaster = 0x7f9f3d534e38 (lldb.process), type = 0x00000001 (state-changed), data = { process = 0x7f9f3d534e00 (pid = 258), state = stopped}}, unique =0) hijack = 0x0 0x7f9f3a058278 Listener('lldb.Debugger')::AddEvent (event_sp = {0x7f9f39f16ff0}) Process::WaitForEventsPrivate (timeout = 0x0, event_sp)... 0x7f9f3d535110 Listener::WaitForEventsInternal (timeout = { 0x0 }) for lldb.process.internal_state_listener 0x7f9f3d535110 'lldb.process.internal_state_listener' Listener::FindNextEventInternal(broadcaster=0x0, broadcaster_names=0x0[0], event_type_mask=0x00000000, remove=1) event 0x7f9f39e16fa0 0x7f9f3d534fa0 Broadcaster("lldb.process.internal_state_broadcaster")::HijackBroadcaster (listener("lldb.process.halt_listener")=0x700000428aa0) 0x700000428aa0 Listener::WaitForEventsInternal (timeout = { 0x700000428a00 }) for lldb.process.halt_listener 0x7f9f3a058278 'lldb.Debugger' Listener::FindNextEventInternal(broadcaster=0x0, broadcaster_names=0x0[0], event_type_mask=0x00000000, remove=1) event 0x7f9f39f16ff0 Process::SetPublicState (state = stopped, restarted = 0) Process::SetPublicState (stopped) -- unlocking run lock 0x7f9f3d535db8 Broadcaster("gdb-remote.client")::RestoreBroadcaster (about to pop listener("lldb.NotifyHijacker")=0x109d0bfa8) Process::SetExitStatus (status=9 (0x00000009), description="") Process::SetPrivateState (exited) Process::SetPrivateState (exited) stop_id = 17 0x7f9f3d534fa0 Broadcaster("lldb.process.internal_state_broadcaster")::BroadcastEvent (event_sp = {0x7f9f39f0e470 Event: broadcaster = 0x7f9f3d534fa0 (lldb.process.internal_state_broadcaster), type = 0x00000001, data = { process = 0x7f9f3d534e00 (pid = 258), state = exited}}, unique =0) hijack = 0x700000428aa0 0x700000428aa0 Listener('lldb.process.halt_listener')::AddEvent (event_sp = {0x7f9f39f0e470}) 0x700000428aa0 'lldb.process.halt_listener' Listener::FindNextEventInternal(broadcaster=0x0, broadcaster_names=0x0[0], event_type_mask=0x00000000, remove=1) event 0x7f9f39f0e470 0x7f9f3d534fa0 Broadcaster("lldb.process.internal_state_broadcaster")::RestoreBroadcaster (about to pop listener("lldb.process.halt_listener")=0x700000428aa0) 0x7f9f3d534fa0 Broadcaster("lldb.process.internal_state_broadcaster")::BroadcastEvent (event_sp = {0x7f9f39f0e470 Event: broadcaster = 0x7f9f3d534fa0 (lldb.process.internal_state_broadcaster), type = 0x00000001, data = { process = 0x7f9f3d534e00 (pid = 258), state = exited}}, unique =0) hijack = 0x0 0x7f9f3d535110 Listener('lldb.process.internal_state_listener')::AddEvent (event_sp = {0x7f9f39f0e470}) 0x7f9f3d5365a8 Broadcaster("lldb.process.gdb-remote.async-broadcaster")::BroadcastEvent (event_sp = {0x7f9f3b026b80 Event: broadcaster = 0x7f9f3d5365a8 (lldb.process.gdb-remote.async-broadcaster), type = 0x00000002 (async thread should exit), data = <NULL>}, unique =0) hijack = 0x0 Process::WaitForEventsPrivate (timeout = 0x0, event_sp)... 0x7f9f3d535110 Listener::WaitForEventsInternal (timeout = { 0x0 }) for lldb.process.internal_state_listener 0x7f9f3d535110 'lldb.process.internal_state_listener' Listener::FindNextEventInternal(broadcaster=0x0, broadcaster_names=0x0[0], event_type_mask=0x00000000, remove=1) event 0x7f9f39f0e470 0x700000428840 Listener::StartListeningForEvents (broadcaster = 0x7f9f3d5356a0, mask = 0x00000020) acquired_mask = 0x00000020 for Communication::SyncronizeWithReadThread Process::ShouldBroadcastEvent (0x7f9f39f0e470) => new state: exited, last broadcast state: exited - YES Process::HandlePrivateEvent (pid = 258) broadcasting new state exited (old state stopped) to public 0x7f9f3d536660 Listener('lldb.process.gdb-remote.async-listener')::AddEvent (event_sp = {0x7f9f3b026b80}) 0x7f9f3d534e38 Broadcaster("lldb.process")::BroadcastEvent (event_sp = {0x7f9f39f0e470 Event: broadcaster = 0x7f9f3d534e38 (lldb.process), type = 0x00000001 (state-changed), data = { process = 0x7f9f3d534e00 (pid = 258), state = exited}}, unique =0) hijack = 0x0 0x7f9f3a058278 Listener('lldb.Debugger')::AddEvent (event_sp = {0x7f9f39f0e470}) 0x7f9f3d536660 'lldb.process.gdb-remote.async-listener' Listener::FindNextEventInternal(broadcaster=0x0, broadcaster_names=0x0[0], event_type_mask=0x00000000, remove=1) event 0x7f9f3b026b80 Went to stop the private state thread, but it was already invalid. ^done (gdb) =thread-exited,id="1",group-id="i1" =thread-exited,id="2",group-id="i1" =thread-exited,id="3",group-id="i1" =thread-exited,id="4",group-id="i1" =thread-exited,id="5",group-id="i1" =thread-exited,id="6",group-id="i1" =thread-exited,id="7",group-id="i1" (gdb) 0x7f9f3a058278 'lldb.Debugger' Listener::FindNextEventInternal(broadcaster=0x0, broadcaster_names=0x0[0], event_type_mask=0x00000000, remove=0) event 0x7f9f39f0e470 0x7f9f3a058278 'lldb.Debugger' Listener::FindNextEventInternal(broadcaster=0x0, broadcaster_names=0x0[0], event_type_mask=0x00000000, remove=1) event 0x7f9f39f0e470 Process::SetPublicState (state = exited, restarted = 0) (gdb) =thread-exited,id="1",group-id="i1" =thread-group-exited,id="i1",exit-code="0" *stopped,reason="exited-normally" (gdb) Repository: rL LLVM http://reviews.llvm.org/D12968 Files: source/Core/Listener.cpp Index: source/Core/Listener.cpp =================================================================== --- source/Core/Listener.cpp +++ source/Core/Listener.cpp @@ -281,7 +281,7 @@ Mutex::Locker lock(m_events_mutex); - if (m_events.empty()) + if (!m_events.size()) return false;
Index: source/Core/Listener.cpp =================================================================== --- source/Core/Listener.cpp +++ source/Core/Listener.cpp @@ -281,7 +281,7 @@ Mutex::Locker lock(m_events_mutex); - if (m_events.empty()) + if (!m_events.size()) return false;
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits