From owner-freebsd-threads@FreeBSD.ORG Thu Oct 5 23:48:03 2006 Return-Path: X-Original-To: freebsd-threads@freebsd.org Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4F0A616A407 for ; Thu, 5 Oct 2006 23:48:03 +0000 (UTC) (envelope-from kabaev@gmail.com) Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.181]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4640343D45 for ; Thu, 5 Oct 2006 23:48:02 +0000 (GMT) (envelope-from kabaev@gmail.com) Received: by py-out-1112.google.com with SMTP id o67so876966pye for ; Thu, 05 Oct 2006 16:48:01 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer:mime-version:content-type; b=st4dEZ31RunMFs6q9CUw/K1FSBuLTIbcSl6QDgZ1mCxL32o5Wb9tlXTPrgFyHZXZSj5/kBpF5kdnXIYjGcGKMTNTTyQKkXxNQX4B0SJdPDkW32MlxitgqO3dFRI2/HUqFVvV/2u9rbI91H+Eol/RmHmXIWwLgBoPCrHzvH/wIKs= Received: by 10.65.154.4 with SMTP id g4mr3245764qbo; Thu, 05 Oct 2006 16:48:01 -0700 (PDT) Received: from kan.dnsalias.net ( [24.63.93.195]) by mx.google.com with ESMTP id e18sm1692902qbe.2006.10.05.16.48.01; Thu, 05 Oct 2006 16:48:01 -0700 (PDT) Date: Thu, 5 Oct 2006 19:47:56 -0400 From: Alexander Kabaev To: John Baldwin Message-ID: <20061005194756.07580108@kan.dnsalias.net> In-Reply-To: <200610050906.21304.john@baldwin.cx> References: <200610041356.k94DuOmj097237@www.freebsd.org> <200610050906.21304.john@baldwin.cx> X-Mailer: Sylpheed-Claws 2.5.2 (GTK+ 2.8.20; i386-portbld-freebsd7.0) Mime-Version: 1.0 Content-Type: multipart/signed; boundary=Sig_olRQb9w73LRMGWxv5Pd0njU; protocol="application/pgp-signature"; micalg=PGP-SHA1 Cc: Takahiro , freebsd-gnats-submit@freebsd.org, KUROSAWA@freebsd.org, freebsd-threads@freebsd.org Subject: Re: threads/103975: Implicit loading/unloading of libpthread.so may crash user processes X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Oct 2006 23:48:03 -0000 --Sig_olRQb9w73LRMGWxv5Pd0njU Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Thu, 5 Oct 2006 09:06:20 -0400 John Baldwin wrote: >=20 > Actually, I wonder if it should be allowed to unload at all. On 4.x > at work we ran into an issue with the linuxthreads library loading, > setting _is_threaded, then unloading with a malloc() occurring during > the destructors resolving a _spinlock() weak symbol, then after the > libraries were completely unloaded, the next malloc() blew up when > _spinlock() pointed off into space. Hmm, this specific condition is > handled I think since __isthreaded in 6.x libpthread isn't set until > you do pthread_create() which at that point means a symbol is > resolved, and the library won't be unloaded (I think). Hmm, maybe > not since that doesn't guarantee that libc depends on libpthread > (that is what keeps it from being unloaded IIRC). So, maybe when the > library sets __isthreaded it should call one of the libc functions > (like malloc) to force one of the weak symbols to be resolved so it > isn't unloaded. >=20 > > To fix the problem, a function that has __attribute__((destructor)) > > in libpthread should probably be implemented in order to recover > > the initial state before unloading. >=20 > I'm not sure you can recover the state actually, hence why I think > maybe we should make it so that libpthread doesn't unload once it has > been loaded. >=20 > --=20 > John Baldwin Linux does not allow pthread library to be unloaded presumably because of reasons like this. From readelf -a /compat/linux/lib/libpthread.so.0: 0x6ffffffb (FLAGS_1) Flags: NODELETE INITFIRST Infortunately, rtld does not implement NODELETE and INITFIRST. Both are addressed in my patch that I am yet to commit. --=20 Alexander Kabaev --Sig_olRQb9w73LRMGWxv5Pd0njU Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (FreeBSD) iD8DBQFFJZmvQ6z1jMm+XZYRAkaKAJ9/bV9FU6UgIVbE7QZAhBLKD7rg5ACeMjGr 1DVtUSKdDtw5N2PFrbduuwc= =+av7 -----END PGP SIGNATURE----- --Sig_olRQb9w73LRMGWxv5Pd0njU--