public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug math/864] New: pow() causes segmentation fault by endless recursion
@ 2005-04-21  6:59 anemo at mba dot ocn dot ne dot jp
  2005-05-22 18:46 ` [Bug math/864] " olecom at gmail dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: anemo at mba dot ocn dot ne dot jp @ 2005-04-21  6:59 UTC (permalink / raw)
  To: glibc-bugs

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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug math/864] pow() causes segmentation fault by endless recursion
  2005-04-21  6:59 [Bug math/864] New: pow() causes segmentation fault by endless recursion anemo at mba dot ocn dot ne dot jp
@ 2005-05-22 18:46 ` olecom at gmail dot com
  2005-12-30  9:48 ` aj at suse dot de
  2006-01-31  7:59 ` anemo at mba dot ocn dot ne dot jp
  2 siblings, 0 replies; 4+ messages in thread
From: olecom at gmail dot com @ 2005-05-22 18:46 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From olecom at gmail dot com  2005-05-22 18:46 -------
<http://www.open-std.org/jtc1/sc22/wg14/www/docs/9899-1999_cor_2-2004.pdf>:

INTERNATIONAL STANDARD ISO/IEC 9899:1999
TECHNICAL CORRIGENDUM 2
...
4. Page 23, 5.2.4.2.2
   Add a new paragraph after paragraph 3:
          An implementation may give zero and non-numeric values (such as
          infinities and NaNs) a sign or may leave them unsigned. Wherever
          such values are unsigned, any requirement in this International
          Standard to retrieve the sign shall produce an unspecified sign,
          and any requirement to set the sign shall be ignored.

-----

So, maybe glibc has some features. Anyway segfault must be fixed.


-- 


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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug math/864] pow() causes segmentation fault by endless recursion
  2005-04-21  6:59 [Bug math/864] New: pow() causes segmentation fault by endless recursion anemo at mba dot ocn dot ne dot jp
  2005-05-22 18:46 ` [Bug math/864] " olecom at gmail dot com
@ 2005-12-30  9:48 ` aj at suse dot de
  2006-01-31  7:59 ` anemo at mba dot ocn dot ne dot jp
  2 siblings, 0 replies; 4+ messages in thread
From: aj at suse dot de @ 2005-12-30  9:48 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From aj at suse dot de  2005-12-30 09:48 -------
We're not going to fix pow - the MIPS software FPU has to fix this, it should
behave the same as a real FPU does.

I agree with Ralf in:
http://www.linux-mips.org/archives/linux-mips/2005-04/msg00217.html

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX


http://sourceware.org/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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug math/864] pow() causes segmentation fault by endless recursion
  2005-04-21  6:59 [Bug math/864] New: pow() causes segmentation fault by endless recursion anemo at mba dot ocn dot ne dot jp
  2005-05-22 18:46 ` [Bug math/864] " olecom at gmail dot com
  2005-12-30  9:48 ` aj at suse dot de
@ 2006-01-31  7:59 ` anemo at mba dot ocn dot ne dot jp
  2 siblings, 0 replies; 4+ messages in thread
From: anemo at mba dot ocn dot ne dot jp @ 2006-01-31  7:59 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From anemo at mba dot ocn dot ne dot jp  2006-01-31 07:59 -------
FYI, the fix for the kernel's FPU emulator is in linux-mips GIT repository now.

http://www.linux-mips.org/git?p=linux.git;a=commit;h=e243f3c204e5767909c87e7ceb7625b165183345


-- 


http://sourceware.org/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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-01-31  7:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-21  6:59 [Bug math/864] New: pow() causes segmentation fault by endless recursion anemo at mba dot ocn dot ne dot jp
2005-05-22 18:46 ` [Bug math/864] " olecom at gmail dot com
2005-12-30  9:48 ` aj at suse dot de
2006-01-31  7:59 ` anemo at mba dot ocn dot ne dot jp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).