Bug 12623

Summary: Certain valid numeric strings cause a SIGFPE when attempting
Product: Base System Reporter: m.seaman <m.seaman>
Component: alphaAssignee: robert
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 3.2-STABLE   
Hardware: Any   
OS: Any   

Description m.seaman 1999-07-13 12:30:00 UTC
Attempting to convert the string "2.49521e-297" into a double
precision value via strtod(3) results in a floating point exception on
the alphaev56 CPU.  The problem doesn't occur on i586.

The problem is sensitive to both the mantissa and exponent of the
number: the following values are known to trigger the bug:

2.49521e-297
3.35554e-295
1.14662e-292
1.14e-293
2.495e-293
2.49e-294
2.4e-293
1e-305

whereas these do not:

2.4e-292
2.49521e-292
2.4951e-293
1.14e-292
1.15e-293

Fix: 

not known
How-To-Repeat: 
#include <stdlib.h>

int
main (int argc, char *argv[])
{
  char str[32] = "2.49521e-297";
  double num;

  num = strtod (str, NULL);
}
Comment 1 Hidetoshi Shimokawa 1999-07-13 17:06:37 UTC
At Tue, 13 Jul 1999 12:27:40 +0100 (BST),
m.seaman@inpharmatica.co.uk wrote:
> >Description:
> 
> Attempting to convert the string "2.49521e-297" into a double
> precision value via strtod(3) results in a floating point exception on
> the alphaev56 CPU.  The problem doesn't occur on i586.

/usr/src/lib/libc/stdlib/strtod.c seems broken on alpha in three ways.

1) IEEE_8087 should be defined instead of IEEE_MC68k.

2) It assumes long is 32bit, but long is 64bit on alpha.
	s/unsigned long/u_int32_t/, s/long/int32_t/.

3) It generates denormal numbers which can not be treaded by the hardware
   on alpha. It should be compiled with the option
   `-mtrap-precision=i -mfp-trap-mode=su' to enable software completion.

-- 
/\ Hidetoshi Shimokawa
\/  simokawa@sat.t.u-tokyo.ac.jp
PGP public key: finger -l simokawa@sat.t.u-tokyo.ac.jp
Comment 2 robert freebsd_committer freebsd_triage 2002-11-17 16:49:15 UTC
State Changed
From-To: open->patched

A fix was committed to -CURRENT.
Comment 3 Kris Kennaway freebsd_committer freebsd_triage 2003-07-13 00:34:28 UTC
Responsible Changed
From-To: freebsd-alpha->robert

Robert reported that a fix was committed.
Comment 4 robert freebsd_committer freebsd_triage 2003-07-13 20:41:04 UTC
State Changed
From-To: patched->closed