• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Exception handling and shared libraries
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Exception handling and shared libraries


  • Subject: Re: Exception handling and shared libraries
  • From: Steve Baxter <email@hidden>
  • Date: Fri, 3 Feb 2006 23:37:04 +0000

The problem is with a difference in the way that GCC handles RTTI compared to Codewarrior and most other environments. If your exception class is completely inline, it is possible for your shared libraries to have different copies of the type_info for the exception. With Codewarrior this doesn't matter - it compares types by name. With GCC, this is a problem as it compares type_info by pointer:

http://www.gnu.org/software/gcc/faq.html#dso
http://developer.apple.com/documentation/DeveloperTools/gcc-3.3/gcc/ Vague-Linkage.html


The solution to this *should* be to export all the symbols in your plugins and other shared libraries (or at least your exceptions) - this is what the code below does I think. I'm finding some circumstances where this doesn't seem to work completely though - the solution there might be to change the C++ runtime library back so that it compares by name not pointer. This will involve a small performance hit (negligible - who is worried about performance when handling exceptions), but will guarantee correct behaviour across shared library boundaries without unnecessary exporting of symbols.

Cheers,

Steve.

On 3 Feb 2006, at 21:57, Andy Finnell wrote:

I actually ran into this problem too.

I noticed that it knew what std::exception's were so I went and looked at the exception header (i.e. exceptions derived from std::exception were recognized as std::exception, not the derived class). Wrapped around the exception declaration it has this:

#pragma GCC visibility push(default)

extern "C++" {

// Exception declaration here

} // extern "C++"

#pragma GCC visibility pop

I did the same for my exception declarations and it worked.

HTH,

    -andy

--
Andy Finnell
Senior Software Architect
Order N Development, LLC
http://www.orderndev.com



On Feb 2, 2006, at 7:40 AM, Gert Thijs wrote:

Hi,

I have a question about the settings in Xcode to generate code that handles exception correctly.

We have developed a generic shared c++ library in one Xcode project in which we implemented several exception handling classes that inherit from std::exception. Now, we are working on a new c++ project in Xcode where we use this library together with a lot of new classes and also other shared libraries (eg. mysql++). Everything compiles without any problem and runs fine except when an exception is thrown from within the used shared libraries. These exceptions are not caught since the type does not seem to be the same.

I have searched quite a bit for information about this problem but I have never found a satisfactory answer on how to tackle this problem. As far as I understand it, the problem originates from the way the shared library is constructed and how objects in the library are referenced. So my guess is that there should be a set of options to Xcode or gcc or the linker to avoid this.

Has anyone any experience with this since I have tried several combination of options (like -fexceptions, -Bsymbolic) but none of them seemed to have any effect.

Gert

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40orderndev.com


This email sent to email@hidden


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40improvision.com


This email sent to email@hidden

Steve Baxter Software Development Manager Improvision +44-2476-692229

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Exception handling and shared libraries (From: Gert Thijs <email@hidden>)
 >Re: Exception handling and shared libraries (From: Andy Finnell <email@hidden>)

  • Prev by Date: Re: Exception handling and shared libraries
  • Next by Date: Re: Debugger questions
  • Previous by thread: Re: Exception handling and shared libraries
  • Next by thread: Re: lazy symbol binding failed
  • Index(es):
    • Date
    • Thread