1.1 --- a/src/os/bsd/vm/os_bsd.cpp Tue Jun 04 19:39:21 2013 -0700 1.2 +++ b/src/os/bsd/vm/os_bsd.cpp Wed Jun 05 14:12:49 2013 -0400 1.3 @@ -3030,6 +3030,19 @@ 1.4 sigAct.sa_sigaction = signalHandler; 1.5 sigAct.sa_flags = SA_SIGINFO|SA_RESTART; 1.6 } 1.7 +#if __APPLE__ 1.8 + // Needed for main thread as XNU (Mac OS X kernel) will only deliver SIGSEGV 1.9 + // (which starts as SIGBUS) on main thread with faulting address inside "stack+guard pages" 1.10 + // if the signal handler declares it will handle it on alternate stack. 1.11 + // Notice we only declare we will handle it on alt stack, but we are not 1.12 + // actually going to use real alt stack - this is just a workaround. 1.13 + // Please see ux_exception.c, method catch_mach_exception_raise for details 1.14 + // link http://www.opensource.apple.com/source/xnu/xnu-2050.18.24/bsd/uxkern/ux_exception.c 1.15 + if (sig == SIGSEGV) { 1.16 + sigAct.sa_flags |= SA_ONSTACK; 1.17 + } 1.18 +#endif 1.19 + 1.20 // Save flags, which are set by ours 1.21 assert(sig > 0 && sig < MAXSIGNUM, "vm signal out of expected range"); 1.22 sigflags[sig] = sigAct.sa_flags;