From <@grizzly.com:markd@grizzly.com>  Wed Jan 11 15:25:06 1995
Received: from cats.ucsc.edu (root@cats-po-1.UCSC.EDU [128.114.129.22]) by freefall.cdrom.com (8.6.9/8.6.6) with ESMTP id PAA13388 for <FreeBSD-gnats-submit@freebsd.org>; Wed, 11 Jan 1995 15:25:06 -0800
Received: from scruz.ucsc.edu by cats.ucsc.edu with SMTP
	id PAA17615; Wed, 11 Jan 1995 15:24:55 -0800
Received: from osprey by scruz.ucsc.edu id aa22088; 11 Jan 95 16:20 PST
Received: (from markd@localhost) by Grizzly.COM (8.6.9/8.6.9) id PAA12598; Tue, 10 Jan 1995 15:18:42 -0800
Message-Id: <199501102318.PAA12598@Grizzly.COM>
Date: Tue, 10 Jan 1995 15:18:42 -0800
From: Mark Diekhans <markd@grizzly.com>
Reply-To: markd@grizzly.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: Distributed libm (msun) has non-standard error handling.
X-Send-Pr-Version: 3.2

>Number:         105
>Category:       kern
>Synopsis:       Distributed libm (msun) has non-standard error handling.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-standards
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jan 11 15:30:00 1995
>Closed-Date:    Mon Jan 24 14:37:34 GMT 2005
>Last-Modified:  Mon Jan 24 14:37:34 GMT 2005
>Originator:     Mark Diekhans
>Release:        FreeBSD 2.0-RELEASE i386
>Organization:
== Mark Diekhans (markd@grizzly.com)     ==
>Environment:

>Description:

FreeBSD 2.0 uses the msun implementation of libm, which has error handling
that is incompatible with most other Unix implementations.

The msun functions don't precheck arguments and call matherr or return special
error values (NaN, inf), instead of detecting errors in the expected manner,
they SIGFPE.  Whats worse is that math.h contains the declaration for "struct
exception".  Programs that are expecting to use matherr compile correctly, but
then fail to handle errors correctly.

This has broken several packages, including Tcl and Elk.  For the sake of
making FreeBSD easy to port to (instead of another Ultrix), please ship the
standard BSD libm. Libmsun can be shipped a seperate library that people who
don't care about the portability issues can optionally use.



>How-To-Repeat:

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

main ()
{
    printf ("acos = %g\n", acos (-2.0));
    printf ("pow = %g\n", pow(3, 1000001));
}


>Fix:
	
Compile and ship lib/libm as the bindist math library. It handles errors
by returning NaN, etc, which is much more common than SIGFPE.

.....

I asked JTC about this on 28-Oct-1995:
"Paul" == Paul Traina <pst@freefall.freebsd.org> writes:
Have you seen similar complaints in NetBSD?  FreeBSD ships your msun
library as the standard math library, with an option to ship with the
CSRG library.

No, but last I checked FreeBSD still does not mask all FP exceptions
as required by IEEE754 (and this library).

Responsible-Changed-From-To: freebsd-bugs->bde 
Responsible-Changed-By: pst 
Responsible-Changed-When: Sun Oct 29 10:10:54 PST 1995 
Responsible-Changed-Why:  

You can assign this to me.  My analysis: 

- our CFLAGS is bogus.  It gives pure IEEE non-ANSI mode. 
- this normally has no effect because we trap for the relevant IEEE 
exceptions (this behaviour is also non-ANSI) 
- some applications may expect to get IEEE behaviour by calling 
fpsetmask(). 
- fdlibm's "POSIX" mode is bogus.  It's apparently close to an old SYSV 
mode designed for FPUs that don't support Infinities or NaNs.  Using 
it would break IEEE support. 
- few users care about the error handling and fewer understand it. 

Bruce 

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->analyzed 
State-Changed-By: pst 
State-Changed-When: Sat Oct 28 15:24:01 PDT 1995 
State-Changed-Why:  
Got input back from JTC. 
State-Changed-From-To: analyzed->open 
State-Changed-By: wollman 
State-Changed-When: Mon Nov 27 11:48:59 PST 2000 
State-Changed-Why:  
Yes, it's night of the undead PRs! 

This PR is being changed back to freebsd-bugs and state open 
as a reminder that the specifications for math exception 
handling in POSIX 2001 have changed significantly from what 
POSIX 1990 required, and will need to be updated once the 
Austin Group settles on the precise details. 


Responsible-Changed-From-To: bde->freebsd-bugs 
Responsible-Changed-By: wollman 
Responsible-Changed-When: Mon Nov 27 11:48:59 PST 2000 
Responsible-Changed-Why:  
See state change. 

