Sources Bugzilla – Bug 9600
Calling a function that has a throw, but an out of frame exception handler via inferior function call results in sigabrt delivery to inferior
Last modified: 2011-11-15 14:43:11 UTC
[Converted from Gnats 2495]
Please see attached test case C++ file. The test case has three functions
call_none () - basic test of inferior function call. Print then return.
call_throw_with_inframe_handler () - test where an exception is thrown and caught locally, within the same frame.
call_throw_no_inframe_handler () - test where an exception is thrown, but not caught locally. The catch for this is in main().
Output from GDB:
g++ -g infthrow.cxx -o infthrow
(gdb) b main
Breakpoint 1 at 0x400b8c: file infthrow.cxx, line 31.
Starting program: /home/pmuldoon/exceptions/infthrow
Breakpoint 1, main () at infthrow.cxx:31
31 call_throw_with_inframe_handler ();
(gdb) print call_throw_with_inframe_handler()
Throw exception with the handler in another frame.
Local exception handled.
$1 = void
(gdb) print call_none()
$2 = void
(gdb) print call_throw_no_inframe_handler()
throw exception with the handler in another frame
terminate called after throwing an instance of 'int'
Program received signal SIGABRT, Aborted.
0x0000003c49e32215 in raise () from /lib64/libc.so.6
The program being debugged was signaled while in a function called from GDB.
GDB remains in the frame where the signal was received.
To change this behavior use "set unwindonsignal on"
Evaluation of the expression containing the function (call_throw_no_inframe_handler()) will be abandoned.
It appears that when __cxa_throw calls __Unwind_RaiseException it is returning _URC_END_OF_STACK which means it cannot find a matching handler in any frame. This is probably due to the mechanics of inferior function calls. As a result, it cannot find the handler in main() and this defaults to the default C++ handler which calls abort.
The patch for this went in a while ago.