Add a mutex to guard access to the ThreadPlanStack class
authorJim Ingham <jingham@apple.com>
Fri, 16 Jul 2021 03:39:15 +0000 (20:39 -0700)
committerJim Ingham <jingham@apple.com>
Fri, 16 Jul 2021 22:40:58 +0000 (15:40 -0700)
commit6eb576dcff45fa53e8ceb30c7648b903c1413e05
treef91059343a574c0829db92c633cef74d3173e827
parente37bbfe59ccd4ea0da95c02e9f36172239f4f0c3
Add a mutex to guard access to the ThreadPlanStack class

We've seen reports of crashes (none we've been able to reproduce
locally) that look like they are caused by concurrent access to a
thread plan stack.  It looks like there are error paths when an
interrupt request to debugserver times out that cause this problem.

The thread plan stack access is never in a hot loop, and there
aren't enough of them for the extra data member to matter, so
there's really no good reason not to protect the access.

Adding the mutex revealed a couple of places where we were
using "auto" in an iteration when we should have been using
"auto &" - we didn't intend to copy the stack - and I fixed
those as well.

Except for preventing crashes this should be NFC.

Differential Revision: https\://reviews.llvm.org/D106122
lldb/include/lldb/Target/ThreadPlanStack.h
lldb/source/Target/ThreadPlanStack.cpp