This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Exceptions aborting the program
- From: "Fernando Jeronymo" <FJeronym at siac dot com>
- To: bjensen at fastmail dot fm
- Cc: bjorn at fastmail dot fm, Fernando Jeronymo <FJeronym at siac dot com>, gcc-help at gcc dot gnu dot org, help at gcc dot gnu dot org
- Date: Tue, 6 Aug 2002 09:40:17 -0400
- Subject: Re: Exceptions aborting the program
but what happens is that in some part of the program I have something like
this:
MyClass::MyMthod()
{
AnotherClass anotherClass ;
try
{
throw 10;
}
catch(int& test)
{
std::cerr << test << std::endl ;
}
anotherClass.AnotherMethod();
}
AnotherClass::AnotherMethod()
{
try
{
throw 11;
}
catch(int& test)
{
std::cerr << test << std::endl ;
}
}
and he is going to throw 10 just fine. But when he tries to throw 11 he
aborts. Plus, any other throw that I have between the main statement and
the MyMethod work just fine. But after AnotherMethod any throw will make
the program to abort.
Any ideas?
stacktrace:
Is there any case where I should use any kind of flags to turn on or
enhance exception handling with gcc?
I have a software that aborts everytime I call an exception. But I can call
exceptions for some part of the code, and then suddenly just after I call a
function (the try-catch statement is the first thing inside my called
function) I try to throw another exception, and then my software abruptely
aborts.
Any help here would be really welcome!
Thanks,
Fernando
P.S> This is the coredump: As oyu can see, from frame 7 to 6 I am just
calling a function. In the part of code relative to frame 7, I throw two
integer exceptions right before calling the "postKeyStroke" function, and
there is nothing between the try-catch statements and the function call.
For frame 6, right in the beginning of my "postKeyStroke" function, I throw
another integer exception, but this time the program just aborts.
#0 0x42029241 in kill () from /lib/i686/libc.so.6
#1 0x4202902a in raise () from /lib/i686/libc.so.6
#2 0x4202a7d2 in abort () from /lib/i686/libc.so.6
#3 0x40178405 in __cxxabiv1::__terminate(void (*)()) (handler=0x4202a664
<abort>)
at ../../../../libstdc++-v3/libsupc++/eh_terminate.cc:47
#4 0x40178440 in __cxxabiv1::__unexpected(void (*)()) (handler=0x8633500)
at ../../../../libstdc++-v3/libsupc++/eh_terminate.cc:57
#5 0x401785b0 in __cxa_rethrow () at
../../../../libstdc++-v3/libsupc++/eh_throw.cc:77
#6 0x082c3de7 in STemplateCtl::postKeystroke(DBKEY) (this=0x86825d0,
key=DBKEY_A) at STemplateCtl.C:693
#7 0x081cac68 in StateControllerGlue::processInput(DBKEY) (this=0x86826c8,
key=DBKEY_A)
at StateControllerGlue.C:78
#8 0x081b5193 in Control::dispatchFromKeyboard(tagMESSAGE*)
(this=0x85ba5f8, msg=0xbfffcdc4)
at ControlReceive.C:1285
#9 0x081b260e in Control::dispatch(tagMESSAGE*) (this=0x85ba5f8,
msg=0xbfffcdc4) at ControlReceive.C:289
#10 0x081ddd92 in dispatchThruControl(void*, tagMESSAGE*) (msg=0xbfffcdc4)
at SEventLoop.C:453
#11 0x08327845 in SCallback<void (*)(void*, tagMESSAGE*),
tagMESSAGE*>::operator()(tagMESSAGE*) const (
this=0x8693858, a1=0xbfffcdc4) at
/mnt/pos.dspb/include/Business/SCallback.h:27
#12 0x08327893 in SCallback<void (*)(void*, tagMESSAGE*),
tagMESSAGE*>::execList(tagMESSAGE*) (this=0x0,
a1=0xbfffcdc4) at /mnt/pos.dspb/include/Business/SCallback.h:34
#13 0x081ddc9d in SEventLoop::dispatch(tagMESSAGE*) (this=0xbfffcda0,
msg=0xbfffcdc4) at SEventLoop.C:398
#14 0x081ddbba in SEventLoop::loop() (this=0xbfffcda0) at SEventLoop.C:363
#15 0x081ddc28 in SEventLoop::loopUntilMsg(tagMESSAGE*, unsigned short,
SProcedure<bool (*)(void*, tagMESSAGE*), bool, tagMESSAGE*>)
(this=0xbfffcda0, msgAddr=0x0, pq=3681, p={_proc = 0x81dd018 <xfer_never>,
_clientData = 0x0})
at SEventLoop.C:381
#16 0x081dd263 in SEventLoop::untilMsg(tagMESSAGE*, unsigned short,
SProcedure<bool (*)(void*, tagMESSAGE*), bool, tagMESSAGE*>, bool, bool,
SCallback<void (*)(void*, tagMESSAGE*), tagMESSAGE*>*, SCallback<void
(*)(void*, bool), bool>*) (pMsg=0x0, predQ=3681, p={_proc = 0x81dd018
<xfer_never>, _clientData = 0x0}, unlockKeyboard=false,
inheritDispatch=false, cbs=0x8693858, lprocs=0x86938f8) at
SEventLoop.C:148
#17 0x081ddf0c in SEventLoop::startTopLevel() () at SEventLoop.C:474
#18 0x08068108 in main (nArgc=5, szArgv=0xbffff0e4) at display.C:68
#19 0x42017499 in __libc_start_main () from /lib/i686/libc.so.6
bjorn rohde
jensen To: Fernando Jeronymo <FJeronym@siac.com>
<bjensen@fast cc: gcc-help@gcc.gnu.org
mail.fm> Subject: Re: Exceptions aborting the program
Sent by:
bjorn@fastmai
l.fm
08/06/2002
03:18 AM
Please
respond to
bjensen
Hi Fernando,
This entry in the trace, you provided, makes me think,
that your problem could be due to mismatching exception
specifications, which will lead to std::unexpected being
called. The default handler for unexpected simply terminates
the program.
> #4 0x40178440 in __cxxabiv1::__unexpected(void (*)())
(handler=0x8633500)
> at ../../../../libstdc++-v3/libsupc++/eh_terminate.cc:57
Yours sincerely,
Bjorn