[PATCH] D62169: [Target] Protect Processes' language runtimes map with a mutex
Alex Langford via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 22 15:58:46 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361442: [Target] Protect Processes' language runtimes map with a mutex (authored by xiaobai, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62169/new/
https://reviews.llvm.org/D62169
Files:
lldb/trunk/include/lldb/Target/Process.h
lldb/trunk/source/Target/Process.cpp
Index: lldb/trunk/include/lldb/Target/Process.h
===================================================================
--- lldb/trunk/include/lldb/Target/Process.h
+++ lldb/trunk/include/lldb/Target/Process.h
@@ -2701,6 +2701,7 @@
bool m_should_detach; /// Should we detach if the process object goes away
/// with an explicit call to Kill or Detach?
LanguageRuntimeCollection m_language_runtimes;
+ std::recursive_mutex m_language_runtimes_mutex;
InstrumentationRuntimeCollection m_instrumentation_runtimes;
std::unique_ptr<NextEventAction> m_next_event_action_up;
std::vector<PreResumeCallbackAndBaton> m_pre_resume_actions;
Index: lldb/trunk/source/Target/Process.cpp
===================================================================
--- lldb/trunk/source/Target/Process.cpp
+++ lldb/trunk/source/Target/Process.cpp
@@ -660,7 +660,10 @@
m_image_tokens.clear();
m_memory_cache.Clear();
m_allocated_memory_cache.Clear();
- m_language_runtimes.clear();
+ {
+ std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex);
+ m_language_runtimes.clear();
+ }
m_instrumentation_runtimes.clear();
m_next_event_action_up.reset();
// Clear the last natural stop ID since it has a strong reference to this
@@ -1549,6 +1552,7 @@
if (m_finalizing)
return nullptr;
+ std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex);
LanguageRuntimeCollection::iterator pos;
pos = m_language_runtimes.find(language);
if (pos == m_language_runtimes.end() || (retry_if_null && !(*pos).second)) {
@@ -1562,6 +1566,7 @@
}
CPPLanguageRuntime *Process::GetCPPLanguageRuntime(bool retry_if_null) {
+ std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex);
LanguageRuntime *runtime =
GetLanguageRuntime(eLanguageTypeC_plus_plus, retry_if_null);
if (runtime != nullptr &&
@@ -1571,6 +1576,7 @@
}
ObjCLanguageRuntime *Process::GetObjCLanguageRuntime(bool retry_if_null) {
+ std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex);
LanguageRuntime *runtime =
GetLanguageRuntime(eLanguageTypeObjC, retry_if_null);
if (runtime != nullptr && runtime->GetLanguageType() == eLanguageTypeObjC)
@@ -5604,7 +5610,10 @@
m_jit_loaders_up.reset();
m_image_tokens.clear();
m_allocated_memory_cache.Clear();
- m_language_runtimes.clear();
+ {
+ std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex);
+ m_language_runtimes.clear();
+ }
m_instrumentation_runtimes.clear();
m_thread_list.DiscardThreadPlans();
m_memory_cache.Clear(true);
@@ -5673,14 +5682,17 @@
// Iterate over a copy of this language runtime list in case the language
// runtime ModulesDidLoad somehow causes the language runtime to be
// unloaded.
- LanguageRuntimeCollection language_runtimes(m_language_runtimes);
- for (const auto &pair : language_runtimes) {
- // We must check language_runtime_sp to make sure it is not nullptr as we
- // might cache the fact that we didn't have a language runtime for a
- // language.
- LanguageRuntimeSP language_runtime_sp = pair.second;
- if (language_runtime_sp)
- language_runtime_sp->ModulesDidLoad(module_list);
+ {
+ std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex);
+ LanguageRuntimeCollection language_runtimes(m_language_runtimes);
+ for (const auto &pair : language_runtimes) {
+ // We must check language_runtime_sp to make sure it is not nullptr as we
+ // might cache the fact that we didn't have a language runtime for a
+ // language.
+ LanguageRuntimeSP language_runtime_sp = pair.second;
+ if (language_runtime_sp)
+ language_runtime_sp->ModulesDidLoad(module_list);
+ }
}
// If we don't have an operating system plug-in, try to load one since
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62169.200833.patch
Type: text/x-patch
Size: 3853 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190522/ecd3a887/attachment.bin>
More information about the llvm-commits
mailing list