From owner-freebsd-threads@FreeBSD.ORG Wed May 4 21:47:09 2005 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 A306E16A4CE for ; Wed, 4 May 2005 21:47:09 +0000 (GMT) Received: from mail.ntplx.net (mail.ntplx.net [204.213.176.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4D9B743D54 for ; Wed, 4 May 2005 21:47:09 +0000 (GMT) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) j44LP4Bq024900; Wed, 4 May 2005 17:25:04 -0400 (EDT) Date: Wed, 4 May 2005 17:25:04 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Marc Olzheim In-Reply-To: <20050504202200.GD76171@stack.nl> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.ntplx.net) cc: freebsd-threads@freebsd.org Subject: Re: Floating point exceptions with -pthread X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 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: Wed, 04 May 2005 21:47:09 -0000 On Wed, 4 May 2005, Marc Olzheim wrote: > On Wed, May 04, 2005 at 09:51:53PM +0200, Marc Olzheim wrote: > > On Wed, May 04, 2005 at 03:15:06PM -0400, Daniel Eischen wrote: > > > > It seems to me like something about the floorf() assembly might have > > > > something to do with it. > > > > > > Yeah, I was just trying to narrow down the problem a bit more. > > > > I've attached one that's built very tight around floorf(). > > Replacing floorf() in the program by: > fabs() > rintf() > sqrt() > expf() > log10f() > logf() > cosf() > powf(,) > > doesn't crash. > > The only two functions I found to crash are floorf() and ceilf(). > > Replacing all floats by doubles and using floor() or ceil() doesn't > crash either. floorf() seems to fiddle with the FP control word. The kernel and libpthread use fxsave and fxrstor respectively. These save and restore the control word, but something may not be working correctly. ENTRY(floorf) pushl %ebp movl %esp,%ebp subl $8,%esp fstcw -12(%ebp) /* store fpu control word */ movw -12(%ebp),%dx orw $0x0400,%dx /* round towards -oo */ andw $0xf7ff,%dx movw %dx,-16(%ebp) fldcw -16(%ebp) /* load modfied control word */ flds 8(%ebp); /* round */ frndint fldcw -12(%ebp) /* restore original control word */ leave ret -- DE