473,394 Members | 1,878 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,394 software developers and data experts.

Catching exceptions accross shared libraries

Hi

I have a scenario with exceptions that I cannot explain.

I have an exception class 'MyException' derived from 'std::exception'

There are two libraries 'plugin' and 'framework' linked together by
loading at runtime.

The issue is that an exception of type 'MyException' is being thrown in
'plugin' and caught in 'framework', but some throws get caught by the
'MyExeption' handler and some some throws get caught by the
'std::exception' handler, in the same try-catch block.

Has anybody got any ideas what could possibly cause this to happen ?

I only get this problem when building with gcc on Linux, I do not have
this problem with msvc

Cheers
N

Dec 22 '06 #1
4 3469
Nindi wrote:
Hi

I have a scenario with exceptions that I cannot explain.

I have an exception class 'MyException' derived from 'std::exception'

There are two libraries 'plugin' and 'framework' linked together by
loading at runtime.

The issue is that an exception of type 'MyException' is being thrown in
'plugin' and caught in 'framework', but some throws get caught by the
'MyExeption' handler and some some throws get caught by the
'std::exception' handler, in the same try-catch block.

Has anybody got any ideas what could possibly cause this to happen ?

I only get this problem when building with gcc on Linux, I do not have
this problem with msvc

The only real way of helping you is to show is the code. It could
possibly be a bug in gcc. What version of gcc are you using and are
framework and plugin build with the same compiler?
Dec 22 '06 #2

Gianni Mariani wrote:
Nindi wrote:
Hi

I have a scenario with exceptions that I cannot explain.

I have an exception class 'MyException' derived from 'std::exception'

There are two libraries 'plugin' and 'framework' linked together by
loading at runtime.

The issue is that an exception of type 'MyException' is being thrown in
'plugin' and caught in 'framework', but some throws get caught by the
'MyExeption' handler and some some throws get caught by the
'std::exception' handler, in the same try-catch block.

Has anybody got any ideas what could possibly cause this to happen ?

I only get this problem when building with gcc on Linux, I do not have
this problem with msvc


The only real way of helping you is to show is the code. It could
possibly be a bug in gcc. What version of gcc are you using and are
framework and plugin build with the same compiler?
I would like to show code .. but I don't think I could rip that part of
code out an reproduce the errors. I am also looking at
http://gcc.gnu.org/wiki/Visibility , I 'think' my problem is detailed
there. I am using gcc 4.1

Dec 22 '06 #3

Nindi wrote:
Gianni Mariani wrote:
Nindi wrote:
Hi
>
I have a scenario with exceptions that I cannot explain.
>
I have an exception class 'MyException' derived from 'std::exception'
>
There are two libraries 'plugin' and 'framework' linked together by
loading at runtime.
>
The issue is that an exception of type 'MyException' is being thrown in
'plugin' and caught in 'framework', but some throws get caught by the
'MyExeption' handler and some some throws get caught by the
'std::exception' handler, in the same try-catch block.
>
Has anybody got any ideas what could possibly cause this to happen ?
>
I only get this problem when building with gcc on Linux, I do not have
this problem with msvc

The only real way of helping you is to show is the code. It could
possibly be a bug in gcc. What version of gcc are you using and are
framework and plugin build with the same compiler?

I would like to show code .. but I don't think I could rip that part of
code out an reproduce the errors. I am also looking at
http://gcc.gnu.org/wiki/Visibility , I 'think' my problem is detailed
there. I am using gcc 4.1


OK .. I fixed it , but I still don't know what was wrong. The header
file for 'MyException' contained the class implementation as well as
the class definition, This header file was being included in both
'plugin' and 'framework' .
I moved the implementation out into a seperate library and linked it
in.
Now its the 'MyException' Handler and not the ''std::exception'
handler that catches 'MyException' .

Dec 23 '06 #4
Nindi wrote:
....
OK .. I fixed it , but I still don't know what was wrong. The header
file for 'MyException' contained the class implementation as well as
the class definition, This header file was being included in both
'plugin' and 'framework' .
I moved the implementation out into a seperate library and linked it
in.
Now its the 'MyException' Handler and not the ''std::exception'
handler that catches 'MyException' .
Yes. That might help. The issue is that the compiler generates
multiple versions of the "MyException" constructor (and possibly other
things) if the definition is in the header. By placing it in the
"framework" library you're limiting it to 1 compiled copy and hence
forcing the linker to use the version specified. I still think it's a
gcc bug though.
Dec 23 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Steven Reddie | last post by:
I understand that access violations aren't part of the standard C++ exception handling support. On Windows, a particular MSVC compiler option enables Microsoft's Structured Exception Handling...
10
by: Eric | last post by:
I have been researching how exceptions and dynamic_cast work to determine if I will use either feature for a game-console application. I have a few pre-concieved notions and questions that I was...
7
by: cmay | last post by:
FxCop complains every time I catch System.Exception. I don't see the value in trying to catch every possible exception type (or even figuring out what exceptions can be caught) by a given block...
5
by: steve bull | last post by:
I am trying to make my code conform to FXCop standards. The problem I have is when, for example, I try to catch errors generated by creating an instance of XmlTextWtriter FxCop insists that I only...
12
by: Vasco Lohrenscheit | last post by:
Hi, I have a Problem with unmanaged exception. In the debug build it works fine to catch unmanaged c++ exceptions from other dlls with //managed code: try { //the form loads unmanaged dlls...
7
by: akennis | last post by:
First of all, sorry for duplicating this post. I put it up in the alt.comp.lang.learn.c-c++ mistakenly. I'm investigating a problem whereby exceptions thrown from functions in a Shared Library...
4
by: foxx | last post by:
This is driving me nuts. I can't catch an exception thrown out of a ..so library. It passes up and terminates the program instead. Here is the code for the .so and the executabe, the compiler...
24
by: usenet | last post by:
I am unable to catch floating exceptions (e.g. divide by 0 or 0/0) using the standard exceptions defined in stdexcept. What is the recommended way to catch such exceptions? Thanks, Song
5
by: Tom P. | last post by:
I have a situation that requires me to catch two different types of exceptions but do the same processing. Is there a way to do this? In VB you can stack the Catch statements but what do I do in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.