8288556: VM crashes if it gets sent SIGUSR2 from outside

Reviewed-by: dholmes, lucy
This commit is contained in:
Thomas Stuefe 2022-06-21 07:55:48 +00:00
parent 5e680d0594
commit 701ea3beaa

View File

@ -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