[Lldb-commits] [PATCH] D41909: Fix deadlock in dwarf logging

Francis Ricci via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Jan 10 09:29:26 PST 2018


fjricci created this revision.
fjricci added reviewers: clayborg, zturner, tberghammer.
Herald added subscribers: JDevlieghere, aprantl.

When dwarf parse logging is enabled (ie `log enable dwarf info`),
deadlocks can occur during dwarf parsing:

Thread 1:
`SymbolVendor::FindFunctions` (acquires mutex for Module)
`SymbolFileDWARF::Index`
<spawn task pool for `ExtractDIEsIfNeeded`>

Task pool threads:
`ExtractDIEsIfNeeded`
`Module::LogMessageVerboseBacktrace`
`Module::GetDescription` (tries to acquire mutex for Module and deadlocks)

Since `GetDescription` is read-only, only touches fairly immutable data
(architecture and filename), and is only used for logging,
the most straightforward fix is to remove the lock guard from this
function.


https://reviews.llvm.org/D41909

Files:
  source/Core/Module.cpp


Index: source/Core/Module.cpp
===================================================================
--- source/Core/Module.cpp
+++ source/Core/Module.cpp
@@ -1077,8 +1077,6 @@
 }
 
 void Module::GetDescription(Stream *s, lldb::DescriptionLevel level) {
-  std::lock_guard<std::recursive_mutex> guard(m_mutex);
-
   if (level >= eDescriptionLevelFull) {
     if (m_arch.IsValid())
       s->Printf("(%s) ", m_arch.GetArchitectureName());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41909.129290.patch
Type: text/x-patch
Size: 435 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20180110/02032c8a/attachment.bin>


More information about the lldb-commits mailing list