From 662aa3c1f83bc7847591a2605034cb162d3a1fac Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Tue, 19 Nov 2024 15:50:15 -0800 Subject: [PATCH] [lldb] Acquire the map lock after deriving the lookup key The computation of the key may itself does DWARF lookups which may acquire additional locks through callbacks into TypeSystem. rdar://139841554 (cherry picked from commit a657eef5a38d74d92c2204ebce00cddfe5413b90) --- .../Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp b/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp index 6b8ec573d0690..5c584ca779a37 100644 --- a/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp +++ b/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp @@ -1911,7 +1911,6 @@ SwiftASTContext *TypeSystemSwiftTypeRefForExpressions::GetSwiftASTContext( SwiftASTContext *TypeSystemSwiftTypeRef::GetSwiftASTContextOrNull( const SymbolContext &sc) const { std::lock_guard guard(m_swift_ast_context_lock); - const char *key = nullptr; auto it = m_swift_ast_context_map.find(key); if (it != m_swift_ast_context_map.end()) @@ -1921,9 +1920,9 @@ SwiftASTContext *TypeSystemSwiftTypeRef::GetSwiftASTContextOrNull( SwiftASTContext *TypeSystemSwiftTypeRefForExpressions::GetSwiftASTContextOrNull( const SymbolContext &sc) const { - std::lock_guard guard(m_swift_ast_context_lock); - const char *key = DeriveKeyFor(sc); + + std::lock_guard guard(m_swift_ast_context_lock); auto it = m_swift_ast_context_map.find(key); if (it != m_swift_ast_context_map.end()) return llvm::cast_or_null(it->second.typesystem.get());