Segfault in _Unwind_* code called from pthread_exit
Tijl Coosemans
tijl at FreeBSD.org
Sat Aug 26 21:33:58 UTC 2017
On Sat, 26 Aug 2017 21:40:34 +0300 Konstantin Belousov <kostikbel at gmail.com> wrote:
> On Sat, Aug 26, 2017 at 08:28:13PM +0200, Tijl Coosemans wrote:
>> On Sat, 26 Aug 2017 02:44:42 +0300 Konstantin Belousov <kostikbel at gmail.com> wrote:
>>> How does llvm unwinder detects that the return address is a garbage ?
>>
>> It just stops unwinding when it can't find frame information (stored in
>> .eh_frame sections). GCC unwinder doesn't give up yet and checks if the
>> return address points to the signal trampoline (which means the current
>> frame is that of a signal handler). It has built-in knowledge of how to
>> unwind to the signal trampoline frame.
> So llvm just gives up on signal frames ?
Looks like it. This program doesn't print anything when using base
libgcc_s. With gcc libgcc_s it prints:
0x400904 <handler+0x24> at /usr/home/tijl/testsig
0x7ffffffff173 <_fini+0x7fffffbfe7bb> at ???
cc -o test test.c -lexecinfo -lgcc_s -rpath /usr/local/lib/gcc5
----------------------------
#include <execinfo.h>
#include <signal.h>
void *buf[ 20 ];
size_t s;
void
handler( int sig ) {
s = backtrace( buf, 20 );
}
int
main( void ) {
signal( SIGINT, handler );
raise( SIGINT );
backtrace_symbols_fd( buf, s, 1 );
return( 0 );
}
----------------------------
More information about the freebsd-current
mailing list