473,320 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Abort instead of throwing exceptions

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
5 2359
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
"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
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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: M Joonas Pihlaja | last post by:
Dear c.l.c++, I'm trying to track down a bug in a program that appears only when throwing exceptions and the program is compiled with optimization. The problem is that the program aborts when...
21
by: mihai | last post by:
People say that is a bad technique to throw exception from constructors; and that the solution would be to create a function _create_ to initialize an object. What about copy constructors? How...
20
by: Doug Thews | last post by:
I ran into an interesting re-pain delay after calling the Abort() method on a thread, but it only happens the very first time I call it. Every time afterward, there is no delay. I've got a...
40
by: Kevin Yu | last post by:
is it a bad programming design to throw exception in the try block then catch it??
5
by: Bob Altman | last post by:
Hi all, I have a WinForms app that has no main window (just a module with a Sub Main). My Main routine calls a subroutine that wants to politely abort the application rather than return to its...
15
by: Dan Holmes | last post by:
In one of the other threads it was mentioned that using return values from methods to indicated success/failure of the method should be replaced with throwing exceptions. Which would mean code...
6
by: Marvin Barley | last post by:
I have a class that throws exceptions in new initializer, and a static array of objects of this type. When something is wrong in initialization, CGI program crashes miserably. Debugging shows...
7
by: Josh | last post by:
I have a lot of except Exception, e statements in my code, which poses some problems. One of the biggest is whenever I refactor even the triviallest thing in my code. I would like python to...
13
by: mike3 | last post by:
Hi. (crossposted because the program is in C++ and some C++-related elements are discussed, hence comp.lang.c++, plus general program design questions are asked, hence comp.programming.) I'm...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.