[PATCH] D157459: Make DWARFContext more thread safe.

Greg Clayton via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 8 17:15:44 PDT 2023


clayborg created this revision.
clayborg added reviewers: aprantl, labath, JDevlieghere, yinghuitan, dblaikie.
Herald added a subscriber: hiraditya.
Herald added a project: All.
clayborg requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

llvm-gsymutil uses a DWARFContext from multiple threads as it parses each compile unit. As it finds issues it might end up dumping a DIE to an output stream which can cause accesses to the DWARFContext from multiple threads. In llvm-gsymutil it can end up dumping a DIE from multiple threads into thread specific stream which was causing DWARFContext::getTUIndex() to be called and can crash the process.

This fix puts a recursive mutex into the DWARFContext class and makes most APIs threadsafe for access. Many of the methods in DWARFContext will check if a member variable has been filled in yet, and parse what is needed and populate a member variagle with the results. Now a mutex protects these functions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157459

Files:
  llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
  llvm/lib/DebugInfo/DWARF/DWARFContext.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157459.548411.patch
Type: text/x-patch
Size: 4797 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230809/d1062756/attachment.bin>


More information about the llvm-commits mailing list