Let trigger_fpe() cause floating-point divide by zero exception, instead of

integer one, which is not trapped for powerpc and aarch64.

Note that it is checked in lib/libc/gen/t_siginfo whether integer divide by
zero is interpreted as SIGFPE or not.

Now, all *_crash_fpe tests pass for powerpc, and nothing changes for amd64
at least.
This commit is contained in:
rin 2020-06-17 08:42:16 +00:00
parent 2d089d6a31
commit f68301ec40
2 changed files with 9 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: t_ptrace_signal_wait.h,v 1.1 2020/05/04 23:49:31 kamil Exp $ */
/* $NetBSD: t_ptrace_signal_wait.h,v 1.2 2020/06/17 08:42:16 rin Exp $ */
/*-
* Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc.
@ -423,7 +423,7 @@ traceme_crash(int sig)
info.psi_siginfo.si_code <= ILL_BADSTK);
break;
case SIGFPE:
ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
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 @@ traceme_signalmasked_crash(int sig)
info.psi_siginfo.si_code <= ILL_BADSTK);
break;
case SIGFPE:
ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
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 @@ traceme_signalignored_crash(int sig)
info.psi_siginfo.si_code <= ILL_BADSTK);
break;
case SIGFPE:
ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
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 @@ unrelated_tracer_sees_crash(int sig, bool masked, bool ignored)
info.psi_siginfo.si_code <= ILL_BADSTK);
break;
case SIGFPE:
FORKEE_ASSERT_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
FORKEE_ASSERT_EQ(info.psi_siginfo.si_code, FPE_FLTDIV);
break;
case SIGBUS:
FORKEE_ASSERT_EQ(info.psi_siginfo.si_code, BUS_ADRERR);

View File

@ -1,4 +1,4 @@
/* $NetBSD: t_ptrace_wait.h,v 1.29 2020/06/17 08:23:18 rin Exp $ */
/* $NetBSD: t_ptrace_wait.h,v 1.30 2020/06/17 08:42:16 rin Exp $ */
/*-
* Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@ -678,15 +678,14 @@ are_fpu_exceptions_supported(void)
static void __used
trigger_fpe(void)
{
volatile int a = getpid();
volatile int b = atoi("0");
volatile double a = getpid();
volatile double 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