Skip to content

Commit 0ddcd20

Browse files
authored
Don't hold the Target's ModuleListLock over running LoadScriptingResourceInTarget (#138216)
That calls an unknown amount of Python code, and can do quite a bit of work - especially if people do things like launch scripted processes in this script affordance. Doing that while holding a major lock like the ModuleList lock is asking for trouble. I tried to make a test that would actually stall without this, but I couldn't come up with anything that reliably failed. You always have to get pretty unlucky.
1 parent 2f16cbc commit 0ddcd20

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lldb/source/Core/ModuleList.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,8 +1046,14 @@ bool ModuleList::LoadScriptingResourcesInTarget(Target *target,
10461046
bool continue_on_error) {
10471047
if (!target)
10481048
return false;
1049-
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
1050-
for (auto module : m_modules) {
1049+
m_modules_mutex.lock();
1050+
// Don't hold the module list mutex while loading the scripting resources,
1051+
// The initializer might do any amount of work, and having that happen while
1052+
// the module list is held is asking for A/B locking problems.
1053+
const ModuleList tmp_module_list(*this);
1054+
m_modules_mutex.unlock();
1055+
1056+
for (auto module : tmp_module_list.ModulesNoLocking()) {
10511057
if (module) {
10521058
Status error;
10531059
if (!module->LoadScriptingResourceInTarget(target, error,

0 commit comments

Comments
 (0)