This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: dlclose() doesn't unload any .so that uses Boost


On Mon, May 30, 2011 at 03:18:52PM +0200, J wrote:
> As you can see, dlclose() doesn't properly unload the .so, even though
> it claims that it has done so. If you'll remove this line:
> 
> boost :: signal< void () > signal;
> 
> it works properly:

On x86 with gcc-4.4.3, ld 2.21.51.20110509, glibc 2.11.1, libboost
1.40.0 I get
host: Loading libchild.so...
child: Constructor
host: so = 0x8240020
host: Unloading libchild.so...
child: Destructor
host: Unloaded.
host: (nil)

ie. the same result as your "works properly".  My guess would be that
your version of glibc handles dlclose differently to mine.  Note that
there are quite legitimate reasons that dlclose might not behave
as you expect, eg. if libchild.so was built with DF_1_NODELETE set.
That probably isn't the case here, but worth checking with readelf
whether that flag is set for libchild.so and any of its dependencies.

"LD_DEBUG=files ./host" for me shows (in part)

     26306:	calling init: ./libchild.so
     26306:	
child: Constructor
     26306:	opening file=./libchild.so [0]; direct_opencount=1
     26306:	
host: so = 0x9a86020
host: Unloading libchild.so...
     26306:	
     26306:	calling fini: ./libchild.so [0]
     26306:	
child: Destructor
     26306:	
     26306:	calling fini: /usr/lib/libboost_signals.so.1.40.0 [0]
     26306:	
     26306:	
     26306:	file=./libchild.so [0];  destroying link map
     26306:	
     26306:	file=/usr/lib/libboost_signals.so.1.40.0 [0];  destroying link map
host: Unloaded.
host: (nil)
     26306:	
     26306:	calling fini: ./host [0]

-- 
Alan Modra
Australia Development Lab, IBM


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]