State-Changed-From-To: open->feedback 
State-Changed-By: keramida 
State-Changed-When: Sun Nov 18 20:22:25 PST 2001 
State-Changed-Why:  
I can't reproduce the problem. 
Do you think that this report can be closed? 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=105 
Responsible-Changed-From-To: freebsd-bugs->freebsd-standards 
Responsible-Changed-By: johan 
Responsible-Changed-When: Thu Aug 22 10:49:30 PDT 2002 
Responsible-Changed-Why:  
According to wollman, this is a POSIX issue that should  
be handled. Over to -standards. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=105 
Responsible-Changed-From-To: freebsd-standards->standards 
Responsible-Changed-By: johan 
Responsible-Changed-When: Sat Aug 24 19:37:38 PDT 2002 
Responsible-Changed-Why:  
Use short names for mailing list to make searches    
using the web query form work with the shown responsible. 

This also makes open PRs show up in the summery mail. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=105 

From: Ryan Sommers <ryans@gamersimpact.com>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: i386/105: Distributed libm (msun) has non-standard error handling.
Date: Wed, 07 Jan 2004 22:05:27 -0600

 It looks like this problem has since been resolved. I believe this PR 
 can be closed.
 
 ryans@lilshadow(~/src):cat test.c
 #include <stdio.h>
 #include <math.h>
 
 main ()
 {
      printf ("acos = %g\n", acos (-2.0));
      printf ("pow = %g\n", pow(3, 1000001));
 }
 ryans@lilshadow(~/src):gcc -lm -o test test.c
 ryans@lilshadow(~/src):./test
 acos = nan
 pow = inf
 ryans@lilshadow(~/src):
 
 -- 
 Ryan Sommers
 ryans@gamersimpact.com

From: Bruce Evans <bde@zeta.org.au>
To: Ryan Sommers <ryans@gamersimpact.com>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: i386/105: Distributed libm (msun) has non-standard error handling.
Date: Thu, 8 Jan 2004 20:28:06 +1100 (EST)

 On Wed, 7 Jan 2004, Ryan Sommers wrote:
 
 >  It looks like this problem has since been resolved. I believe this PR
 >  can be closed.
 >
 >  ryans@lilshadow(~/src):cat test.c
 >  #include <stdio.h>
 >  #include <math.h>
 >
 >  main ()
 >  {
 >       printf ("acos = %g\n", acos (-2.0));
 >       printf ("pow = %g\n", pow(3, 1000001));
 >  }
 >  ryans@lilshadow(~/src):gcc -lm -o test test.c
 >  ryans@lilshadow(~/src):./test
 >  acos = nan
 >  pow = inf
 
 Many aspects of this are still open:
 - adding "assert(errno == EDOM);" would show that error handling does not
   conform to C90 (or the man page for at least the VAX and Tahoe cases;
   the handing of domain errors for other cases seems to be undocumented
   in the man pages).
 - adding "#include <ieeefp.h> ... fpsetmask(fpgetmask() | FP_X_INV)"
   would show that the oringal problem still exists, unless fpsetmask() is
   permitted to break the operation of standard functions.  Using
   fpsetmask() gives undefined behaviour by taking the program out of C90
   abd by fpsetmask()'s docmentation not being detailed enough to define
   the behaviour.  C99 defines the effect of the feset*() family on library
   functions in detail.  I don't completely understand this, and C99 avoids
   the problem by not providing a way to unmask traps for FP exceptions.
 
 This is mainly a documentation problem.  Math functions should eventually
 do the the following:
 - not support C90 (they never did)
 - conform to C99 with the <mumble> math extensions.  Take the option to
   never set errno for math functions.
 - have a nonstandard fesetmask() function whose use breaks C99 conformance
   in documented ways (should it affect math functions or only application
   code?).
 - conform to POSIX.1-2001.  Set math_errhandling to MATH_ERREXCEPT to
   indicate that setting errno is not done.
 - document the above, and don't document VAX and Tahoe error handling.
 - document "raise"ing of FP exceptions more clearly than POSIX (does it
   call raise() or raise a SIGFPE?  It had better not by default, but
   fpsetmask() can certainly cause it to).
 
 See also PR 56906.
 
 Bruce
Responsible-Changed-From-To: standards->freebsd-standards 
Responsible-Changed-By: des 
Responsible-Changed-When: Tue Feb 17 07:45:40 PST 2004 
Responsible-Changed-Why:  
Misattributed PR. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=105 
State-Changed-From-To: feedback->closed 
State-Changed-By: das 
State-Changed-When: Mon Jan 24 14:37:06 GMT 2005 
State-Changed-Why:  
Better late than never: close this PR.  In short, the problem the 
submitter reported (FP exceptions unmasked by default) were fixed 5 
years ago in src/sys/i386/include/npx.c, v1.18.  The tangential issues 
raised in the audit trail have also been more or less addressed. 

Now our oldest unresolved PR is from 1996! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=105 
>Unformatted:
