misc/151861: dlclose() of library causes separately opened libraries to unload as well

Jaakko Heinonen jh at FreeBSD.org
Wed Nov 3 10:10:11 UTC 2010


The following reply was made to PR misc/151861; it has been noted by GNATS.

From: Jaakko Heinonen <jh at FreeBSD.org>
To: Kostik Belousov <kostikbel at gmail.com>
Cc: Arjan van Leeuwen <freebsd-maintainer at opera.com>,
	bug-followup at freebsd.org, kan at freebsd.org
Subject: Re: misc/151861: dlclose() of library causes separately opened
 libraries to unload as well
Date: Wed, 3 Nov 2010 12:06:49 +0200

 On 2010-11-02, Kostik Belousov wrote:
 > Why do you think that your patch is not correct ?
 
 Well, I didn't say that I think it's incorrect. :)
 
 > I feel that more explicit handling of the state of the DAG is cleaner.
 
 I don't disagree but there is a problem with your patch. If an object
 has the DF_1_NODELETE flag set, dag is initialized in
 load_needed_objects(). In this case the reference count isn't correctly
 bumped in dlopen() because dag_inited is already set.
 
 (BTW. I think that there shouldn't be the ref_dag(obj1) call in
 load_needed_objects(). Now the reference count is increased twice in the
 nodelete case.)
 
 > --- a/libexec/rtld-elf/rtld.c
 > +++ b/libexec/rtld-elf/rtld.c
 > @@ -1275,8 +1275,11 @@ init_dag(Obj_Entry *root)
 >  {
 >      DoneList donelist;
 >  
 > +    if (root->dag_inited)
 > +	    return;
 
 Why init_dag() should be allowed to be called multiple times for an
 object?
 
 Thanks.
 -- 
 Jaakko


More information about the freebsd-bugs mailing list