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

Kostik Belousov kostikbel at gmail.com
Wed Nov 3 16:40:14 UTC 2010


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

From: Kostik Belousov <kostikbel at gmail.com>
To: Alexander Kabaev <kabaev at gmail.com>
Cc: Jaakko Heinonen <jh at freebsd.org>,
        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 18:37:56 +0200

 --WrZzWSSrfsHeDS1u
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 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.
 
 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().
 
 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->ne=
 xt)
 @@ -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;
 
 --WrZzWSSrfsHeDS1u
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.11 (FreeBSD)
 
 iEYEARECAAYFAkzRj+MACgkQC3+MBN1Mb4hlhgCePxx85hsAX8dFQNcd0YQPOUix
 ae8AoK/CdgarYRhNpgRnkuFh2t0Tq3rV
 =eA3x
 -----END PGP SIGNATURE-----
 
 --WrZzWSSrfsHeDS1u--


More information about the freebsd-bugs mailing list