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 Turn trigger_fpe() back to integer divisi...



details:   https://anonhg.NetBSD.org/src/rev/70f51e4b5894
branches:  trunk
changeset: 934998:70f51e4b5894
user:      rin <rin%NetBSD.org@localhost>
date:      Mon Jun 22 02:51:06 2020 +0000

description:
Turn trigger_fpe() back to integer division by zero for a while
until QEMU bug #1668041 is fixed:

https://bugs.launchpad.net/qemu/+bug/1668041

by which floating-point division by zero is not trapped correctly
both on amd64 and i386.

Skip *_crash_fpe tests on powerpc, where integer division by zero
is never trapped.

diffstat:

 tests/lib/libc/sys/t_ptrace_signal_wait.h |  10 +++++-----
 tests/lib/libc/sys/t_ptrace_wait.h        |  12 ++++++++----
 2 files changed, 13 insertions(+), 9 deletions(-)

diffs (83 lines):

diff -r 152d22b97722 -r 70f51e4b5894 tests/lib/libc/sys/t_ptrace_signal_wait.h
--- a/tests/lib/libc/sys/t_ptrace_signal_wait.h Mon Jun 22 02:26:19 2020 +0000
+++ b/tests/lib/libc/sys/t_ptrace_signal_wait.h Mon Jun 22 02:51:06 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_ptrace_signal_wait.h,v 1.2 2020/06/17 08:42:16 rin Exp $     */
+/*     $NetBSD: t_ptrace_signal_wait.h,v 1.3 2020/06/22 02:51:06 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_FLTDIV);
+               ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
                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_FLTDIV);
+               ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
                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_FLTDIV);
+               ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
                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_FLTDIV);
+                       FORKEE_ASSERT_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
                        break;
                case SIGBUS:
                        FORKEE_ASSERT_EQ(info.psi_siginfo.si_code, BUS_ADRERR);
diff -r 152d22b97722 -r 70f51e4b5894 tests/lib/libc/sys/t_ptrace_wait.h
--- a/tests/lib/libc/sys/t_ptrace_wait.h        Mon Jun 22 02:26:19 2020 +0000
+++ b/tests/lib/libc/sys/t_ptrace_wait.h        Mon Jun 22 02:51:06 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_ptrace_wait.h,v 1.30 2020/06/17 08:42:16 rin Exp $   */
+/*     $NetBSD: t_ptrace_wait.h,v 1.31 2020/06/22 02:51:06 rin Exp $   */
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -671,6 +671,9 @@
                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
@@ -678,14 +681,15 @@
 static void __used
 trigger_fpe(void)
 {
-       volatile double a = getpid();
-       volatile double b = atoi("0");
+       volatile int a = getpid();
+       volatile int b = atoi("0");
 
 #ifdef __HAVE_FENV
        feenableexcept(FE_ALL_EXCEPT);
 #endif
 
-       usleep((int)(a / b));
+       /* Division by zero causes CPU trap, translated to SIGFPE */
+       usleep(a / b);
 }
 
 static void __used



Home | Main Index | Thread Index | Old Index