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

Dimitry Andric via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 15 10:47:43 PDT 2020


dim added subscribers: emaste, dim.
dim added a comment.
Herald added a project: libunwind.
Herald added a reviewer: libunwind.

It seems that after this change, I'm getting sporadic lld segfaults in libunwind, which look like:

  Core was generated by `/usr/obj/share/dim/src/freebsd/clang1100-import/amd64.amd64/tmp/usr/bin/ld --sys'.
  Program terminated with signal SIGSEGV, Segmentation fault.
  #0  0x0000000002479166 in libunwind::findUnwindSectionsByPhdr(dl_phdr_info*, unsigned long, void*) ()
  [Current thread is 1 (LWP 100282)]
  (gdb) bt
  #0  0x0000000002479166 in libunwind::findUnwindSectionsByPhdr(dl_phdr_info*, unsigned long, void*) ()
  #1  0x000000000247a67c in libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_x86_64>::setInfoBasedOnIPRegister(bool) ()
  #2  0x000000000247927a in unw_init_local ()
  #3  0x0000000002477ba8 in _Unwind_Backtrace ()
  #4  0x0000000002416bb1 in backtrace ()
  #5  0x0000000001097c83 in llvm::sys::PrintStackTrace(llvm::raw_ostream&) ()
  #6  0x0000000001096105 in llvm::sys::RunSignalHandlers() ()
  #7  0x0000000001098676 in SignalHandler(int) ()
  #8  0x0000000002437c70 in handle_signal ()
  #9  0x0000000002437248 in thr_sighandler ()
  #10 <signal handler called>
  #11 0x0000000002479166 in libunwind::findUnwindSectionsByPhdr(dl_phdr_info*, unsigned long, void*) ()
  #12 0x000000000247a67c in libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_x86_64>::setInfoBasedOnIPRegister(bool) ()
  #13 0x000000000247927a in unw_init_local ()
  #14 0x000000000247884c in unwind_phase2_forced ()
  #15 0x0000000002478b43 in _Unwind_ForcedUnwind ()
  #16 0x00000000024421b6 in thread_unwind ()
  #17 0x000000000244211f in _pthread_exit_mask ()
  #18 0x000000000244208b in pthread_exit ()
  #19 0x000000000243fcf3 in thread_start ()
  #20 0x0000000000000000 in ?? ()
  Backtrace stopped: Cannot access memory at address 0x7fffdfbfc000

When I look at the code, it appears that it has inlined `FrameHeaderCache::add()`, and goes into the `else` part:

  Current = MostRecentlyUsed;
  CacheEntry *Previous = nullptr;
  while (Current->Next != nullptr) {
    Previous = Current;
    Current = Current->Next;
  }

However, it enters that part with `MostRecentlyUsed` being `nullptr`, and this causes a segfault in the expression `while (Current->Next != nullptr)`.

Would it make sense for `MostRecentlyUsed` to ever be null at this point, and if so, shouldn't the code be mitigating this?  And if `MostRecentlyUsed` should never be null, what could be the reason that it is?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75954



More information about the llvm-commits mailing list