If correct, this fixes a 22 year old bug that exists since 4.4BSD alpha :)

In modf, when we go down the Lbig jump, f0:f1 is never set and just
contains gibberish. Usually NAN or 0.0. What we really want is just copy
the input out and be done.

This completely corrupts python when hashing floats for a dictionary.
Since the resulting hash is not stable, it makes python crash all over
the place: http://bugs.python.org/issue7424

Sparc64 is not affected afaict, it's register passing convention seems
to put floats in f0..., making the copied code work just fine ;)

Index: arch/sparc/gen/modf.S
===================================================================
RCS file: /home/vcs/cvs/openbsd/src/lib/libc/arch/sparc/gen/modf.S,v
retrieving revision 1.8
diff -u -p -r1.8 modf.S
--- arch/sparc/gen/modf.S       22 Aug 2012 17:19:35 -0000      1.8
+++ arch/sparc/gen/modf.S       6 Jun 2014 21:16:40 -0000
@@ -175,11 +175,11 @@ Lbig:
         */
 #ifdef __PIC__
        PICCY_SET(L0, %l0, %o7)
-       std     %f0, [%i2]              ! *ival = val;
+       std     %i0, [%i2]              ! *ival = val;
        ldd     [%l0], %f0              ! return 0.0;
 #else
        sethi   %hi(L0), %l0
-       std     %f0, [%i2]              ! *ival = val;
+       std     %i0, [%i2]              ! *ival = val;
        ldd     [%l0 + %lo(L0)], %f0    ! return 0.0;
 #endif
        ret

Reply via email to