Abort instead of throwing exceptions

C

ChessManiac

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 ?
 
G

Gianni Mariani

ChessManiac said:
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 :

(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 ?
 
I

Ivan Vecerina

ChessManiac said:
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
 
C

ChessManiac

Ivan Vecerina a écrit :
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.
 
C

ChessManiac

Gianni Mariani a écrit :
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 ?
 
I

Ivan Vecerina

ChessManiac said:
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.
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top