NetBSD Problem Report #42630

From www@NetBSD.org  Sun Jan 17 11:21:03 2010
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id CD3E263B886
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 17 Jan 2010 11:21:02 +0000 (UTC)
Message-Id: <20100117112102.9BDD863B86D@www.NetBSD.org>
Date: Sun, 17 Jan 2010 11:21:02 +0000 (UTC)
From: naruse@airemix.jp
Reply-To: naruse@airemix.jp
To: gnats-bugs@NetBSD.org
Subject: asin(2.0) and acos(2.0) doesn't return NaN
X-Send-Pr-Version: www-1.0

>Number:         42630
>Category:       lib
>Synopsis:       asin(2.0) and acos(2.0) doesn't return NaN
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jan 17 11:25:00 +0000 2010
>Closed-Date:    Sat Jan 30 21:28:19 +0000 2010
>Last-Modified:  Sat Jan 30 21:28:19 +0000 2010
>Originator:     NARUSE, Yui
>Release:        5.0.1
>Organization:
>Environment:
NetBSD kelvena 5.0.1 NetBSD 5.0.1 (GENERIC) #0: Thu Jul 30 01:39:11 UTC 2009  builds@b8.netbsd.org:/home/builds/ab/netbsd-5-0-1-RELEASE/i386/200907292356Z-obj/home/builds/ab/netbsd-5-0-1-RELEASE/src/sys/arch/i386/compile/GENERIC i386
>Description:
On NetBSD 5.0.1 (i386) asin(2.0) and acos(2.0) return 0.0.
(and set errno as EDOM)

This conflicts asin's man:
 RETURN VALUES
     If |x|>1, asin(x) and asinf(x) return NaN and set the global variable
     errno to EDOM.
(acos's man doesn't descrive about return value if |x| > 1)

And lib/libm/src/e_asin.c's comment:
 * Special cases:
 *      if x is NaN, return x itself;
 *      if |x|>1, return NaN with invalid signal.
(e_acos.c also has same comment)

This seems because of the bug of lib/libm/arch/i387/e_asin.S.
(and lib/libm/arch/i387/e_acos.S)
>How-To-Repeat:
$ cat t.c
#include <stdio.h>
#include <math.h>
#include <errno.h>

int main(void)
{
  double r;
  errno = 0;
  r = asin(2.0);
  printf("r: %f isnan:%d errno:%d\n", r, isnan(r), errno);
  return 0;
}
$ cc -lm t.c
$ ./a.out
r: 0.000000 isnan:0 errno:33

>Fix:

>Release-Note:

>Audit-Trail:
From: Takehiko NOZAKI <takehiko.nozaki@gmail.com>
To: gnats-bugs@netbsd.org
Cc: lib-bug-people@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: lib/42630: asin(2.0) and acos(2.0) doesn't return NaN
Date: Tue, 19 Jan 2010 02:30:01 +0900

 hi, naruse-san.

 this is because of __kernel_standard(x, x, 2) returns zero.
 please try following patch.


 Index: src/k_standard.c
 ===================================================================
 RCS file: /cvsroot/src/lib/libm/src/k_standard.c,v
 retrieving revision 1.12
 diff -u -r1.12 k_standard.c
 --- src/k_standard.c	21 Jul 2005 16:58:39 -0000	1.12
 +++ src/k_standard.c	18 Jan 2010 17:24:19 -0000
 @@ -118,9 +118,12 @@
  		exc.type = DOMAIN;
  		exc.name = type < 100 ? "asin" : "asinf";
  		exc.retval = zero;
 -		if(_LIB_VERSION == _POSIX_)
 +		if(_LIB_VERSION == _POSIX_) {
 +#ifndef __vax__
 +		  exc.retval = NAN;
 +#endif
  		  errno = EDOM;
 -		else if (!matherr(&exc)) {
 +		} else if (!matherr(&exc)) {
  		  if(_LIB_VERSION == _SVID_) {
  		    	(void) WRITE2("asin: DOMAIN error\n", 19);
  		  }
 @@ -135,9 +138,12 @@
  		exc.type = DOMAIN;
  		exc.name = type < 100 ? "atan2" : "atan2f";
  		exc.retval = zero;
 -		if(_LIB_VERSION == _POSIX_)
 +		if(_LIB_VERSION == _POSIX_) {
 +#ifndef __vax__
 +		  exc.retval = NAN;
 +#endif
  		  errno = EDOM;
 -		else if (!matherr(&exc)) {
 +		} else if (!matherr(&exc)) {
  		  if(_LIB_VERSION == _SVID_) {
  			(void) WRITE2("atan2: DOMAIN error\n", 20);
  		      }


 very truly yours.
 --
 Takehiko NOZAKI <tnozaki@NetBSD.org>

From: Takehiko NOZAKI <tnozaki@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/42630 CVS commit: src/lib/libm/src
Date: Wed, 20 Jan 2010 16:31:35 +0000

 Module Name:	src
 Committed By:	tnozaki
 Date:		Wed Jan 20 16:31:35 UTC 2010

 Modified Files:
 	src/lib/libm/src: k_standard.c

 Log Message:
 PR/42630 asin(2.0) and acos(2.0) doesn't return NaN.
 reported by NARUSE, Yui -san, Thanks!


 To generate a diff of this commit:
 cvs rdiff -u -r1.12 -r1.13 src/lib/libm/src/k_standard.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->pending-pullups
State-Changed-By: tnozaki@NetBSD.org
State-Changed-When: Wed, 20 Jan 2010 16:44:17 +0000
State-Changed-Why:
send mail pullup-5.

From: Manuel Bouyer <bouyer@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/42630 CVS commit: [netbsd-5] src/lib/libm/src
Date: Sat, 23 Jan 2010 18:02:33 +0000

 Module Name:	src
 Committed By:	bouyer
 Date:		Sat Jan 23 18:02:33 UTC 2010

 Modified Files:
 	src/lib/libm/src [netbsd-5]: k_standard.c

 Log Message:
 Pull up following revision(s) (requested by tnozaki in ticket #1261):
 	lib/libm/src/k_standard.c: revision 1.13, 1.14
 PR/42630 asin(2.0) and acos(2.0) doesn't return NaN.
 reported by NARUSE, Yui -san, Thanks!
 let the previous fix apply to acos rather than atan2,
 and get rid of #ifdef vax


 To generate a diff of this commit:
 cvs rdiff -u -r1.12 -r1.12.26.1 src/lib/libm/src/k_standard.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: pending-pullups->closed
State-Changed-By: snj@NetBSD.org
State-Changed-When: Sat, 30 Jan 2010 21:28:19 +0000
State-Changed-Why:
Pulled up.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.