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

Catching exceptions accross shared libraries

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a

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

P: n/a

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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.