From mcclure@cs.unm.edu  Thu Mar  2 20:05:30 1995
Received: from mimbres.cs.unm.edu (mimbres.cs.unm.edu [198.59.151.2]) by freefall.cdrom.com (8.6.9/8.6.6) with SMTP id UAA00764 for <FreeBSD-gnats-submit@freebsd.org>; Thu, 2 Mar 1995 20:05:29 -0800
Received: from chaco.cs.unm.edu by mimbres.cs.unm.edu (5.65/033093) with SMTP
	id <AA18277@mimbres.cs.unm.edu>; Thu, 2 Mar 95 21:05:26 -0700
Received: by chaco.cs.unm.edu (5.65/011293)
	id AA18921; Thu, 2 Mar 1995 21:05:25 -0700
Message-Id: <9503030405.AA18921@chaco.cs.unm.edu>
Date: Thu, 2 Mar 95 21:05:24 MST
From: mcclure@cs.unm.edu
To: FreeBSD-gnats-submit@freebsd.org
Subject: acos() core dump

>Number:         229
>Category:       misc
>Synopsis:       acos() core dump
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bde
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Mar  2 20:10:02 1995
>Closed-Date:    Mon Jul 19 01:51:12 PDT 1999
>Last-Modified:  Mon Jul 19 03:30:01 PDT 1999
>Originator:     User &
>Release:        FreeBSD 2.0-RELEASE i386
>Organization:
>Environment:

FreeBSD 2.0 from Walnut creek FreeBSD 2.0 "January 1994" release.

>Description:

calling the acos() function in the math library with illegal values
( say -2.0 ) causes a floating exception core dump.

/usr/lib info: 
# ls -l libm.*
-r--r--r--  1 bin  bin  123388 Nov 22 05:14 libm.a
-r--r--r--  1 bin  bin  165021 Nov 22 05:14 libm.so.2.0
# cksum libm.*
3164276670 123388 libm.a
3263430048 165021 libm.so.2.0

>How-To-Repeat:

Try running this an linking with -lm:

#include<stdio.h>
#include<math.h>

main()
{
  acos(-2.0);
}

>Fix:

Unknown.


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->bde 
Responsible-Changed-By: wollman 
Responsible-Changed-When: Thu Feb 8 08:36:31 PST 1996 
Responsible-Changed-Why:  
bde is Mr. Math.  I have verified that the problem still 
persists. 

From: John-Mark Gurney <jmg@nike.efn.org>
To: mcclure@cs.unm.edu, freebsd-gnats-submit@freefall.FreeBSD.org,
        FreeBSD Current <freebsd-current@freebsd.org>
Cc:  Subject: misc/229 floating point exception on illegial values..
Date: Mon, 10 Feb 1997 12:45:50 -0800 (PST)

 I believe that this is what is suppose to happen...  you use SIGFPE to
 trap these errors and possibly rerun the function after correcting the
 problem....  acording to the math(3) man page an exception is suppose to
 occure on invalid values...
 
 so this is really a non-error correct?  and this pr should be closed...
 
 i.e. acos(-2.0) is suppose to generate a SIGFPE else it isn't doing what
 math(3) says it will do...
 
 John-Mark
 
 gurney_j@efn.org
 http://resnet.uoregon.edu/~gurney_j/
 Modem/FAX: (541) 683-6954   (FreeBSD Box)
 
 Live in Peace, destroy Micro$oft, support free software, run FreeBSD (unix)
 

From: Mark Diekhans <markd@Grizzly.COM>
To: gurney_j@resnet.uoregon.edu
Cc: mcclure@cs.unm.edu, freebsd-gnats-submit@freefall.freebsd.org,
        freebsd-current@freebsd.org
Subject: Re: misc/229 floating point exception on illegial values..
Date: Mon, 10 Feb 1997 17:43:35 -0800 (PST)

 >I believe that this is what is suppose to happen...  you use SIGFPE to
 >trap these errors and possibly rerun the function after correcting the
 >problem....  acording to the math(3) man page an exception is suppose to
 >occure on invalid values...
 >
 >so this is really a non-error correct?  and this pr should be closed...
 >
 >i.e. acos(-2.0) is suppose to generate a SIGFPE else it isn't doing what
 >math(3) says it will do...
 
 As the default behavior, this causes a great amount of pain when porting
 software to BSD.  No other system that I know of works in this manner.
 Its a royal pain for things like Tcl and other interpreters that want to
 check errno after calling a math function.
 
 Mark

From: Bruce Evans <bde@zeta.org.au>
To: gurney_j@resnet.uoregon.edu, markd@Grizzly.COM
Cc: freebsd-current@freebsd.org, freebsd-gnats-submit@freefall.freebsd.org,
        mcclure@cs.unm.edu
