Closed jlsantiago0 closed 1 year ago
This actually isn't something that I can fix in libbacktrace. The libbacktrace library relies on _Unwind_Backtrace
, which is provided by the compiler. That function is responsible for knowing how to unwind through a signal handler.
You didn't mention which compiler you are using, but this is a bug either in the compiler, or in MUSL, or in the interaction between them.
Ah OK:
gcc --version
gcc (Alpine 11.2.1_git20220219) 11.2.1 20220219
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
OK. Thank you for the quick reply. I appreciate this library quite a bit.
When using GCC it unwinds through a signal handler by recognizing the code in the signal handler. For x86 see https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libgcc/config/i386/linux-unwind.h;h=5486223d60272c73d5103b29ae592d2ee998e1cf;hb=HEAD
I opened a ticket with Alpine. Hopefully they will be able to fix this:
Hi,
Love this library, it is working well for me in most places. I am unable to see past the signal handler trampoline with MUSL runtime used by Alpine Linux. I tested with Alpine v3.9 and v3.16.
I have a test program that registers a signal handler for SIGABRT which uses static global pointer that was created before main started running as follows:
backtrace_create_state(NULL, 0, LibBackTraceErrorCB, NULL)
Notice that the stack dump wont get past the signal handler trampoline:
BTW: If I do a backtrace in normal operation it works fine. Jus t not in the signal handler.