Re: Segfault in _Unwind_* code called from pthread_exit

From: Tijl Coosemans <tijl_at_FreeBSD.org>
Date: Sat, 26 Aug 2017 23:33:45 +0200
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 );
}
----------------------------
Received on Sat Aug 26 2017 - 19:33:58 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:13 UTC