Mercurial > hg > graal-jvmci-8
comparison 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 |
comparison
equal
deleted
inserted
replaced
12128:c169f7038414 | 12147:c636758ea616 |
---|---|
28 #include "utilities/vmError.hpp" | 28 #include "utilities/vmError.hpp" |
29 | 29 |
30 #include <unistd.h> | 30 #include <unistd.h> |
31 #include <sys/resource.h> | 31 #include <sys/resource.h> |
32 #include <sys/utsname.h> | 32 #include <sys/utsname.h> |
33 #include <pthread.h> | |
34 #include <signal.h> | |
33 | 35 |
34 | 36 |
35 // Check core dump limit and report possible place where core can be found | 37 // Check core dump limit and report possible place where core can be found |
36 void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* buffer, size_t bufferSize) { | 38 void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* buffer, size_t bufferSize) { |
37 int n; | 39 int n; |
318 * Protects the callback call so that SIGSEGV / SIGBUS jumps back into this | 320 * Protects the callback call so that SIGSEGV / SIGBUS jumps back into this |
319 * method and returns false. If none of the signals are raised, returns true. | 321 * method and returns false. If none of the signals are raised, returns true. |
320 * The callback is supposed to provide the method that should be protected. | 322 * The callback is supposed to provide the method that should be protected. |
321 */ | 323 */ |
322 bool os::WatcherThreadCrashProtection::call(os::CrashProtectionCallback& cb) { | 324 bool os::WatcherThreadCrashProtection::call(os::CrashProtectionCallback& cb) { |
325 sigset_t saved_sig_mask; | |
326 | |
323 assert(Thread::current()->is_Watcher_thread(), "Only for WatcherThread"); | 327 assert(Thread::current()->is_Watcher_thread(), "Only for WatcherThread"); |
324 assert(!WatcherThread::watcher_thread()->has_crash_protection(), | 328 assert(!WatcherThread::watcher_thread()->has_crash_protection(), |
325 "crash_protection already set?"); | 329 "crash_protection already set?"); |
326 | 330 |
327 if (sigsetjmp(_jmpbuf, 1) == 0) { | 331 // we cannot rely on sigsetjmp/siglongjmp to save/restore the signal mask |
332 // since on at least some systems (OS X) siglongjmp will restore the mask | |
333 // for the process, not the thread | |
334 pthread_sigmask(0, NULL, &saved_sig_mask); | |
335 if (sigsetjmp(_jmpbuf, 0) == 0) { | |
328 // make sure we can see in the signal handler that we have crash protection | 336 // make sure we can see in the signal handler that we have crash protection |
329 // installed | 337 // installed |
330 WatcherThread::watcher_thread()->set_crash_protection(this); | 338 WatcherThread::watcher_thread()->set_crash_protection(this); |
331 cb.call(); | 339 cb.call(); |
332 // and clear the crash protection | 340 // and clear the crash protection |
333 WatcherThread::watcher_thread()->set_crash_protection(NULL); | 341 WatcherThread::watcher_thread()->set_crash_protection(NULL); |
334 return true; | 342 return true; |
335 } | 343 } |
336 // this happens when we siglongjmp() back | 344 // this happens when we siglongjmp() back |
345 pthread_sigmask(SIG_SETMASK, &saved_sig_mask, NULL); | |
337 WatcherThread::watcher_thread()->set_crash_protection(NULL); | 346 WatcherThread::watcher_thread()->set_crash_protection(NULL); |
338 return false; | 347 return false; |
339 } | 348 } |
340 | 349 |
341 void os::WatcherThreadCrashProtection::restore() { | 350 void os::WatcherThreadCrashProtection::restore() { |