jeremy-rifkin / cpptrace

Simple, portable, and self-contained stacktrace library for C++11 and newer
MIT License
621 stars 64 forks source link

older version of glibc does not produce stacktrace in signal tracing #126

Closed WSUFan closed 3 months ago

WSUFan commented 3 months ago

It seems that in older versions of glibc (such as the one in Ubuntu 20), the following test will fail:

#include <dlfcn.h>
int main() {
    dl_find_object result;
    _dl_find_object(reinterpret_cast<void*>(main), &result);
}

As a result, cpptrace will not use _dl_find_object and will instead use dlopen (right?). This approach produces an empty stack trace (I guess the object path is not correct in this case?):

SIGSEGV occurred:
Stack trace (most recent call first):
<empty trace>

So, do we have any fallback functions to mimic the behavior of _dl_find_object?

Thanks!

jeremy-rifkin commented 3 months ago

Hi, correct, _dl_find_object is needed for getting information in a signal-safe way and I don’t know of any alternative. I should document that relatively recent glibc is needed.

WSUFan commented 3 months ago

Ok. Thanks for letting me know