8137165: Tests fail in SR_Handler because thread is not VMThread or JavaThread
Reviewed-by: kbarrett
--- a/hotspot/src/os/linux/vm/os_linux.cpp Mon Mar 14 20:20:18 2016 +0100
+++ b/hotspot/src/os/linux/vm/os_linux.cpp Tue Mar 15 03:00:32 2016 -0400
@@ -881,6 +881,13 @@
assert(osthread != NULL, "osthread not set");
if (Thread::current()->osthread() == osthread) {
+#ifdef ASSERT
+ sigset_t current;
+ sigemptyset(¤t);
+ pthread_sigmask(SIG_SETMASK, NULL, ¤t);
+ assert(!sigismember(¤t, SR_signum), "SR signal should not be blocked!");
+#endif
+
// Restore caller's signal mask
sigset_t sigmask = osthread->caller_sigmask();
pthread_sigmask(SIG_SETMASK, &sigmask, NULL);
@@ -3903,7 +3910,8 @@
// after sigsuspend.
int old_errno = errno;
- Thread* thread = Thread::current();
+ Thread* thread = Thread::current_or_null_safe();
+ assert(thread != NULL, "Missing current thread in SR_handler");
OSThread* osthread = thread->osthread();
assert(thread->is_VM_thread() || thread->is_Java_thread(), "Must be VMThread or JavaThread");
@@ -3915,7 +3923,7 @@
os::SuspendResume::State state = osthread->sr.suspended();
if (state == os::SuspendResume::SR_SUSPENDED) {
sigset_t suspend_set; // signals for sigsuspend()
-
+ sigemptyset(&suspend_set);
// get current set of blocked signals and unblock resume signal
pthread_sigmask(SIG_BLOCK, NULL, &suspend_set);
sigdelset(&suspend_set, SR_signum);
@@ -4169,6 +4177,7 @@
// try to honor the signal mask
sigset_t oset;
+ sigemptyset(&oset);
pthread_sigmask(SIG_SETMASK, &(actp->sa_mask), &oset);
// call into the chained handler
@@ -4179,7 +4188,7 @@
}
// restore the signal mask
- pthread_sigmask(SIG_SETMASK, &oset, 0);
+ pthread_sigmask(SIG_SETMASK, &oset, NULL);
}
// Tell jvm's signal handler the signal is taken care of.
return true;
@@ -5716,6 +5725,7 @@
// Don't catch signals while blocked; let the running threads have the signals.
// (This allows a debugger to break into the running thread.)
sigset_t oldsigs;
+ sigemptyset(&oldsigs);
sigset_t* allowdebug_blocked = os::Linux::allowdebug_blocked_signals();
pthread_sigmask(SIG_BLOCK, allowdebug_blocked, &oldsigs);
#endif