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

Alexander Kabaev kabaev at gmail.com
Wed Nov 3 22:00:26 UTC 2010


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

From: Alexander Kabaev <kabaev at gmail.com>
To: Kostik Belousov <kostikbel at gmail.com>
Cc: Jaakko Heinonen <jh at freebsd.org>, 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 17:55:42 -0400

 --Sig_/ykcQFMB+TmLB+hf/2HXyXRY
 Content-Type: text/plain; charset=US-ASCII
 Content-Transfer-Encoding: quoted-printable
 
 On Wed, 3 Nov 2010 18:37:56 +0200
 Kostik Belousov <kostikbel at gmail.com> wrote:
 
 > On Wed, Nov 03, 2010 at 12:27:33PM -0400, Alexander Kabaev wrote:
 > > On Wed, 3 Nov 2010 18:20:30 +0200
 > > Kostik Belousov <kostikbel at gmail.com> wrote:
 > > ...
 > > > ready initialized DAGs but feel free to do whatever you think is
 > > > > best. =20
 > > > I do not like it too, but this is the current interface of
 > > > init_dag(). Intermediate version of the latest patch removed the
 > > > ref_dag() part from init_dag(). Would you prefer this ?
 > >=20
 > > I would, but I lack time following all the patch versions flying
 > > around, so I am not sure I am talking about the right one.
 >=20
 > By intermediate I mean private intermediate state in my working tree.
 > Below is the patch augmented with the change to not call ref_dag()
 > from init_dag().
 >=20
 > diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
 > index f1ffc3e..b5fb6e1 100644
 > --- a/libexec/rtld-elf/rtld.c
 > +++ b/libexec/rtld-elf/rtld.c
 > @@ -1276,7 +1276,7 @@ init_dag(Obj_Entry *root)
 >      DoneList donelist;
 > =20
 >      if (root->dag_inited)
 > -	    return;
 > +	return;
 >      donelist_init(&donelist);
 >      init_dag1(root, root, &donelist);
 >      root->dag_inited =3D true;
 > @@ -1290,7 +1290,6 @@ init_dag1(Obj_Entry *root, Obj_Entry *obj,
 > DoneList *dlp) if (donelist_check(dlp, obj))
 >  	return;
 > =20
 > -    obj->refcount++;
 >      objlist_push_tail(&obj->dldags, root);
 >      objlist_push_tail(&root->dagmembers, obj);
 >      for (needed =3D obj->needed;  needed !=3D NULL;  needed =3D
 > needed->next) @@ -2031,6 +2030,7 @@ dlopen(const char *name, int mode)
 >  	    assert(*old_obj_tail =3D=3D obj);
 >  	    result =3D load_needed_objects(obj, RTLD_LO_DLOPEN);
 >  	    init_dag(obj);
 > +	    ref_dag(obj);
 >  	    if (result !=3D -1)
 >  		result =3D rtld_verify_versions(&obj->dagmembers);
 >  	    if (result !=3D -1 && ld_tracing)
 > @@ -2054,10 +2054,8 @@ dlopen(const char *name, int mode)
 >  	     * already loaded as a dependency, initialize the dag
 >  	     * starting at it.
 >  	     */
 > -	    if (obj->dl_refcount =3D=3D 1)
 > -		init_dag(obj);
 > -	    else
 > -		ref_dag(obj);
 > +	    init_dag(obj);
 > +	    ref_dag(obj);
 > =20
 >  	    if (ld_tracing)
 >  		goto trace;
 
 This is one that is least confusing and I like it. Thanks.=20
 
 --=20
 Alexander Kabaev
 
 --Sig_/ykcQFMB+TmLB+hf/2HXyXRY
 Content-Type: application/pgp-signature; name=signature.asc
 Content-Disposition: attachment; filename=signature.asc
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.16 (FreeBSD)
 
 iD8DBQFM0dpnQ6z1jMm+XZYRAn1DAKC2AOFZjncDv3aIwYHdciHTN28nOACg5d/X
 YZmVyabqGdtJC3+czb+KZUo=
 =FiaC
 -----END PGP SIGNATURE-----
 
 --Sig_/ykcQFMB+TmLB+hf/2HXyXRY--


More information about the freebsd-bugs mailing list