From owner-freebsd-threads@FreeBSD.ORG Fri Aug 29 16:47:06 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 37CEB1065679; Fri, 29 Aug 2008 16:47:06 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.netplex.net (mail.netplex.net [204.213.176.10]) by mx1.freebsd.org (Postfix) with ESMTP id 554D68FC08; Fri, 29 Aug 2008 16:47:04 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.netplex.net (8.14.3/8.14.3/NETPLEX) with ESMTP id m7TGP9er009267; Fri, 29 Aug 2008 12:25:09 -0400 (EDT) X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.netplex.net) X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-4.0 (mail.netplex.net [204.213.176.10]); Fri, 29 Aug 2008 12:25:09 -0400 (EDT) Date: Fri, 29 Aug 2008 12:25:09 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Kostik Belousov In-Reply-To: <20080829143645.GY2038@deviant.kiev.zoral.com.ua> Message-ID: References: <48B70A98.5060501@icyb.net.ua> <48B7101E.7060203@icyb.net.ua> <48B71BA6.5040504@icyb.net.ua> <20080829141043.GX2038@deviant.kiev.zoral.com.ua> <48B8052A.6070908@icyb.net.ua> <20080829143645.GY2038@deviant.kiev.zoral.com.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-threads@freebsd.org, Andriy Gapon , davidxu@freebsd.org Subject: Re: mysterious hang in pthread_create X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Aug 2008 16:47:06 -0000 On Fri, 29 Aug 2008, Kostik Belousov wrote: > On Fri, Aug 29, 2008 at 05:18:18PM +0300, Andriy Gapon wrote: >> >> Kostik, thanks! >> >> on 29/08/2008 17:10 Kostik Belousov said the following: >>> I am wondering why did you not fixed it youself with all this information. >> >> I am wondering that myself now :-) >> I got bogged in rtld details and simply didn't think about the solution >> of doing setthreaded earlier. >> >> I will try your patch a couple of hours later. >> BTW, a forward question - should this patch help in the case of an >> exception thrown (and caught) before main(), i.e. in constructors of >> static/global objects? > If the objects are from the executable, then yes. I do not know about > present situation, but some time ago g++ and several other compilers > called ctr for global objects from the main() function. Regardeless > of this, init for main executable shall be called after init for > dependencies is finished. See initlist_add_objects(). > > On the other hand, ctr calls from linked dso may get fixed in regard > of exception throwing, or may not, depending on the relative order of > the dso loading against libthr. > >> >>> 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() == 0) >>> + _thr_setthreaded(1); >>> } >>> >>> /* I think the intent of __isthreaded (and _thr_setthreaded()) was to be set if there were more than 1 thread, not to indicate that the thread library has been initialized. -- DE