changeset 4545:d1c1d2ffc2c5

8009302: Mac OS X: JVM crash on infinite recursion on Appkit Thread Summary: Use SA_ONSTACK flag to ensure signal gets delivered properly. Reviewed-by: dholmes, coleenp Contributed-by: gerard.ziemski@oracle.com
author hseigel
date Thu, 06 Jun 2013 08:54:53 -0400
parents 02d2b7ba71ad
children 58e723f20009
files src/os/bsd/vm/os_bsd.cpp
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/os/bsd/vm/os_bsd.cpp	Wed May 15 22:35:36 2013 -0700
+++ b/src/os/bsd/vm/os_bsd.cpp	Thu Jun 06 08:54:53 2013 -0400
@@ -4269,6 +4269,19 @@
     sigAct.sa_sigaction = signalHandler;
     sigAct.sa_flags = SA_SIGINFO|SA_RESTART;
   }
+#if __APPLE__
+  // Needed for main thread as XNU (Mac OS X kernel) will only deliver SIGSEGV
+  // (which starts as SIGBUS) on main thread with faulting address inside "stack+guard pages"
+  // if the signal handler declares it will handle it on alternate stack.
+  // Notice we only declare we will handle it on alt stack, but we are not
+  // actually going to use real alt stack - this is just a workaround.
+  // Please see ux_exception.c, method catch_mach_exception_raise for details
+  // link http://www.opensource.apple.com/source/xnu/xnu-2050.18.24/bsd/uxkern/ux_exception.c
+  if (sig == SIGSEGV) {
+    sigAct.sa_flags |= SA_ONSTACK;
+  }
+#endif
+
   // Save flags, which are set by ours
   assert(sig > 0 && sig < MAXSIGNUM, "vm signal out of expected range");
   sigflags[sig] = sigAct.sa_flags;