This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB 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]

c++/2495: Calling a function that has a throw, but an out of frame exception handler via inferior function call results in sigabrt delivery to inferior


>Number:         2495
>Category:       c++
>Synopsis:       Calling a function that has a throw, but an out of frame exception handler via inferior function call results in sigabrt delivery to inferior
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Aug 05 17:28:01 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     pmuldoon@redhat.com
>Release:        6.8
>Organization:
>Environment:

>Description:
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 infthrow

(gdb) b main
Breakpoint 1 at 0x400b8c: file infthrow.cxx, line 31.

(gdb) r
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() 
Do nothing.
$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.
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/x-c++src; name="infthrow.cxx"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="infthrow.cxx"

I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnZvaWQgY2FsbF90aHJv
d19ub19pbmZyYW1lX2hhbmRsZXIgKCkKewogIGNvdXQgPDwgIlRocm93IGV4Y2VwdGlvbiB3aXRo
IHRoZSBoYW5kbGVyIGluIGFub3RoZXIgZnJhbWUuIiA8PCBlbmRsOwogIHRocm93IDIwOwp9CgoK
dm9pZCBjYWxsX3Rocm93X3dpdGhfaW5mcmFtZV9oYW5kbGVyICgpCnsKICB0cnkgCiAgICB7CiAg
ICAgIGNvdXQgPDwgIlRocm93IGV4Y2VwdGlvbiB3aXRoIHRoZSBoYW5kbGVyIGluIGFub3RoZXIg
ZnJhbWUuIiA8PCBlbmRsOwogICAgICB0aHJvdyAyMDsKICAgIH0KICBjYXRjaCAoLi4uKQogICAg
ewogICAgICBjb3V0IDw8ICJMb2NhbCBleGNlcHRpb24gaGFuZGxlZC4iIDw8IGVuZGw7CiAgICB9
Cn0KCnZvaWQgY2FsbF9ub25lICgpIAp7CiAgY291dCA8PCAiRG8gbm90aGluZy4iIDw8IGVuZGw7
Cn0KCmludCBtYWluICgpIHsKICBjYWxsX3Rocm93X3dpdGhfaW5mcmFtZV9oYW5kbGVyICgpOwog
IHRyeSAgCiAgICB7CiAgICAgIGNhbGxfdGhyb3dfbm9faW5mcmFtZV9oYW5kbGVyICgpOwogICAg
fQogIGNhdGNoICguLi4pICAKICAgIHsKICAgICAgY291dCA8PCAiT3V0IG9mIGZyYW1lIGV4Y2Vw
dGlvbiBjYXVnaHQuIiA8PCBlbmRsOwogICAgfQogIHJldHVybiAwOwp9Cg==


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