From owner-freebsd-threads@FreeBSD.ORG Tue Sep 2 13:59:14 2008 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9972B1065694; Tue, 2 Sep 2008 13:59:14 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.terabit.net.ua (mail.terabit.net.ua [195.137.202.147]) by mx1.freebsd.org (Postfix) with ESMTP id 370108FC1B; Tue, 2 Sep 2008 13:59:13 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from skuns.zoral.com.ua ([91.193.166.194] helo=mail.zoral.com.ua) by mail.terabit.net.ua with esmtp (Exim 4.63 (FreeBSD)) (envelope-from ) id 1KaWPY-0005jk-5N; Tue, 02 Sep 2008 16:59:12 +0300 Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id m82Dx8TU097967 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 2 Sep 2008 16:59:08 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.2/8.14.2) with ESMTP id m82Dx8kW056417; Tue, 2 Sep 2008 16:59:08 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.2/8.14.2/Submit) id m82Dx722056414; Tue, 2 Sep 2008 16:59:07 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 2 Sep 2008 16:59:07 +0300 From: Kostik Belousov To: David Xu Message-ID: <20080902135907.GX2038@deviant.kiev.zoral.com.ua> References: <20080830184512.GH2038@deviant.kiev.zoral.com.ua> <48BBA369.9010108@freebsd.org> <48BBA925.1000303@icyb.net.ua> <20080901084548.GQ2038@deviant.kiev.zoral.com.ua> <48BBC9A3.1050905@icyb.net.ua> <20080901111215.GS2038@deviant.kiev.zoral.com.ua> <48BBDD6A.60002@icyb.net.ua> <20080901131724.GT2038@deviant.kiev.zoral.com.ua> <48BC990C.9020208@freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Wk+D4bxjv0bBail9" Content-Disposition: inline In-Reply-To: <48BC990C.9020208@freebsd.org> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: ClamAV version 0.93.3, clamav-milter version 0.93.3 on skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua X-Virus-Scanned: mail.terabit.net.ua 1KaWPY-0005jk-5N a083fdc56fbcc8f6eb225f13e688c036 X-Terabit: YES Cc: Daniel Eischen , Andriy Gapon , freebsd-threads@freebsd.org Subject: Re: mysterious hang in pthread_create 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: Tue, 02 Sep 2008 13:59:14 -0000 --Wk+D4bxjv0bBail9 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Sep 02, 2008 at 09:38:20AM +0800, David Xu wrote: > Kostik Belousov wrote: > >On Mon, Sep 01, 2008 at 03:17:46PM +0300, Andriy Gapon wrote: > >>on 01/09/2008 14:12 Kostik Belousov said the following: > >>>On Mon, Sep 01, 2008 at 01:53:23PM +0300, Andriy Gapon wrote: > >... > >>>>>>>The following silly patch fixes the problem Andriy encountered: > >>>>>>I can confirm - this fixed the issue for me. > >>>>>>David, thanks! > >>>>>Does libc_r still work with patch applied ? > >>>>In what sense? > >>>>The test program that I posted seems to hang in both cases (patched a= nd=20 > >>>>unpatched rtld). > >>>The David' patch changes the code used to support libc_r operations. > >>>Even on CURRENT, if you run 4.x-compiled binary with the support of > >>>compat-4x libraries, this code from /libexec/ld-elf.so.1 (installed > >>>by CURRENT buildworld) provides locking for rtld. > >>I understand, but I am not sure what exactly needs to be tested. > >>"Still works" is too broad in this context. > > > >I am not sure too. As I said, this one of the reason I prefered to not > >touch that code. >=20 > It should not affect other code outside the rtld. In fact, this patch > fixes the maintenance of synchronization between locks and thread_flag. > In current code, if you acquire a rwlock, and then acquire second > rwlock, the first one will work, but acquiring second lock will fail > and thread_flag is out of sync, this results bit flag leaking in > thread_flag, and later a _rtld_thread_init() call will transfer the > unlocked rwlock state to libthr as locked state, also the existing > code does not distinguish reader lock and writer lock, it blindly=20 > transfer lock state as write-lock, fortunately, in correct case, > it should not be called with any lock held, so the transferring > does not occur. Yes, I understand this. And, this code is used when threading implementation is provided by libc_r, see above. I have no objection against that patch, but I think that it shall be verified whether compat-4x threaded programs work correctly with the change. > Another question is why should dl_iterate_phdr() use exclusive lock ? > doesn't this cause all C++ exception to be executed in serialization > manner ? It is required by C++ runtime. See the commit log for r178807. --Wk+D4bxjv0bBail9 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAki9RqsACgkQC3+MBN1Mb4iTcQCgnkiWRz0LubydR3GBUgg+aKnV sFwAoOsJyPFdUXasAwocFjj1MUaI7vCA =OJp8 -----END PGP SIGNATURE----- --Wk+D4bxjv0bBail9--