[Lldb-commits] [lldb] r276795 - Check both private & public states to decide if you need to halt before killing.
Jim Ingham via lldb-commits
lldb-commits at lists.llvm.org
Wed Jul 27 09:41:20 PDT 2016
If you go to halt a thread whose private state is running, and by the time you get to halting it the private state has gone from running to stopped then the code doing the halt will declare victory, since that's what it was trying to do. If it was still running, then it will have to interrupt. I don't see how this will be flakey.
> On Jul 27, 2016, at 5:09 AM, Pavel Labath <labath at google.com> wrote:
> This fix is going to be flaky: Since the private state can flip back
> and forth between running and stopped and there's no sychronization
> between the private state thread and this code, you're going to get
> unpredictable behavior depending on the exact moment you call
> I assume the other thread is stuck in RunThreadPlan(), which does not
> update the public state and that's why this does not fire. If that's
> the case, we should check whether RunThreadPlan is active instead of
> relying on the private state.
> On 26 July 2016 at 20:47, Jim Ingham via lldb-commits
> <lldb-commits at lists.llvm.org> wrote:
>> Author: jingham
>> Date: Tue Jul 26 14:47:45 2016
>> New Revision: 276795
>> URL: http://llvm.org/viewvc/llvm-project?rev=276795&view=rev
>> Check both private & public states to decide if you need to halt before killing.
>> We were just checking the public state, but that meant if you were hung in a long
>> running hand-called function, we wouldn't know to interrupt the process, and we would
>> not succeed in killing it.
>> Modified: lldb/trunk/source/Target/Process.cpp
>> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=276795&r1=276794&r2=276795&view=diff
>> --- lldb/trunk/source/Target/Process.cpp (original)
>> +++ lldb/trunk/source/Target/Process.cpp Tue Jul 26 14:47:45 2016
>> @@ -3634,7 +3634,10 @@ Error
>> Process::StopForDestroyOrDetach(lldb::EventSP &exit_event_sp)
>> Error error;
>> - if (m_public_state.GetValue() == eStateRunning)
>> + // Check both the public & private states here. If we're hung evaluating an expression, for instance, then
>> + // the public state will be stopped, but we still need to interrupt.
>> + if (m_public_state.GetValue() == eStateRunning || m_private_state.GetValue() == eStateRunning)
>> Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
>> if (log)
>> lldb-commits mailing list
>> lldb-commits at lists.llvm.org
More information about the lldb-commits