[Lldb-commits] [lldb] [LLDB] Fix potential data race in Symtab initialization (PR #192753)
Adrian Prantl via lldb-commits
lldb-commits at lists.llvm.org
Sat Apr 18 09:54:18 PDT 2026
================
@@ -1126,6 +1126,7 @@ void Symtab::FindFunctionSymbols(ConstString name, uint32_t name_type_mask,
}
}
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (!m_name_indexes_computed)
InitNameIndexes();
----------------
adrian-prantl wrote:
I don't think that's a safe change because the block below calls `GetNameToSymbolIndexMap(type)` which accesses yet another member without any guards.
The entire interface of this class is relying on callers acquiring the mutex. I don't really know how expensive locking an already acquired recursive_mutex is, but assuming it is prohibitively expensive, a better interface would be a wrapper object that returns a locked query object and makes it impossible to forget to hold the mutex.
I did remove the redundant checks around the invocations of InitNameIndexes() though.
https://github.com/llvm/llvm-project/pull/192753
More information about the lldb-commits
mailing list