Mercurial > hg > graal-jvmci-8
diff src/os/posix/vm/os_posix.cpp @ 12147:c636758ea616
Merge
author | dcubed |
---|---|
date | Fri, 30 Aug 2013 07:04:42 -0700 |
parents | f92b82d454fa cc56f122f3f7 |
children | c250880a6673 2b8e28fdf503 |
line wrap: on
line diff
--- a/src/os/posix/vm/os_posix.cpp Fri Aug 30 00:29:52 2013 -0700 +++ b/src/os/posix/vm/os_posix.cpp Fri Aug 30 07:04:42 2013 -0700 @@ -30,6 +30,8 @@ #include <unistd.h> #include <sys/resource.h> #include <sys/utsname.h> +#include <pthread.h> +#include <signal.h> // Check core dump limit and report possible place where core can be found @@ -320,11 +322,17 @@ * The callback is supposed to provide the method that should be protected. */ bool os::WatcherThreadCrashProtection::call(os::CrashProtectionCallback& cb) { + sigset_t saved_sig_mask; + assert(Thread::current()->is_Watcher_thread(), "Only for WatcherThread"); assert(!WatcherThread::watcher_thread()->has_crash_protection(), "crash_protection already set?"); - if (sigsetjmp(_jmpbuf, 1) == 0) { + // we cannot rely on sigsetjmp/siglongjmp to save/restore the signal mask + // since on at least some systems (OS X) siglongjmp will restore the mask + // for the process, not the thread + pthread_sigmask(0, NULL, &saved_sig_mask); + if (sigsetjmp(_jmpbuf, 0) == 0) { // make sure we can see in the signal handler that we have crash protection // installed WatcherThread::watcher_thread()->set_crash_protection(this); @@ -334,6 +342,7 @@ return true; } // this happens when we siglongjmp() back + pthread_sigmask(SIG_SETMASK, &saved_sig_mask, NULL); WatcherThread::watcher_thread()->set_crash_protection(NULL); return false; }