8245833: crash_with_sigfpe uses pthread_kill(SIGFPE) on macOS

Changed division code to ensure that real crash happens

Reviewed-by: dholmes
This commit is contained in:
Gerard Ziemski 2020-06-02 13:15:13 -05:00
parent 5f67125ba6
commit 8752e02e66

@ -1739,18 +1739,22 @@ bool VMError::check_timeout() {
#ifndef PRODUCT
typedef void (*voidfun_t)();
// Crash with an authentic sigfpe
volatile int sigfpe_int = 0;
static void crash_with_sigfpe() {
// generate a native synchronous SIGFPE where possible;
sigfpe_int = sigfpe_int/sigfpe_int;
// if that did not cause a signal (e.g. on ppc), just
// raise the signal.
volatile int x = 0;
volatile int y = 1/x;
#ifndef _WIN32
// OSX implements raise(sig) incorrectly so we need to
// explicitly target the current thread
pthread_kill(pthread_self(), SIGFPE);
#endif
} // end: crash_with_sigfpe
// crash with sigsegv at non-null address.