Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 Aug 2017 23:33:45 +0200
From:      Tijl Coosemans <tijl@FreeBSD.org>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        freebsd-current@FreeBSD.org, gerald@FreeBSD.org
Subject:   Re: Segfault in _Unwind_* code called from pthread_exit
Message-ID:  <20170826233345.348f73a3@kalimero.tijl.coosemans.org>
In-Reply-To: <20170826184034.GR1700@kib.kiev.ua>
References:  <20170823163707.096f93ab@kalimero.tijl.coosemans.org> <20170824154235.GD1700@kib.kiev.ua> <20170824180830.199885b0@kalimero.tijl.coosemans.org> <20170825173851.09116ddc@kalimero.tijl.coosemans.org> <20170825234442.GO1700@kib.kiev.ua> <20170826202813.1240a1ef@kalimero.tijl.coosemans.org> <20170826184034.GR1700@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 26 Aug 2017 21:40:34 +0300 Konstantin Belousov <kostikbel@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@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 );
}
----------------------------



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20170826233345.348f73a3>