Skip to content
This repository has been archived by the owner. It is now read-only.
Browse files
8245833: crash_with_sigfpe uses pthread_kill(SIGFPE) on macOS
Changed division code to ensure that real crash happens

Reviewed-by: dholmes
  • Loading branch information
Gerard Ziemski committed Jun 2, 2020
1 parent 5f67125 commit 8752e02e66256e9b6304ef14dbb6a354b594bd72
Showing with 6 additions and 2 deletions.
  1. +6 −2 src/hotspot/share/utilities/vmError.cpp
@@ -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);

} // end: crash_with_sigfpe

// crash with sigsegv at non-null address.

0 comments on commit 8752e02

Please sign in to comment.