<div dir="ltr">I'll change it to an assert and next time it happens I'll dig a little more.  I've only seen this on about 1 or 2 out of 100 runs of the test suite so I don't know how it happens.</div><br><div class="gmail_quote"><div dir="ltr">On Fri, Nov 13, 2015 at 1:44 PM Jim Ingham <<a href="mailto:jingham@apple.com">jingham@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">GetCurrentPlan should never return NULL.  The Thread constructor pushes the Base thread plan onto the stack, and pop won't remove the Base plan.  When we destroy the thread (in ThreadDestroy) we clear the plan stack and then push a ThreadPlanNull onto the plan stack.  So if you are seeing a GetCurrentPlan returning NULL that means somebody is using it while it is in the process of being created or destroyed.  The former shouldn't be possible, so you must be accessing it while it is in mid-destroy.<br>
<br>
I'd rather not put more code in various places that checks for things that should never be true, or if you are doing this check you should assert so we can figure out how this is happening.<br>
<br>
Note, ThreadDestroy doesn't lock itself against uses of the thread.  That hasn't been necessary but if you are seeing crashes here, it might be worth doing that.<br>
<br>
Jim<br>
<br>
<br>
> On Nov 13, 2015, at 1:28 PM, Zachary Turner via lldb-commits <<a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a>> wrote:<br>
><br>
> Author: zturner<br>
> Date: Fri Nov 13 15:28:53 2015<br>
> New Revision: 253086<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=253086&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=253086&view=rev</a><br>
> Log:<br>
> Add a null check against the ThreadPlan<br>
><br>
> I'm seeing some cases where the ThreadPlan is null.  It could<br>
> be a sign of a valid race condition, but at least we shouldn't<br>
> crash.<br>
><br>
> Modified:<br>
>    lldb/trunk/source/Target/ThreadList.cpp<br>
><br>
> Modified: lldb/trunk/source/Target/ThreadList.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadList.cpp?rev=253086&r1=253085&r2=253086&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadList.cpp?rev=253086&r1=253085&r2=253086&view=diff</a><br>
> ==============================================================================<br>
> --- lldb/trunk/source/Target/ThreadList.cpp (original)<br>
> +++ lldb/trunk/source/Target/ThreadList.cpp Fri Nov 13 15:28:53 2015<br>
> @@ -538,7 +538,7 @@ ThreadList::WillResume ()<br>
><br>
>     for (pos = m_threads.begin(); pos != end; ++pos)<br>
>     {<br>
> -        if ((*pos)->GetResumeState() != eStateSuspended &&<br>
> +        if ((*pos)->GetResumeState() != eStateSuspended && (*pos)->GetCurrentPlan() &&<br>
>                  (*pos)->GetCurrentPlan()->StopOthers())<br>
>         {<br>
>             if ((*pos)->IsOperatingSystemPluginThread() && !(*pos)->GetBackingThread())<br>
><br>
><br>
> _______________________________________________<br>
> lldb-commits mailing list<br>
> <a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits</a><br>
<br>
</blockquote></div>