From owner-freebsd-bugs@FreeBSD.ORG Wed Nov 3 20:30:15 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DD5A41065697 for ; Wed, 3 Nov 2010 20:30:14 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id C11958FC1B for ; Wed, 3 Nov 2010 20:30:14 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id oA3KUEJi055663 for ; Wed, 3 Nov 2010 20:30:14 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id oA3KUEK5055658; Wed, 3 Nov 2010 20:30:14 GMT (envelope-from gnats) Date: Wed, 3 Nov 2010 20:30:14 GMT Message-Id: <201011032030.oA3KUEK5055658@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Kostik Belousov Cc: Subject: Re: misc/151861: dlclose() of library causes separately opened libraries to unload as well X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Kostik Belousov List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Nov 2010 20:30:15 -0000 The following reply was made to PR misc/151861; it has been noted by GNATS. From: Kostik Belousov To: Jaakko Heinonen Cc: Alexander Kabaev , Arjan van Leeuwen , bug-followup@freebsd.org, kan@freebsd.org Subject: Re: misc/151861: dlclose() of library causes separately opened libraries to unload as well Date: Wed, 3 Nov 2010 22:27:50 +0200 --45BN1MGjfyYG1snq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Nov 03, 2010 at 08:48:24PM +0200, Jaakko Heinonen wrote: > On 2010-11-03, Kostik Belousov wrote: > > 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 > I prefer this one. Could you also add assert(root->dag_inited); to > ref_dag() and unref_dag()? This is reasonable but IMHO risky asserts. I added them as requested, will see how it going. Any further suggestions or objections ? If not, I will commit this tomorrow morning. diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index f1ffc3e..bf21586 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; @@ -3085,6 +3083,7 @@ ref_dag(Obj_Entry *root) { Objlist_Entry *elm; =20 + assert(root->dag_inited); STAILQ_FOREACH(elm, &root->dagmembers, link) elm->obj->refcount++; } @@ -3094,6 +3093,7 @@ unref_dag(Obj_Entry *root) { Objlist_Entry *elm; =20 + assert(root->dag_inited); STAILQ_FOREACH(elm, &root->dagmembers, link) elm->obj->refcount--; } --45BN1MGjfyYG1snq Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAkzRxcYACgkQC3+MBN1Mb4i2OwCfZBkstpjnLsrNvOrdin/1W2C/ UDoAnAjHo3/SWSm7ZC46+Vvoa7ZGI33J =EVSb -----END PGP SIGNATURE----- --45BN1MGjfyYG1snq--