8193308: Disallow installing user signal handlers for SIGBUS on OSX
authorrwestberg
Tue, 06 Feb 2018 15:48:50 +0100
changeset 48875 c1e7612f6b11
parent 48874 f09fdaad7321
child 48876 45b6aae769cc
8193308: Disallow installing user signal handlers for SIGBUS on OSX Reviewed-by: stuefe, dholmes
src/hotspot/os/bsd/jvm_bsd.cpp
test/jdk/sun/misc/SunMiscSignalTest.java
--- a/src/hotspot/os/bsd/jvm_bsd.cpp	Wed Feb 07 03:43:29 2018 +0100
+++ b/src/hotspot/os/bsd/jvm_bsd.cpp	Tue Feb 06 15:48:50 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -51,6 +51,12 @@
     case SIGILL:
     case SIGSEGV:
 
+#if defined(__APPLE__)
+    /* On Darwin, memory access errors commonly results in SIGBUS instead
+     * of SIGSEGV. */
+    case SIGBUS:
+#endif
+
     /* The following signal is used by the VM to dump thread stacks unless
        ReduceSignalUsage is set, in which case the user is allowed to set
        his own _native_ handler for this signal; thus, in either case,
--- a/test/jdk/sun/misc/SunMiscSignalTest.java	Wed Feb 07 03:43:29 2018 +0100
+++ b/test/jdk/sun/misc/SunMiscSignalTest.java	Tue Feb 06 15:48:50 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -112,7 +112,6 @@
         Object[][] posixSignals = {
                 {"HUP",  IsSupported.YES, registerXrs, raiseXrs, invokedXrs},
                 {"QUIT", IsSupported.YES, CanRegister.NO, CanRaise.NO, Invoked.NO},
-                {"BUS",  IsSupported.YES, CanRegister.YES, CanRaise.YES, invokedXrs},
                 {"USR1", IsSupported.YES, CanRegister.YES, CanRaise.YES, invokedXrs},
                 {"USR2", IsSupported.YES, CanRegister.YES, CanRaise.YES, invokedXrs},
                 {"PIPE", IsSupported.YES, CanRegister.YES, CanRaise.YES, invokedXrs},
@@ -132,6 +131,14 @@
                 {"SYS",   IsSupported.YES, CanRegister.YES, CanRaise.YES, invokedXrs},
         };
 
+        Object[][] posixNonOSXSignals = {
+                {"BUS",  IsSupported.YES, CanRegister.YES, CanRaise.YES, invokedXrs},
+        };
+
+        Object[][] posixOSXSignals = {
+                {"BUS",  IsSupported.YES, CanRegister.NO, CanRaise.NO, Invoked.NO},
+        };
+
         Object[][] windowsSignals = {
                 {"HUP",  IsSupported.NO, CanRegister.NO, CanRaise.NO, Invoked.NO},
                 {"QUIT", IsSupported.NO, CanRegister.NO, CanRaise.NO, Invoked.NO},
@@ -155,7 +162,9 @@
                 {"SYS",  IsSupported.NO, CanRegister.NO, CanRaise.NO, Invoked.NO},
         };
 
-        return concatArrays(commonSignals, (Platform.isWindows() ? windowsSignals : posixSignals));
+        Object[][] combinedPosixSignals = concatArrays(posixSignals,
+                                                       (Platform.isOSX() ? posixOSXSignals : posixNonOSXSignals));
+        return concatArrays(commonSignals, (Platform.isWindows() ? windowsSignals : combinedPosixSignals));
     }
 
     // Provider of invalid signal names