This is the mail archive of the glibc-bugs@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug math/864] New: pow() causes segmentation fault by endless recursion


With linux-mips kernel's FPU emulator, libc's pow() causes
segmentation fault on particular values.

Here is a test program to reproduce it.

main()
{
	union {
		double d;
		struct {
#ifdef __MIPSEB	/* Big Endian */
			unsigned int high, low;
#else	/* Little Endian */
			unsigned int low, high;
#endif
		} i;
	} x, y, z;
        x.i.low = 0x00000000;
        x.i.high = 0xfff00001;
        y.i.low = 0x80000000;
        y.i.high = 0xcff00000;
        z.d = pow(x.d, y.d);
        printf("%x %x\n", z.i.high, z.i.low);
        return 0;
}

If you run this program, you will get segmentation fault.  The
segmentation fault is caused by endless recursion in __ieee754_pow().

It looks glibc's pow() assume unary '-' operation for any number
(including NaN) always invert its sign bit.

sysdeps/ieee754/dbl-64/e_pow.c:__ieee754_pow():
    return (k==1)?__ieee754_pow(-x,y):-__ieee754_pow(-x,y); /* if y even or odd */

But FPU emulator in mips-linux kernel keeps the sign of a NaN
unchanged for "NEG.d" instruction.  According to the IEEE 754, libc
should not depend on the sign of a NaN.

The original report to linux-mips ML is:
http://www.linux-mips.org/cgi-bin/mesg.cgi?a=linux-mips&i=20050420.174023.113589096.nemoto%40toshiba-tops.co.jp

-- 
           Summary: pow() causes segmentation fault by endless recursion
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: minor
          Priority: P2
         Component: math
        AssignedTo: aj at suse dot de
        ReportedBy: anemo at mba dot ocn dot ne dot jp
                CC: glibc-bugs at sources dot redhat dot com
 GCC build triplet: mips-linux, mipsel-linux
  GCC host triplet: mips-linux, mipsel-linux
GCC target triplet: mips-linux, mipsel-linux


http://sources.redhat.com/bugzilla/show_bug.cgi?id=864

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]