diff --git a/src/hotspot/os/posix/signals_posix.cpp b/src/hotspot/os/posix/signals_posix.cpp index adcc644df8d48..79f2f8f3f833c 100644 --- a/src/hotspot/os/posix/signals_posix.cpp +++ b/src/hotspot/os/posix/signals_posix.cpp @@ -1597,7 +1597,22 @@ static void SR_handler(int sig, siginfo_t* siginfo, ucontext_t* context) { PosixSignals::unblock_error_signals(); Thread* thread = Thread::current_or_null_safe(); - assert(thread != NULL, "Missing current thread in SR_handler"); + + // The suspend/resume signal may have been sent from outside the process, deliberately or + // accidentally. In that case the receiving thread may not be attached to the VM. We handle + // that case by asserting (debug VM) resp. writing a diagnostic message to tty and + // otherwise ignoring the stray signal (release VMs). + // We print the siginfo as part of the diagnostics, which also contains the sender pid of + // the stray signal. + if (thread == nullptr) { + stringStream ss; + ss.print_raw("Non-attached thread received stray SR signal ("); + os::print_siginfo(&ss, siginfo); + ss.print_raw(")."); + assert(thread != NULL, "%s.", ss.base()); + log_warning(os)("%s", ss.base()); + return; + } // On some systems we have seen signal delivery get "stuck" until the signal // mask is changed as part of thread termination. Check that the current thread