Floating point exceptions with -pthread
deischen at freebsd.org
Wed May 4 14:47:09 PDT 2005
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:
> 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
fstcw -12(%ebp) /* store fpu control word */
orw $0x0400,%dx /* round towards -oo */
fldcw -16(%ebp) /* load modfied control word */
flds 8(%ebp); /* round */
fldcw -12(%ebp) /* restore original control word */
More information about the freebsd-threads