public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Signal handlers and _Unwind_IsSignalFrame
@ 2008-09-09 13:37 Martin Bouzek
  2008-09-10  5:19 ` Ian Lance Taylor
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Bouzek @ 2008-09-09 13:37 UTC (permalink / raw)
  To: gcc-help

Hi,

I have a problem. I want to handle signals like SIGSEGV in non-main
threads of C++ program and terminate thread by pthread_exit call. Of
course I need all destructors of objects on stack to be called (eg.
mutex unlocking).

When compiling with -fnon-call-exceptios everything almost works but:

In context is saved address of failing instruction, not adress of
instruction after the failing one. Thus decrementing of this address in
__gxx_personality_v0 sometimes leads to calling of terminate(), because
no suitable entry in call-site table (?is it the right name?) is found
in .gcc_except_table. 

It is clearly supposed to be handled by SIGNAL_FRAME_BIT in flagss in
struct _Unwind_Context. But this bit is not set in my context. That is
why __gxx_personality misses proper handler by one byte, and calls
terminate instead. If I put one simple pointer dereference before my
failing instruction, decremented address is now inside the range
described in call-site table and everything works fine.

I am not sure I understand well how the SIGNAL_FRAME_BIT flag is
supposed to be set. Shall there be a CIE with "S" augmentation
in .eh_frame for signal handler? Threre is not such one in my program.
How can I make gcc to create one? Or am I completely wrong?

Just for completenes I have tried with gcc 4.1.0 and 4.2.1 on x86_64
(Suse 10.1 and 10.3).

Thanks in advance



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Signal handlers and _Unwind_IsSignalFrame
  2008-09-09 13:37 Signal handlers and _Unwind_IsSignalFrame Martin Bouzek
@ 2008-09-10  5:19 ` Ian Lance Taylor
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2008-09-10  5:19 UTC (permalink / raw)
  To: Martin Bouzek; +Cc: gcc-help

Martin Bouzek <martin.bouzek@radas-atc.cz> writes:

> I have a problem. I want to handle signals like SIGSEGV in non-main
> threads of C++ program and terminate thread by pthread_exit call. Of
> course I need all destructors of objects on stack to be called (eg.
> mutex unlocking).
>
> When compiling with -fnon-call-exceptios everything almost works but:
>
> In context is saved address of failing instruction, not adress of
> instruction after the failing one. Thus decrementing of this address in
> __gxx_personality_v0 sometimes leads to calling of terminate(), because
> no suitable entry in call-site table (?is it the right name?) is found
> in .gcc_except_table. 
>
> It is clearly supposed to be handled by SIGNAL_FRAME_BIT in flagss in
> struct _Unwind_Context. But this bit is not set in my context. That is
> why __gxx_personality misses proper handler by one byte, and calls
> terminate instead. If I put one simple pointer dereference before my
> failing instruction, decremented address is now inside the range
> described in call-site table and everything works fine.
>
> I am not sure I understand well how the SIGNAL_FRAME_BIT flag is
> supposed to be set. Shall there be a CIE with "S" augmentation
> in .eh_frame for signal handler? Threre is not such one in my program.
> How can I make gcc to create one? Or am I completely wrong?

In ordinary use the signal_frame and SIGNAL_FRAME_BIT flags is set by
machine dependent code which recognizes a symbol frame.  In the gcc
source code for x86_64 GNU/Linux this is in the file
gcc/config/i386/linux-unwind.h.  Perhaps that code is not working for
you, but I have no idea why not.

Note that you can have this sort of problem when using some versions
of libunwind instead of the unwind code which comes with gcc.  You
would know if you are doing that, though; you need to configure gcc
with --with-system-libunwind.

Ian

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-09-10  5:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-09 13:37 Signal handlers and _Unwind_IsSignalFrame Martin Bouzek
2008-09-10  5:19 ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).