[Lldb-commits] [PATCH] D109013: [lldb] Tighten lock in Language::ForEach
Alex Langford via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Aug 31 15:47:40 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG862a311301f5: [lldb] Tighten lock in Language::ForEach (authored by bulbazord).
Changed prior to commit:
https://reviews.llvm.org/D109013?vs=369758&id=369809#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109013/new/
https://reviews.llvm.org/D109013
Files:
lldb/source/Target/Language.cpp
Index: lldb/source/Target/Language.cpp
===================================================================
--- lldb/source/Target/Language.cpp
+++ lldb/source/Target/Language.cpp
@@ -108,10 +108,21 @@
}
});
- std::lock_guard<std::mutex> guard(GetLanguagesMutex());
- LanguagesMap &map(GetLanguagesMap());
- for (const auto &entry : map) {
- if (!callback(entry.second.get()))
+ // callback may call a method in Language that attempts to acquire the same
+ // lock (such as Language::ForEach or Language::FindPlugin). To avoid a
+ // deadlock, we do not use callback while holding the lock.
+ std::vector<Language *> loaded_plugins;
+ {
+ std::lock_guard<std::mutex> guard(GetLanguagesMutex());
+ LanguagesMap &map(GetLanguagesMap());
+ for (const auto &entry : map) {
+ if (entry.second)
+ loaded_plugins.push_back(entry.second.get());
+ }
+ }
+
+ for (auto *lang : loaded_plugins) {
+ if (!callback(lang))
break;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109013.369809.patch
Type: text/x-patch
Size: 979 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210831/14cfdeb2/attachment.bin>
More information about the lldb-commits
mailing list