Subject: Re: misc/229 floating point exception on illegial values..
Date: Tue, 11 Feb 1997 13:49:16 +1100

 >>I believe that this is what is suppose to happen...  you use SIGFPE to
 >>trap these errors and possibly rerun the function after correcting the
 >>problem....  acording to the math(3) man page an exception is suppose to
 >>occure on invalid values...
 
 No.  math(3) says "NOTE: An Exception is not an Error unless handled
 badly".  It doesn't say that the default FreeBSD handling is always
 bad :-].
 
 >As the default behavior, this causes a great amount of pain when porting
 >software to BSD.  No other system that I know of works in this manner.
 >Its a royal pain for things like Tcl and other interpreters that want to
 >check errno after calling a math function.
 
 BSD's libraries are both advanced and broken here.  The old libm almost
 never sets errno.  Instead, for domain errors, it attempts to return
 a NaN and attempts to set the IEEE exception bit for invalid operand.
 These attempts, especially the setting of the exception bit, are sometimes
 broken by gcc's lack of support for IEEE floating point and libm's faith
 in the compiler's lack of optimization.  The new libm (msun) has support
 for setting errno, but for various reasons this support is not enabled by
 default in FreeBSD.
 
 Bruce

From: John-Mark Gurney <jmg@nike.efn.org>
To: Mark Diekhans <markd@Grizzly.COM>
Cc: mcclure@cs.unm.edu, freebsd-gnats-submit@freefall.freebsd.org,
        freebsd-current@freebsd.org
Subject: Re: misc/229 floating point exception on illegial values..
Date: Mon, 10 Feb 1997 19:20:41 -0800 (PST)

 On Mon, 10 Feb 1997, Mark Diekhans wrote:
 
 > >I believe that this is what is suppose to happen...  you use SIGFPE to
 > >trap these errors and possibly rerun the function after correcting the
 > >problem....  acording to the math(3) man page an exception is suppose to
 > >occure on invalid values...
 > >
 > >so this is really a non-error correct?  and this pr should be closed...
 > >
 > >i.e. acos(-2.0) is suppose to generate a SIGFPE else it isn't doing what
 > >math(3) says it will do...
 > 
 > As the default behavior, this causes a great amount of pain when porting
 > software to BSD.  No other system that I know of works in this manner.
 > Its a royal pain for things like Tcl and other interpreters that want to
 > check errno after calling a math function.
 
 well... it turns out that this is the IEEE 754 Spec that libm if
 following...  I don't think the FreeBSD team would mind adding a free ANSI
 C compatible math lib to the source tree...  do you have access or
 knowledge of one?
 
 guess the real pr is is not having an ANSI C math lib?
 
 thanks for the clarification...  ttyl..
 
 John-Mark
 
 gurney_j@efn.org
 http://resnet.uoregon.edu/~gurney_j/
 Modem/FAX: (541) 683-6954   (FreeBSD Box)
 
 Live in Peace, destroy Micro$oft, support free software, run FreeBSD (unix)
 
State-Changed-From-To: open->closed 
State-Changed-By: n_hibma 
State-Changed-When: Mon Jul 19 01:51:12 PDT 1999 
State-Changed-Why:  
In a recent discussion this was again proposed as to be changed, but wasn't. 

Doug White mentions the following as a solution to problems with FPE's and netscape: 

Did you use the port? 

This is a common Linux-ism.  Linux masks all FPU exceptions by default, 
where FreeBSD does not.  The offending calls simply need to be bracketed 
with fpgetmask()/fpsetmask() calls.   

Doug White 

From: Nick Hibma <nick.hibma@jrc.it>
To: freebsd-gnats-submit@freebsd.org
Cc:  
Subject: Re: misc/229: acos() core dump (fwd)
Date: Mon, 19 Jul 1999 12:28:39 +0200 (MET DST)

 As Bruce suggests, this bug report is the same as 105.
 
 ---------- Forwarded message ----------
 Date: Mon, 19 Jul 1999 20:05:40 +1000
 From: Bruce Evans <bde@zeta.org.au>
 To: n_hibma@FreeBSD.org
 Subject: Re: misc/229: acos() core dump
 
 >Synopsis: acos() core dump
 >
 >State-Changed-From-To: open->closed
 
 This should be left open, or marked superseded/preceded by i386/105.
 
 >This is a common Linux-ism.  Linux masks all FPU exceptions by default,
 >where FreeBSD does not.  The offending calls simply need to be bracketed
 >with fpgetmask()/fpsetmask() calls.  
 
 FreeBSD is not compatible with Standard C here.  The Standard requires
 all Standard math functions to not produced any externally visible
 exceptions.  Bracketing the offending calls is very slow and doesn't
 actually work unless there is no offense or the closing bracket is
 omitted so that exceptions remain masked (it just delays delivery of
 a SIGFPE).
 
 OTOH, the Standard doesn't require anything for FP exceptions outside of
 math functions (the behaviour is undefined).  Defaulting to delivery of
 a SIGFPE is useful for finding bugs in the 99.9% of programs that don't
 actually understand IEEE arithmetic.  E.g., PR12611 could be "fixed"
 by masking overflow execptions.  `jot -w %d 3 3000000000' would then
 produced 3 identical numbers (the single result of the default for
 overflow on conversion of double to long) instead of (int)3000000000,
 (int)3000000001, etc.
 
 Bruce
 
 
 
>Unformatted:

