Throwing C++ exceptions from signal handlers
Jakub Jelinek
jakub@redhat.com
Thu Jun 10 09:38:00 GMT 2004
On Thu, Jun 10, 2004 at 12:20:20PM +0300, Yuval Kfir wrote:
> > > is it possible to somehow convince gcc to properly throw an exception
> from a
> > > signal handler context?
> >
> > Yes, but only with synchronous exceptions like SIGSEGV and SIGFPE.
>
> That's good news - but how? How should I modify the sample program so that
> it won't abort with gcc? Or should I use different flags?
Certainly you cannot expect you can throw exceptions through arbitrary
C library functions like raise ().
If you don't do this and want to handle synchronous exceptions, you need
at least -fnon-call-exceptions in all code that might raise synchronous
signals and/or -fasynchronous-unwind-tables in all code that might be
interrupted by asynchronous signals you want to throw from (obviously
you have to make sure that you don't throw while the asynchronous signal
interrupted some function without exception support).
Jakub
More information about the Gcc
mailing list