[Lldb-commits] [PATCH] D55631: Delay replacing the process till after we've finalized it

Jim Ingham via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Dec 13 11:02:20 PST 2018

jingham added a comment.

Yeah, I'll simplify the logic after this change.

I've had mysterious crashes that I've never been able to reproduce for quite some time now.  Things like we go to tear down a process, the thread is deleting its thread plans, a thread plan goes to remove one of it's breakpoints and crashes because Thread::GetTarget returns a bogus target.  Then a little while ago I got one test in the test suite to crash this way (on my machine for about a day and only when I debugged it lightly...)  I figured out that the problem was that the Thread relies on the ProcessWP -> ProcessSP to get the target.  I am pretty sure this is an infrequent and racy crash because generally somebody else is holding onto a shared pointer to the process, so m_process_sp is not the last reference.  But if it is, the ThreadPlans can no longer get to the target.

I thought a bit about having the thread plans handle GetTarget being fallible, but they really do have to have a way to get to the Target when being deleted or they will leave stray random breakpoints in the target that will be inserted on rerun.  That would be no good.

This change patches over the problem for now.  It will make sure that Finalize gets called before destruction.

But longer term we either need to require Finalize before destruction, or we need to make a more robust way for Threads to get back to their Targets.




More information about the lldb-commits mailing list