[Lldb-commits] [lldb] [LLDB] Acquire the module mutex at the start of SetLoadAddress (PR #227149)
Jacob Lalonde via lldb-commits
lldb-commits at lists.llvm.org
Tue Sep 29 17:02:20 PDT 2026
https://github.com/Jlalond updated https://github.com/llvm/llvm-project/pull/227149
>From 63ada09823fb546d2c4f3cd9a669c02b5db57e2e Mon Sep 17 00:00:00 2001
From: Jacob Lalonde <jalalonde at fb.com>
Date: Mon, 28 Sep 2026 14:59:12 -0700
Subject: [PATCH 1/2] Acquire the module mutex at the start of SetLoadAddress,
becuase ObjectFileELF calls back to module to acquire the mutex, potentially
causing a deadlock
---
lldb/source/Core/Module.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 989410b23c997a..73caf527a4b9f8 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -1447,6 +1447,7 @@ bool Module::SetArchitecture(const ArchSpec &new_arch) {
bool Module::SetLoadAddress(Target &target, lldb::addr_t value,
bool value_is_offset, bool &changed) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
ObjectFile *object_file = GetObjectFile();
if (object_file != nullptr) {
changed = object_file->SetLoadAddress(target, value, value_is_offset);
>From 1d457a762aeb4aa6807a71d3426ac25bf4b0019a Mon Sep 17 00:00:00 2001
From: Jacob Lalonde <jalalonde at fb.com>
Date: Tue, 29 Sep 2026 17:01:47 -0700
Subject: [PATCH 2/2] Add a comment abut lock re-entry
---
lldb/source/Core/Module.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 73caf527a4b9f8..2d7cffb7b43984 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -1447,6 +1447,9 @@ bool Module::SetArchitecture(const ArchSpec &new_arch) {
bool Module::SetLoadAddress(Target &target, lldb::addr_t value,
bool value_is_offset, bool &changed) {
+ // Acquire the module mutex so that any re-entrant calls in
+ // ObjectFile::SetLoadAddress already own the recurisve mutex before
+ // acquiring a second lock.
std::lock_guard<std::recursive_mutex> guard(m_mutex);
ObjectFile *object_file = GetObjectFile();
if (object_file != nullptr) {
More information about the lldb-commits
mailing list