I have a simple c++ program that throws an exception and tries to catch it.
But when I run it, it crashes with segmentation faul. Looking and the stack
trace, looks like the exception is thrown but no one catches it. Is this a
bug? There's a workaround?
The c++ file is:
---
include <iostream>
int main(void)
{
try
{
throw "Exception";
}
catch(...)
{
std::cout << "Exception catched" << std::endl;
}
}
---
more info:
$ uname -mprsv
OpenBSD 3.6 GENERIC#136 amd64 AMD Athlon(tm) 64 Processor 2800+
$ gcc -v
Reading specs from /usr/lib/gcc-lib/x86_64-unknown-openbsd3.6/3.3.2/specs
Configured with:
Thread model: single
gcc version 3.3.2 (propolice)
$ g++ -g -o test test.cpp
$ ./test
Abort (core dumped)
$ gdb test
GNU gdb 6.1
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-unknown-openbsd3.6"...
(gdb) run
Starting program: /home/scufre/test
Program received signal SIGABRT, Aborted.
0x000000004a065c1a in kill () from /usr/lib/libc.so.34.1
(gdb) bt
#0 0x000000004a065c1a in kill () from /usr/lib/libc.so.34.1
#1 0x000000004a092141 in abort () from /usr/lib/libc.so.34.1
#2 0x00000000004021ce in uw_init_context_1 (context=0x7f7fffff6650,
outer_cfa=0x7f7fffff6770,
outer_ra=0x4ef294c6) at /usr/src/gnu/usr.bin/gcc/gcc/unwind-dw2.c:1177
#3 0x0000000000402381 in _Unwind_RaiseException (exc=0x807050) at unwind.inc
:84
#4 0x000000004ef294c6 in __cxa_throw () from /usr/lib/libstdc++.so.32.0
#5 0x000000000040105c in main () at test.cpp:7