This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Throwing C++ exceptions in signal handlers


I have a strange question to ask of the GCC folks that understand
more about exception handling and signals than I do.  Is it reasonable
(or safe) to throw an exception in a signal handler.

The reason I ask is that I was reading through the list of standard
C library functions that can't throw in "cp/cfns.gperf".  This lists
functions that are implicitly __attribute__((nothrow)) in g++, and
omits the obvious "qsort" and "bsearch" which can call user-written
functions.

However explicitly listed is the function "raise" that passes control
flow to a user-written signal handler, that might in theory be able to
throw an exception.  Potentially there could also be an issue with
the "atexit" routines being called from exit.

I notice that Linux supports sigsetjmp and siglongjmp, so there is
atleast some precedent for doing strange things in signal handlers.

Might it be safer to comment out "raise" in cp/cfns.gperf, or is
throwing an exception in a signal handler explicitly forbidden?

Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]