• 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: dlclose changed behavior in 10.5.7
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dlclose changed behavior in 10.5.7


  • Subject: Re: dlclose changed behavior in 10.5.7
  • From: Peter O'Gorman <email@hidden>
  • Date: Wed, 27 May 2009 09:49:20 -0500

Shai Shasag wrote:
> My code uses dlopen/dlclose to load/unload dynamic libraries.
>
> Until 10.5.7 dlclose would close the library and the library's file.
> When I upgraded to 10.5.7 the library remains open even after dlclose
> returns.
>
> In both cases dlclose return value is 0.
>
> I see that the dll file is still open by running lsof (after dlclose was
> called) from the command line:
>
> lsof | grep dll_name
>
> Under 10.5.6 and before this command return nothing - meaning the dll
> file was closed.
>
> Under 10.5.7 I get the a line with the name of the dll:
>
> app_name   3434 shai  txt      REG      14,3    326312   2538026
> /path/to/dll/dll_name
>
> Did dlclose change it's behaviour in 10.5.7?

I don't know if dlclose() changed its behavior in 10.5.7, however,
http://opensource.apple.com does not show dyld as being updated in
10.5.7, nor did I see it mentioned in the release notes or security
updates (but I could've missed it).

Is the dll a bundle or a dylib (otool -hv /path/to/dll will show you a
filetype of either BUNDLE or DYLIB)?

If it is a dylib, did you see this section of the dlclose man page?
"
Prior to Mac OS X 10.5, only bundles could be unloaded.  Starting in Mac
OS X 10.5, dynamic libraries may also be unloaded.  There are a couple
of cases in which a dynamic library will never be unloaded: 1) the main
executable links against it, 2) An API that does not supoort unloading
(e.g. NSAddImage()) was used to load it or some other dynnamic library
that depends on it, 3) the dynamic library is in dyld's shared cache.
"

Also, are you sure your code didn't change? dlopen/dlclose keep a
refcount to the opened image, it is not removed until the refcount
reaches zero, if you open it twice, it will stay around until you close
it twice.

And lastly, dlclose() is not required to do much at all by posix, which
states "The use of dlclose() reflects a statement of intent on the part
of the process, but does not create any requirement upon the
implementation", so dlclose could simply be implemented as 'int
dlclose(void * unused) {return 0;}' and be standards conforming, if your
code can not deal with that case, perhaps it should.

http://www.opengroup.org/onlinepubs/9699919799/functions/dlclose.html

Peter
--
Peter O'Gorman
http://pogma.com
 _______________________________________________
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

  • Follow-Ups:
    • Re: dlclose changed behavior in 10.5.7
      • From: Shai Shasag <email@hidden>
References: 
 >dlclose changed behavior in 10.5.7 (From: Shai Shasag <email@hidden>)

  • Prev by Date: Re: configuration error in trying to build library for 10.4 sdk
  • Next by Date: Recognizing new document icons
  • Previous by thread: dlclose changed behavior in 10.5.7
  • Next by thread: Re: dlclose changed behavior in 10.5.7
  • Index(es):
    • Date
    • Thread