Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/lib/libc/sys Work around QEMU bug #1668041 differently...
details: https://anonhg.NetBSD.org/src/rev/3a1cb28f029c
branches: trunk
changeset: 973157:3a1cb28f029c
user: rin <rin%NetBSD.org@localhost>
date: Mon Jun 22 12:21:02 2020 +0000
description:
Work around QEMU bug #1668041 differently, by which floating-point
division by zero is not correctly trapped for i386 and amd64:
https://bugs.launchpad.net/qemu/+bug/1668041
Make trigger_fpe() cause integer division by zero for x86, and
floating-point one for other architectures. Also, assertions for
si_code in *_crash_fpe tests are commented out for now. They
should be cleaned up after the bug is fixed.
Now, *_crash_fpe tests are working also on powerpc.
Suggested by kamil.
diffstat:
tests/lib/libc/sys/t_ptrace_signal_wait.h | 10 +++++-----
tests/lib/libc/sys/t_ptrace_wait.h | 24 +++++++++++++++++-------
2 files changed, 22 insertions(+), 12 deletions(-)
diffs (96 lines):
diff -r de3ad0de10f4 -r 3a1cb28f029c tests/lib/libc/sys/t_ptrace_signal_wait.h
--- a/tests/lib/libc/sys/t_ptrace_signal_wait.h Mon Jun 22 12:03:46 2020 +0000
+++ b/tests/lib/libc/sys/t_ptrace_signal_wait.h Mon Jun 22 12:21:02 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_ptrace_signal_wait.h,v 1.3 2020/06/22 02:51:06 rin Exp $ */
+/* $NetBSD: t_ptrace_signal_wait.h,v 1.4 2020/06/22 12:21:02 rin Exp $ */
/*-
* Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc.
@@ -423,7 +423,7 @@
info.psi_siginfo.si_code <= ILL_BADSTK);
break;
case SIGFPE:
- ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
+// XXXQEMU ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_FLTDIV);
break;
case SIGBUS:
ATF_REQUIRE_EQ(info.psi_siginfo.si_code, BUS_ADRERR);
@@ -603,7 +603,7 @@
info.psi_siginfo.si_code <= ILL_BADSTK);
break;
case SIGFPE:
- ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
+// XXXQEMU ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_FLTDIV);
break;
case SIGBUS:
ATF_REQUIRE_EQ(info.psi_siginfo.si_code, BUS_ADRERR);
@@ -786,7 +786,7 @@
info.psi_siginfo.si_code <= ILL_BADSTK);
break;
case SIGFPE:
- ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
+// XXXQEMU ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_FLTDIV);
break;
case SIGBUS:
ATF_REQUIRE_EQ(info.psi_siginfo.si_code, BUS_ADRERR);
@@ -1890,7 +1890,7 @@
info.psi_siginfo.si_code <= ILL_BADSTK);
break;
case SIGFPE:
- FORKEE_ASSERT_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
+// XXXQEMU FORKEE_ASSERT_EQ(info.psi_siginfo.si_code, FPE_FLTDIV);
break;
case SIGBUS:
FORKEE_ASSERT_EQ(info.psi_siginfo.si_code, BUS_ADRERR);
diff -r de3ad0de10f4 -r 3a1cb28f029c tests/lib/libc/sys/t_ptrace_wait.h
--- a/tests/lib/libc/sys/t_ptrace_wait.h Mon Jun 22 12:03:46 2020 +0000
+++ b/tests/lib/libc/sys/t_ptrace_wait.h Mon Jun 22 12:21:02 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_ptrace_wait.h,v 1.31 2020/06/22 02:51:06 rin Exp $ */
+/* $NetBSD: t_ptrace_wait.h,v 1.32 2020/06/22 12:21:02 rin Exp $ */
/*-
* Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -671,9 +671,6 @@
return false;
return true;
}
-#elif __powerpc__
-/* Integer division by zero do not trap on powerpc. */
-#define are_fpu_exceptions_supported() 0
#else
#define are_fpu_exceptions_supported() 1
#endif
@@ -681,15 +678,28 @@
static void __used
trigger_fpe(void)
{
- volatile int a = getpid();
- volatile int b = atoi("0");
+#if __i386__ || __x86_64__
+ /*
+ * XXX
+ * Hack for QEMU bug #1668041, by which floating-point division by
+ * zero is not trapped correctly. Also, assertions for si_code in
+ * ptrace_signal_wait.h are commented out. Clean them up after the
+ * bug is fixed.
+ */
+ volatile int a, b;
+#else
+ volatile double a, b;
+#endif
+
+ a = getpid();
+ b = atoi("0");
#ifdef __HAVE_FENV
feenableexcept(FE_ALL_EXCEPT);
#endif
/* Division by zero causes CPU trap, translated to SIGFPE */
- usleep(a / b);
+ usleep((int)(a / b));
}
static void __used
Home |
Main Index |
Thread Index |
Old Index