diff options
| author | Jim Ingham <jingham@apple.com> | 2022-04-29 11:07:22 -0700 |
|---|---|---|
| committer | Jim Ingham <jingham@apple.com> | 2022-04-29 11:07:22 -0700 |
| commit | dca2bc408186667346ab3bbb951adab44feba5bd (patch) | |
| tree | f2fc81621486f20282056c27e323659f6821632c /lldb/source/Target/ThreadPlanStack.cpp | |
| parent | 6f79700830292d86afec5f3cf5143b00e6f3f1fd (diff) | |
Add a mutex to the ThreadPlanStackMap class.
We've seen very occasional crashes that we can only explain by
simultaneous access to the ThreadPlanStackMap, so I'm adding a
mutex to protect it.
Differential Revision: https://reviews.llvm.org/D124029
Diffstat (limited to 'lldb/source/Target/ThreadPlanStack.cpp')
| -rw-r--r-- | lldb/source/Target/ThreadPlanStack.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lldb/source/Target/ThreadPlanStack.cpp b/lldb/source/Target/ThreadPlanStack.cpp index 80634647f9e0..ac7b44cef37d 100644 --- a/lldb/source/Target/ThreadPlanStack.cpp +++ b/lldb/source/Target/ThreadPlanStack.cpp @@ -400,6 +400,7 @@ void ThreadPlanStackMap::Update(ThreadList ¤t_threads, bool delete_missing, bool check_for_new) { + std::lock_guard<std::recursive_mutex> guard(m_stack_map_mutex); // Now find all the new threads and add them to the map: if (check_for_new) { for (auto thread : current_threads.Threads()) { @@ -434,6 +435,7 @@ void ThreadPlanStackMap::DumpPlans(Stream &strm, lldb::DescriptionLevel desc_level, bool internal, bool condense_if_trivial, bool skip_unreported) { + std::lock_guard<std::recursive_mutex> guard(m_stack_map_mutex); for (auto &elem : m_plans_list) { lldb::tid_t tid = elem.first; uint32_t index_id = 0; @@ -470,6 +472,7 @@ bool ThreadPlanStackMap::DumpPlansForTID(Stream &strm, lldb::tid_t tid, bool internal, bool condense_if_trivial, bool skip_unreported) { + std::lock_guard<std::recursive_mutex> guard(m_stack_map_mutex); uint32_t index_id = 0; ThreadSP thread_sp = m_process.GetThreadList().FindThreadByID(tid); @@ -509,6 +512,7 @@ bool ThreadPlanStackMap::DumpPlansForTID(Stream &strm, lldb::tid_t tid, bool ThreadPlanStackMap::PrunePlansForTID(lldb::tid_t tid) { // We only remove the plans for unreported TID's. + std::lock_guard<std::recursive_mutex> guard(m_stack_map_mutex); ThreadSP thread_sp = m_process.GetThreadList().FindThreadByID(tid); if (thread_sp) return false; |
