• 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: Xcode 2.3 breaks bundle static object destruction? fuse-cxa-atexit? Help!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Xcode 2.3 breaks bundle static object destruction? fuse-cxa-atexit? Help!


  • Subject: Re: Xcode 2.3 breaks bundle static object destruction? fuse-cxa-atexit? Help!
  • From: "Darryl Trujillo" <email@hidden>
  • Date: Wed, 14 Jun 2006 14:29:33 -0700 (PDT)
  • Importance: Normal

On Jun 10, 2006, at 12:48 PM, Andy O'Meara wrote:
> Well, I don't understand why, in Mac OS X, ya developer would ever want
> a dynamic library's static deinit chain to be put in the host process's
deinit
> chain.  In Windows, for example, a dynamic library's static init chain
always
> occurs when a it's loaded (LoadLibrary()) and the its deinit chain is
> *always* called when the module is unloaded (FreeLibrary()) (where
LoadLibrary()
> and FreeLibrary() are the Windows analogs to CFBundleCreate() and
CFRelease()).
> So the fact that the default behavior for a dynamic library to do its
static deinit
> on the host process's static deinit chain leaves me totally baffled--I keep
> thinking that I must have a gross conceptual error regarding Mac OS X
dynamic
> libraries.

Yes you're missing something, but it's not your fault: Darwin's handling
of shared libraries is best described as "odd." First off, they
distinguish between shared libraries that are used as libraries ("dylibs")
and shared libraries that are used as plug-ins ("bundles" in the mach-o
container sense, not in the "application package" sense). Bundles can be
dynamically loaded/unloaded as you would expect, but dylibs, once  loaded,
are never actually unloaded, even if you call something like dlclose() and
it tells you it succeeded. That means they're "unloaded" at application
exit time and, yes, that's when any termination code will run. So it's not
that it's tied to the host's deinit chain, it just wasn't unloaded when
you thought it was.

The documentation here is contradictory, but I verified this behavior
under 10.3 a couple of years back. The man page for dlclose() might lead
you to expect dylibs to be unloaded on demand, but the 10.4 release notes
for dyld
(http://developer.apple.com/releasenotes/DeveloperTools/dyld.html) make it
 clear, in the "known issues" section, that  "Dynamic libraries (not
bundles) once loaded, can never be unloaded."

The take-away here is that, if you want dynamic load/unload behavior, you
need to build a bundle/plug-in, not a shared library.

    - dmt





 _______________________________________________
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

  • Prev by Date: Somewhat OT - Creating a Project Template from Working Project With Shell Script
  • Next by Date: XCODE 2.3 Debug Window display problem
  • Previous by thread: Re: Somewhat OT - Creating a Project Template from Working Project With Shell Script
  • Next by thread: XCODE 2.3 Debug Window display problem
  • Index(es):
    • Date
    • Thread