[libcxx-commits] [PATCH] D75954: Cache uwnind frame headers as they are found.

Dimitry Andric via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat Aug 15 12:17:06 PDT 2020


dim added a subscriber: hans.
dim added a comment.

Hm, the `static FrameHeaderCache ProcessFrameHeaderCache;` is biting us here, at least in a multithreaded process like lld, which is the process that is crashing for me all the time now. I added some instrumentation, which shows the problem by adding a thread ID to each log message, and by adding an assert in `FrameHeaderCache::add()` that `MostRecentlyUsed != nullptr`:

  cc -target x86_64-unknown-freebsd13.0 --sysroot=/usr/obj/usr/src/amd64.amd64/tmp -B/usr/obj/usr/src/amd64.amd64/tmp/usr/bin -Wl,--no-undefined -Wl,--version-script=/usr/src/contrib/com_err/version-script.map   -fstack-protector-strong -shared -Wl,-x -Wl,--fatal-warnings -Wl,--warn-shared-textrel  -o libcom_err.so.5.full -Wl,-soname,libcom_err.so.5  `NM='nm' NMFLAGS='' lorder com_err.pico error.pico |  tsort -q`
  libunwind FrameHeaderCache.hpp(57)[tid=0x803805a00]: FrameHeaderCache reset
  libunwind FrameHeaderCache.hpp(130)[tid=0x803805000]: UIS=0x7fffdfdfc9e0
  libunwind FrameHeaderCache.hpp(130)[tid=0x803805500]: UIS=0x7fffdfbfb9e0
  libunwind FrameHeaderCache.hpp(140)[tid=0x803805500]: Unused == nullptr, MostRecentlyUsed=0x0
  libunwind FrameHeaderCache.hpp(140)[tid=0x803805000]: Unused == nullptr, MostRecentlyUsed=0x0
  Assertion failed: (MostRecentlyUsed != nullptr), function add, file FrameHeaderCache.hpp, line 141.
  libunwind FrameHeaderCache.hpp(130)[tid=0x803805a00]: UIS=0x7fffdf9fa9e0
  libunwind FrameHeaderCache.hpp(134)[tid=0x803805a00]: Unused != nullptr
  PLEASE submit a bug report to https://bugs.freebsd.org/submit/ and include the crash backtrace.
  libunwind FrameHeaderCache.hpp(161)[tid=0x803805a00]: FrameHeaderCache add [b060b0 - 256ec70)
  cc: error: unable to execute command: Segmentation fault (core dumped)
  cc: error: linker command failed due to signal (use -v to see invocation)

So what you see here is that thread `0x803805a00` resets, then thread `0x803805000` and `0x803805500` simultaneously invoke `FrameHeaderCache::add()`, and that leads to both `Unused` and `MostRecentlyUsed` being `nulllptr`, resulting in the crash.

It looks like the need for some locking in this `FrameHeaderCache` was completely overlooked? Or at least, having a cache per thread would make locking unnecessary, but it would cost more memory.

@hans in the state this is in now, I would suggest this to be reverted for 11.0, otherwise you will end up with a seriously broken release for multi-threaded programs.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75954/new/

https://reviews.llvm.org/D75954



More information about the libcxx-commits mailing list