linux-mips
[Top] [All Lists]

Re: Float / Double issues - solved, perhaps

To: Ralf Baechle <ralf@uni-koblenz.de>, linux@cthulhu.engr.sgi.com
Subject: Re: Float / Double issues - solved, perhaps
From: Tim Hockin <thockin@cobaltnet.com>
Date: Wed, 14 Jul 1999 18:18:29 -0700
Cc: cjohnson@cobaltnet.com
Organization: Cobalt Networks
References: <378AADF5.96152E0B@cobaltnet.com> <19990714235346.A1231@uni-koblenz.de>
Sender: owner-linux@cthulhu.engr.sgi.com
Ralf Baechle wrote:

> On Mon, Jul 12, 1999 at 08:09:41PM -0700, Tim Hockin wrote:
>
> > Hey gang - I have what seems to be two seperate issues on Mips/Linux
> > (cobalt boxes).
> >
> > 1) Programs using doubles with pthreads get corrupted data in the
> > doubles.
>
> That one is funny.  It was/is a longstanding libc bug originally reported
> by Dong Liu.  I actually thought it'd be fixed but now thanks to your
> report I see it's still broken.  So the multithreaded variant of your
> double.c doesn't work at all on our libc.
>
> The bug is in glibc/sysdeps/unix/sysv/linux/mips/clone.S; I suppose
> Cobalt's libc which I last worked on late October is still using my
> old clone.S from that time or somebody else there came up with a funky
> new bug completly on it's own - which might explain why double.c cannot
> even successfully create the threads.

We have the fix, I think.  Not clone.S, but in
glibc-2.0.7/linuxthreads/internals.h line 86 we need to tell gcc that this
struct (_pthread_descr_struct - which defines the offset of a thread's stack
from a well-aligned, malloc() returned addr) be padded to be aligned
correctly on an 8byte boundary:

-};
+} __attribute__ ((aligned(__alignof__(double))));

It's working for us now.  Please confirm if it works for you folks, too.  A
bug report has been filed for glibc, though I doubt if anything official
goes on for 2.0.x, now. Hopefully 2.1.x will fold this in.  A thread's stack
really should always be well aligned :)  Funny, the doubles were actually
calculated right, but stdio functions use va_arg - which expected double's
to be aligned, and weren't.  The work got done, but it couldn't tell us!

As for the va_arg "bug" - I realized it was pilot error shortly after
sending it out.  I just needed to look at something that was NOT this double
bug for a while. :)  So the new question is who wants to do thread support
in gdb !!

Tim

<Prev in Thread] Current Thread [Next in Thread>