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

Zachary Turner via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Jan 11 14:23:56 PST 2018

zturner added a comment.

Seems like the high level problem is that the entity which acquires the mutex is not the same as the entity which decides how data gets into the Module.  For example, we call `SymbolVendor::FindFunctions` and expect that someone is going to somehow get some functions into the Module.  But it doesn't anticipate that that someone decides it wants to do it in a multi-threaded fashion.  I think as a general principle, when you have this kind of lazy access pattern, you need to clearly separate the responsibilities.  The entity that acquires the lock needs to be the same entity that updates the state.

In other words, something like this:

  // Not locked
  auto Functions = m_sym_file_ap->FindFunctions(...);
  // Now grab the lock and update the Module
  std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());


More information about the lldb-commits mailing list