From owner-freebsd-threads@FreeBSD.ORG Fri Nov 21 06:12:19 2003 Return-Path: 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 4238B16A4CF; Fri, 21 Nov 2003 06:12:19 -0800 (PST) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 663EA43FEA; Fri, 21 Nov 2003 06:12:18 -0800 (PST) (envelope-from eischen@vigrid.com) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mail.pcnet.com (8.12.10/8.12.1) with ESMTP id hALECF1G000395; Fri, 21 Nov 2003 09:12:15 -0500 (EST) Date: Fri, 21 Nov 2003 09:12:15 -0500 (EST) From: Daniel Eischen X-Sender: eischen@pcnet5.pcnet.com To: David Xu In-Reply-To: <3FBE061B.3070206@freebsd.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: David Xu cc: threads@freebsd.org cc: Marcel Moolenaar Subject: Re: KSE/ia64 broken X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: deischen@freebsd.org List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Nov 2003 14:12:19 -0000 On Fri, 21 Nov 2003, David Xu wrote: > Marcel Moolenaar wrote: > > >Ok. More pieces of the puzzle. If I apply the attached patch (against > >clean sources), I get the following: > > > >itanium% ./foo.bad > >XXX:_thr_alloc: thread=200000000008a000, tcb=2000000000085000 > >XXX:_thr_alloc: thread=2000000000090000, tcb=2000000000090000 > > > >The second _thr_alloc() is screwed up, in that malloc() returns > >the same pointer twice. Hence thread->tcb points to thread itself > >and we're clobbering our thread structure. > > > I saw the same result. > > >Since thr_spinlock.c > >affects the locking of malloc(), we may have a race condition. > >Note that forcing an upcall (by adding a _thread_printf() in the > >code stream) seems to fix it. Does the UTS call malloc when first > >invoked? > > > > > > > No, we never call malloc in such case. I suspect we do not > fully restore thread's context. In kernel, I pass zero as third > parameter to get_mcontext(), is it enough for ia64 ? Well, we do call malloc at library initialization. We malloc initial KSE & thread, locks, and a few other things. But this is before __isthreaded gets set (so the spinlock shouldn't be used). All this is done before the first thread is created. -- Dan Eischen