NetBSD Problem Report #51839
From www@NetBSD.org Fri Jan 13 04:38:03 2017
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id E646D7A20E
for <gnats-bugs@gnats.NetBSD.org>; Fri, 13 Jan 2017 04:38:02 +0000 (UTC)
Message-Id: <20170113043801.F11C67A2B6@mollari.NetBSD.org>
Date: Fri, 13 Jan 2017 04:38:01 +0000 (UTC)
From: yaneurabeya@gmail.com
Reply-To: yaneurabeya@gmail.com
To: gnats-bugs@NetBSD.org
Subject: [PATCH] tests/lib/libm/t_scalbn: reset errno to 0 before calling scalbn*
X-Send-Pr-Version: www-1.0
>Number: 51839
>Category: bin
>Synopsis: [PATCH] tests/lib/libm/t_scalbn: reset errno to 0 before calling scalbn*
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Jan 13 04:40:00 +0000 2017
>Closed-Date: Sun Jun 03 08:41:28 +0000 2018
>Last-Modified: Sun Jun 03 08:41:28 +0000 2018
>Originator: Ngie Cooper
>Release: 7.0.2
>Organization:
>Environment:
n/a
>Description:
As stated by POSIX [*], the errno should be set to 0 before calling scalbn to test for correctness:
<<<
An application wishing to check for error situations should set errno to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these functions. On return, if errno is non-zero or fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has occurred.
>>>
FreeBSD definitely needs this to be done. The attached patch fixes that.
* http://pubs.opengroup.org/onlinepubs/9699919799/functions/scalbln.html
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
From: "Ngie Cooper (yaneurabeya)" <yaneurabeya@gmail.com>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: bin/51839: [PATCH] tests/lib/libm/t_scalbn: reset errno to 0
before calling scalbn*
Date: Thu, 12 Jan 2017 20:42:28 -0800
--Apple-Mail=_5D1A96CB-9463-4C92-94B6-6DD94B7A0DF3
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=us-ascii
Patch attached.
-Ngie
--Apple-Mail=_5D1A96CB-9463-4C92-94B6-6DD94B7A0DF3
Content-Disposition: attachment;
filename*0=t_scalbn-reset-errno-to-0-before-calling-scalbn-functions-and-te;
filename*1=sting-errno.patch
Content-Type: application/octet-stream;
x-unix-mode=0644;
name="t_scalbn-reset-errno-to-0-before-calling-scalbn-functions-and-testing-errno.patch"
Content-Transfer-Encoding: 7bit
Index: lib/libm/t_scalbn.c
===================================================================
RCS file: /cvsroot/src/tests/lib/libm/t_scalbn.c,v
retrieving revision 1.11
diff -u -r1.11 t_scalbn.c
--- lib/libm/t_scalbn.c 3 Mar 2014 10:39:08 -0000 1.11
+++ lib/libm/t_scalbn.c 13 Jan 2017 04:35:31 -0000
@@ -81,6 +81,7 @@
double rv;
for (i = 0; i < tcnt; i++) {
+ errno = 0;
rv = scalbn(tests[i].inval, tests[i].exp);
ATF_CHECK_EQ_MSG(errno, tests[i].error,
"test %zu: errno %d instead of %d", i, errno,
@@ -222,6 +223,7 @@
double rv;
for (i = 0; i < tcnt; i++) {
+ errno = 0;
rv = scalbnf(tests[i].inval, tests[i].exp);
ATF_CHECK_EQ_MSG(errno, tests[i].error,
"test %zu: errno %d instead of %d", i, errno,
@@ -366,6 +368,7 @@
long double rv;
for (i = 0; i < tcnt; i++) {
+ errno = 0;
rv = scalbnl(tests[i].inval, tests[i].exp);
ATF_CHECK_EQ_MSG(errno, tests[i].error,
"test %zu: errno %d instead of %d", i, errno,
--Apple-Mail=_5D1A96CB-9463-4C92-94B6-6DD94B7A0DF3--
From: Joerg Sonnenberger <joerg@bec.de>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: bin/51839: [PATCH] tests/lib/libm/t_scalbn: reset errno to 0
before calling scalbn*
Date: Fri, 13 Jan 2017 11:32:39 +0100
On Fri, Jan 13, 2017 at 04:40:00AM +0000, yaneurabeya@gmail.com wrote:
> <<<
>
> An application wishing to check for error situations should set errno to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these functions. On return, if errno is non-zero or fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has occurred.
>
> >>>
>
> FreeBSD definitely needs this to be done. The attached patch fixes that.
But it doesn't? It only provides half of that.
Joerg
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/51839 CVS commit: src/tests/lib/libm
Date: Fri, 13 Jan 2017 14:26:04 -0500
Module Name: src
Committed By: christos
Date: Fri Jan 13 19:26:03 UTC 2017
Modified Files:
src/tests/lib/libm: t_scalbn.c
Log Message:
PR/51839: Ngie Cooper: reset errno to 0 before calling scalbn*
To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/tests/lib/libm/t_scalbn.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->feedback
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Tue, 14 Mar 2017 07:51:06 +0000
State-Changed-Why:
Christos committed it. I think Joerg's question means the code should
also be patched to call feclearexcept()... is that right?
From: Joerg Sonnenberger <joerg@bec.de>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: bin/51839 ([PATCH] tests/lib/libm/t_scalbn: reset errno to 0
before calling scalbn*)
Date: Tue, 14 Mar 2017 11:25:31 +0100
On Tue, Mar 14, 2017 at 07:51:06AM +0000, dholland@NetBSD.org wrote:
> Synopsis: [PATCH] tests/lib/libm/t_scalbn: reset errno to 0 before calling scalbn*
>
> State-Changed-From-To: open->feedback
> State-Changed-By: dholland@NetBSD.org
> State-Changed-When: Tue, 14 Mar 2017 07:51:06 +0000
> State-Changed-Why:
> Christos committed it. I think Joerg's question means the code should
> also be patched to call feclearexcept()... is that right?
Correct.
Joerg
From: Ngie Cooper <yaneurabeya@gmail.com>
To: "gnats-bugs@NetBSD.org" <gnats-bugs@netbsd.org>
Cc: "gnats-admin@netbsd.org" <gnats-admin@netbsd.org>,
"netbsd-bugs@netbsd.org" <netbsd-bugs@netbsd.org>
Subject: Re: bin/51839 ([PATCH] tests/lib/libm/t_scalbn: reset errno to 0
before calling scalbn*)
Date: Tue, 14 Mar 2017 15:17:47 -0700
On Tue, Mar 14, 2017 at 3:30 AM, Joerg Sonnenberger <joerg@bec.de> wrote:
> The following reply was made to PR bin/51839; it has been noted by GNATS.
>
> From: Joerg Sonnenberger <joerg@bec.de>
> To: gnats-bugs@NetBSD.org
> Cc:
> Subject: Re: bin/51839 ([PATCH] tests/lib/libm/t_scalbn: reset errno to 0
> before calling scalbn*)
> Date: Tue, 14 Mar 2017 11:25:31 +0100
>
> On Tue, Mar 14, 2017 at 07:51:06AM +0000, dholland@NetBSD.org wrote:
> > Synopsis: [PATCH] tests/lib/libm/t_scalbn: reset errno to 0 before calling scalbn*
> >
> > State-Changed-From-To: open->feedback
> > State-Changed-By: dholland@NetBSD.org
> > State-Changed-When: Tue, 14 Mar 2017 07:51:06 +0000
> > State-Changed-Why:
> > Christos committed it. I think Joerg's question means the code should
> > also be patched to call feclearexcept()... is that right?
>
> Correct.
I'll look at this, as well. There are some testcases in FreeBSD
that could be polished up and "upstreamed" to NetBSD.
Thanks!
-Ngie
State-Changed-From-To: feedback->closed
State-Changed-By: maya@NetBSD.org
State-Changed-When: Sun, 03 Jun 2018 08:41:28 +0000
State-Changed-Why:
I've made the changes in the second part, too. Should be good now.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.