From owner-freebsd-threads@FreeBSD.ORG Fri Aug 29 14:34:10 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 778F6106567E for ; Fri, 29 Aug 2008 14:34:10 +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 1553E8FC1A for ; Fri, 29 Aug 2008 14:34:10 +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 1KZ4gb-000K00-Ty; Fri, 29 Aug 2008 17:10:50 +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 m7TEAhnx007840 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 29 Aug 2008 17:10:44 +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 m7TEAhxb057105; Fri, 29 Aug 2008 17:10:43 +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 m7TEAhv1057100; Fri, 29 Aug 2008 17:10:43 +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: Fri, 29 Aug 2008 17:10:43 +0300 From: Kostik Belousov To: Andriy Gapon Message-ID: <20080829141043.GX2038@deviant.kiev.zoral.com.ua> References: <48B70A98.5060501@icyb.net.ua> <48B7101E.7060203@icyb.net.ua> <48B71BA6.5040504@icyb.net.ua> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="YvxfeT9y/1FRS2+9" Content-Disposition: inline In-Reply-To: <48B71BA6.5040504@icyb.net.ua> 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 1KZ4gb-000K00-Ty bdab99369f9b855193e40e9a23b484f5 X-Terabit: YES Cc: davidxu@freebsd.org, 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: Fri, 29 Aug 2008 14:34:10 -0000 --YvxfeT9y/1FRS2+9 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Aug 29, 2008 at 12:41:58AM +0300, Andriy Gapon wrote: > on 28/08/2008 23:52 Andriy Gapon said the following: > >So can all this be a result of an exception thrown before threads are=20 > >initialized? >=20 > This seems to be it. > I can reproduce the issue with the following small C++ program: >=20 > /*********************************************/ > #include >=20 >=20 > static void * thrfunc(void * arg) > { > return NULL; > } >=20 > int main(void) > { > pthread_t thr; >=20 > try { > throw int(1); > } > catch (...) {} >=20 > pthread_create(&thr, NULL, thrfunc, NULL); >=20 > return 0; > } > /*********************************************/ >=20 >=20 > $ uname -a > ... FreeBSD 7.0-STABLE #9: Sun Jul 6 17:13:22 EEST 2008 ... i386 >=20 > --=20 > Andriy Gapon I am wondering why did you not fixed it youself with all this information. Anyway, patch below seems to work for me. David may have an opinion on the change. diff --git a/lib/libthr/thread/thr_init.c b/lib/libthr/thread/thr_init.c index f96bba9..785d610 100644 --- a/lib/libthr/thread/thr_init.c +++ b/lib/libthr/thread/thr_init.c @@ -355,6 +355,9 @@ _libpthread_init(struct pthread *curthread) if (_thread_event_mask & TD_CREATE) _thr_report_creation(curthread, curthread); } + + if (_thr_isthreaded() =3D=3D 0) + _thr_setthreaded(1); } =20 /* --YvxfeT9y/1FRS2+9 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAki4A2IACgkQC3+MBN1Mb4ghwACg48Cq54kIYCRiNPZv4+9fQKsJ sycAniWJY6CZ2kw79wGzxCWaJfPCvq9L =Rdug -----END PGP SIGNATURE----- --YvxfeT9y/1FRS2+9--