NetBSD Problem Report #57949
From www@netbsd.org Mon Feb 19 21:23:38 2024
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 36A411A9239
for <gnats-bugs@gnats.NetBSD.org>; Mon, 19 Feb 2024 21:23:38 +0000 (UTC)
Message-Id: <20240219212336.9C5D01A923A@mollari.NetBSD.org>
Date: Mon, 19 Feb 2024 21:23:36 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: fetestexcept disables all floating-point exception traps as a side effect
X-Send-Pr-Version: www-1.0
>Number: 57949
>Category: port-amd64
>Synopsis: fetestexcept disables all floating-point exception traps as a side effect
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: port-amd64-maintainer
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Feb 19 21:25:00 +0000 2024
>Closed-Date: Fri Feb 23 19:11:09 +0000 2024
>Last-Modified: Fri Feb 23 19:11:09 +0000 2024
>Originator: Taylor R Campbell
>Release: current, 10, 9, 8, 7, 6
>Organization:
The NetBSD Exception
>Environment:
amd64
>Description:
fetestexcept uses fnstenv, which has the side effect of masking all x87 floating-point exception traps.
There's no need to use this; it should just use fnstcw (and stmxcsr).
>How-To-Repeat:
unsigned enabled0, raised, enabled1;
feclearexcept(FE_ALL_EXCEPT);
fedisableexcept(FE_ALL_EXCEPT);
feenableexcept(FE_ALL_EXCEPT);
enabled0 = fegetexcept();
raised = fetestexcept(FE_ALL_EXCEPT);
enabled1 = fegetexcept();
printf("enabled0: 0x%x\n", enabled0);
printf("raised: 0x%x\n", raised);
printf("enabled1: 0x%x\n", enabled1);
Expected enabled0 and enabled1 to both be 0x3d, but instead enabled0 is 0x3d and enabled1 is 0.
>Fix:
Yes, please!
>Release-Note:
>Audit-Trail:
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/57949 CVS commit: src/tests/lib/libm
Date: Mon, 19 Feb 2024 23:19:11 +0000
Module Name: src
Committed By: riastradh
Date: Mon Feb 19 23:19:11 UTC 2024
Modified Files:
src/tests/lib/libm: t_fenv.c
Log Message:
fenv(3): Add test for PR port-amd64/57949.
To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/tests/lib/libm/t_fenv.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: Taylor R Campbell <riastradh@NetBSD.org>
To: gnats-bugs@NetBSD.org
Cc: netbsd-bugs@NetBSD.org
Subject: Re: port-amd64/57949: fetestexcept disables all floating-point exception traps as a side effect
Date: Mon, 19 Feb 2024 23:58:07 +0000
This is a multi-part message in MIME format.
--=_fvz4bw6Sgb7EvIjKFB6Nr1oMeWUc8Daj
The attached patch should fix this -- I'll commit once the releng
testbed has confirmed my test is working to detect the problem.
--=_fvz4bw6Sgb7EvIjKFB6Nr1oMeWUc8Daj
Content-Type: text/plain; charset="ISO-8859-1"; name="pr57949-x86fetestexcept"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="pr57949-x86fetestexcept.patch"
From 8af3bc587abd07af6d32acf4f5dc7803ac28ec23 Mon Sep 17 00:00:00 2001
From: Taylor R Campbell <riastradh@NetBSD.org>
Date: Mon, 19 Feb 2024 23:24:13 +0000
Subject: [PATCH] fenv(3): Fix fetestexcept to avoid side effects on trap
state.
PR port-amd64/57949
---
lib/libm/arch/x86_64/fenv.c | 10 +---------
tests/lib/libm/t_fenv.c | 3 ---
2 files changed, 1 insertion(+), 12 deletions(-)
diff --git a/lib/libm/arch/x86_64/fenv.c b/lib/libm/arch/x86_64/fenv.c
index cd09c8bbd597..7d1816c15a72 100644
--- a/lib/libm/arch/x86_64/fenv.c
+++ b/lib/libm/arch/x86_64/fenv.c
@@ -259,7 +259,6 @@ fesetexceptflag(const fexcept_t *flagp, int excepts)
int
fetestexcept(int excepts)
{
- fenv_t fenv;
uint32_t mxcsr;
uint16_t status;
int ex;
@@ -268,17 +267,10 @@ fetestexcept(int excepts)
=20
ex =3D excepts & FE_ALL_EXCEPT;
=20
- /* Store the current x87 floating-point environment */
- memset(&fenv, 0, sizeof(fenv));
-
- __fnstenv(&fenv);
__fnstsw(&status);
-
- /* Store the MXCSR register state */
- __stmxcsr(&fenv.mxcsr);
__stmxcsr(&mxcsr);
=20
- return ((fenv.x87.status | fenv.mxcsr) & ex);
+ return ((status | mxcsr) & ex);
}
=20
/*
diff --git a/tests/lib/libm/t_fenv.c b/tests/lib/libm/t_fenv.c
index 038da828c7c6..deacead62b6f 100644
--- a/tests/lib/libm/t_fenv.c
+++ b/tests/lib/libm/t_fenv.c
@@ -364,9 +364,6 @@ ATF_TC_BODY(fetestexcept_trap, tc)
"fegetexcept()=3D0x%x FE_ALL_EXCEPT=3D0x%x", except, FE_ALL_EXCEPT);
=20
(void)fetestexcept(FE_ALL_EXCEPT);
-#ifdef __x86_64__
- atf_tc_expect_fail("PR port-amd64/57949");
-#endif
ATF_CHECK_EQ_MSG((except =3D fegetexcept()), FE_ALL_EXCEPT,
"fegetexcept()=3D0x%x FE_ALL_EXCEPT=3D0x%x", except, FE_ALL_EXCEPT);
}
--=_fvz4bw6Sgb7EvIjKFB6Nr1oMeWUc8Daj--
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/57949 CVS commit: src
Date: Tue, 20 Feb 2024 03:53:49 +0000
Module Name: src
Committed By: riastradh
Date: Tue Feb 20 03:53:49 UTC 2024
Modified Files:
src/lib/libm/arch/x86_64: fenv.c
src/tests/lib/libm: t_fenv.c
Log Message:
fenv(3): Fix fetestexcept to avoid side effects on trap state.
PR port-amd64/57949
To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libm/arch/x86_64/fenv.c
cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libm/t_fenv.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: riastradh@NetBSD.org
State-Changed-When: Thu, 22 Feb 2024 14:54:24 +0000
State-Changed-Why:
pullup-10 #602 https://releng.netbsd.org/cgi-bin/req-10.cgi?show=602
pullup-9 #1801 https://releng.netbsd.org/cgi-bin/req-9.cgi?show=1801
pullup-8 #1937 https://releng.netbsd.org/cgi-bin/req-8.cgi?show=1937
From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/57949 CVS commit: [netbsd-10] src
Date: Fri, 23 Feb 2024 18:09:23 +0000
Module Name: src
Committed By: martin
Date: Fri Feb 23 18:09:23 UTC 2024
Modified Files:
src/lib/libm/arch/x86_64 [netbsd-10]: fenv.c
src/tests/lib/libm [netbsd-10]: t_fenv.c
Log Message:
Pull up following revision(s) (requested by riastradh in ticket #603):
tests/lib/libm/t_fenv.c: revision 1.14
tests/lib/libm/t_fenv.c: revision 1.15
lib/libm/arch/x86_64/fenv.c: revision 1.11
fenv(3): Add test for PR port-amd64/57949.
fenv(3): Fix fetestexcept to avoid side effects on trap state.
PR port-amd64/57949
To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.10.2.1 src/lib/libm/arch/x86_64/fenv.c
cvs rdiff -u -r1.6 -r1.6.10.1 src/tests/lib/libm/t_fenv.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/57949 CVS commit: [netbsd-9] src
Date: Fri, 23 Feb 2024 18:13:54 +0000
Module Name: src
Committed By: martin
Date: Fri Feb 23 18:13:54 UTC 2024
Modified Files:
src/lib/libm/arch/x86_64 [netbsd-9]: fenv.c
src/tests/lib/libm [netbsd-9]: t_fenv.c
Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1801):
tests/lib/libm/t_fenv.c: revision 1.14
tests/lib/libm/t_fenv.c: revision 1.15
lib/libm/arch/x86_64/fenv.c: revision 1.11
fenv(3): Add test for PR port-amd64/57949.
fenv(3): Fix fetestexcept to avoid side effects on trap state.
PR port-amd64/57949
To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.7.14.1 src/lib/libm/arch/x86_64/fenv.c
cvs rdiff -u -r1.6 -r1.6.2.1 src/tests/lib/libm/t_fenv.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/57949 CVS commit: [netbsd-8] src
Date: Fri, 23 Feb 2024 18:15:53 +0000
Module Name: src
Committed By: martin
Date: Fri Feb 23 18:15:53 UTC 2024
Modified Files:
src/lib/libm/arch/x86_64 [netbsd-8]: fenv.c
src/tests/lib/libm [netbsd-8]: t_fenv.c
Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1937):
tests/lib/libm/t_fenv.c: revision 1.14
tests/lib/libm/t_fenv.c: revision 1.15
lib/libm/arch/x86_64/fenv.c: revision 1.11
fenv(3): Add test for PR port-amd64/57949.
fenv(3): Fix fetestexcept to avoid side effects on trap state.
PR port-amd64/57949
To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.7.4.1 src/lib/libm/arch/x86_64/fenv.c
cvs rdiff -u -r1.3 -r1.3.8.1 src/tests/lib/libm/t_fenv.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: riastradh@NetBSD.org
State-Changed-When: Fri, 23 Feb 2024 19:11:09 +0000
State-Changed-Why:
fixed and pulled up to 10, 9, 8
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.