By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,417 Members | 1,035 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,417 IT Pros & Developers. It's quick & easy.

Abort instead of throwing exceptions

P: n/a
Hi

I cannot use a method that is supposed to raise an exception,
because GCC *aborts* the program before throwing the exception !

The method belongs to a class that is inside a dynamic library
(provided by a vendor, so I cannot change it)
try {
instance->Method();
}
catch (LIB::Exc &e) {
cout << "Exception handled" << endl;
}
catch (const std::exception& x) {
cerr << "Error : UNKNOWN STD EXCEPTION" << endl;
}
catch (...) {
cerr << "Error : UNKNOWN EXCEPTION" << endl;
}
The program nevers go into the catch statements.

With the debugger I see the following :
0x4092b721 in kill () from /lib/libc.so.6
#1 0x4043c771 in pthread_kill () from /lib/libpthread.so.0
#2 0x4043ca7b in raise () from /lib/libpthread.so.0
#3 0x4092b4d4 in raise () from /lib/libc.so.6
#4 0x4092c9e8 in abort () from /lib/libc.so.6
#5 0x408b2ba7 in __cxxabiv1::__terminate(void (*)()) (handler=0x4092c870 <abort>) at ../../../../gcc-3.2.2/libstdc++-v3/libsupc++/eh_terminate.cc:47
/opt/src/gcc-3.2.2/libstdc++-v3/libsupc++/eh_terminate.cc:47:1856:beg:0x408b2ba7
#6 0x408b2bf4 in std::terminate() () at ../../../../gcc-3.2.2/libstdc++-v3/libsupc++/eh_terminate.cc:57
#7 0x408b2d76 in __cxa_throw () at ../../../../gcc-3.2.2/libstdc++-v3/libsupc++/eh_throw.cc:77
/opt/src/gcc-3.2.2/libstdc++-v3/libsupc++/eh_throw.cc:77:2810:beg:0x408b2d76
#8 0x4028da68 in DtFederateMgr::testReadFedFile(RtiDtString, RtiDtString) () from libLIB.so
..... etc


In eh_throw.cc, GCC doesn't throw the exception but calls terminate instead !

I use g++ (GCC 3.2.2) the Operating System is Linux Debian/Woody
with a GLIBC 2.3

I tried many things (not successfully) such as compile with
-fexceptions, -pthread, -shared, -DTHREAD, -DPTHREADS, -DREENTRANT
and to link with lstdc++, -lpthread .....
Any idea ?
Jul 22 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
ChessManiac wrote:
Hi

I cannot use a method that is supposed to raise an exception,
because GCC *aborts* the program before throwing the exception !
....
With the debugger I see the following :
> 0x4092b721 in kill () from /lib/libc.so.6
> #1 0x4043c771 in pthread_kill () from /lib/libpthread.so.0
> #2 0x4043ca7b in raise () from /lib/libpthread.so.0
> #3 0x4092b4d4 in raise () from /lib/libc.so.6
> #4 0x4092c9e8 in abort () from /lib/libc.so.6
> #5 0x408b2ba7 in __cxxabiv1::__terminate(void (*)()) (handler=0x4092c870 <abort>) at

....
Any idea ?


The third party code looks like it double throws (raise() twice in the
stack trace) which results in terminate.

Do you know which exception is being thown ?

Jul 22 '05 #2

P: n/a
"ChessManiac" <Ch*********@tele2.fr> wrote in message
news:40**************@tele2.fr...
I cannot use a method that is supposed to raise an exception,
because GCC *aborts* the program before throwing the exception ! .... Any idea ?


Do you happen to be using any throw-specifications in your program?
e.g.: void f() throw();

What is exactly the statement that you are using to throw
the exception?
e.g.: a naked call to "throw;" will terminate the program
if not invoked during the execution of a catch-handler.

For testing, try putting your throw statement immediately
after the enclosing "try", then move it down to find
where the problem occurs.

This is what I can think of from a standard C++ perspective.

If this does not help, you may want to ask for support on
a GCC-dedicated forum -- in can also be a configuration problem.
hth-Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- e-mail contact form

Jul 22 '05 #3

P: n/a
Ivan Vecerina a écrit :
"ChessManiac" <Ch*********@tele2.fr> wrote in message
news:40**************@tele2.fr...
I cannot use a method that is supposed to raise an exception,
because GCC *aborts* the program before throwing the exception !
...
Any idea ?

Do you happen to be using any throw-specifications in your program?
e.g.: void f() throw();


The library is not mine ; it is provided by a vendor so I can't
see the internal code.
But in the include, the function "f" is declared to throw
an exception.
By the way, the program works with an old version of the
library (compatible with gcc3.0)

What is exactly the statement that you are using to throw
the exception?
e.g.: a naked call to "throw;" will terminate the program
if not invoked during the execution of a catch-handler.

For testing, try putting your throw statement immediately
after the enclosing "try", then move it down to find
where the problem occurs.

This is what I can think of from a standard C++ perspective.

If this does not help, you may want to ask for support on
a GCC-dedicated forum -- in can also be a configuration problem.
Thank you Ivan, do you know any gcc-dedicated forum ?
I ask this because my Internet provider has very few newsgroups
on his nntp server.
hth-Ivan

Jul 22 '05 #4

P: n/a
Gianni Mariani a écrit :
ChessManiac wrote:
Hi

I cannot use a method that is supposed to raise an exception,
because GCC *aborts* the program before throwing the exception !

...

With the debugger I see the following :
> 0x4092b721 in kill () from /lib/libc.so.6
> #1 0x4043c771 in pthread_kill () from /lib/libpthread.so.0
> #2 0x4043ca7b in raise () from /lib/libpthread.so.0
> #3 0x4092b4d4 in raise () from /lib/libc.so.6
> #4 0x4092c9e8 in abort () from /lib/libc.so.6
> #5 0x408b2ba7 in __cxxabiv1::__terminate(void (*)())

(handler=0x4092c870 <abort>) at


...

Any idea ?

The third party code looks like it double throws (raise() twice in the
stack trace) which results in terminate.

Do you know which exception is being thown ?

Yes I know because the program works with an old version of
the library (but compiled with gcc3.0, an old and bugged version
of the compiler).
How can this help ?
Jul 22 '05 #5

P: n/a
"ChessManiac" <Ch*********@tele2.fr> wrote in message
news:9r*******************@nntpserver.swip.net...
Ivan Vecerina a écrit :
By the way, the program works with an old version of the
library (compatible with gcc3.0)


Gianny and I tried to list some of the situations in which
throwing an exception will result in program termination.
But we can't really tell more given the information you
provided.
If this does not help, you may want to ask for support on
a GCC-dedicated forum -- in can also be a configuration problem.


Thank you Ivan, do you know any gcc-dedicated forum ?
I ask this because my Internet provider has very few newsgroups
on his nntp server.


See http://gcc.gnu.org/lists.html for mailing lists.
I remember that some publicly available nntp servers mirror
popular linux/gnu mailing lists, but I do not have a link at hand.

But if you are using a closed source library, maybe its developer
would be a better person to contact...
hth
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- e-mail contact form


Jul 22 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.