3

I want to provide a generic call stack function as part of a library (.so) using libunwind. However, executables linked against the .so start to fail as soon as I link against libunwind. As I understand it, the problem I'm running into is that libunwind defines the same symbols as the GCC runtime, but the implementation is seemingly not compatible.

Linking statically or dynamically against libunwind doesn't change anything, I get a segfault when throwing an exception in _Unwind_Resume (if linked statically), otherwise the call-stack starts at __cxa_throw (presumably, it has been damaged before.)

Interestingly, the problems only occur when I use GCC, with Clang, everything works just fine.

Is it possible to use libunwind inside a shared library? If not, is there another library which allows me to obtained the name plus instruction pointer offset of the functions on the stack? backtrace() is nearly good enough, but backtrace_symbols() is doing too much formatting which I would have to "un-parse" first.

Anteru
  • 19,042
  • 12
  • 77
  • 121
  • It appears to work fine in my case. I am using gcc-4.8.2 and libunwind8. Could you post some code? – Icarus3 Jul 15 '14 at 13:41
  • That's the problem, it only fails in the larger application. I couldn't get it to repro in a small case; might be also related to visibility setting. – Anteru Jul 15 '14 at 16:13
  • I haven't had an issue doing this, either. A small reproducer would be helpful. – Tanner Firl Apr 07 '23 at 04:49

0 Answers0