8202014: Possible to receive signal before signal semaphore created
Initialize jdk.internal.misc.Signal in os_init2 and rename initialization functions. Reviewed-by: dholmes, stuefe
This commit is contained in:
parent
bc795f4eb8
commit
768632f24b
@ -1798,7 +1798,7 @@ static void local_sem_wait() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void os::signal_init_pd() {
|
static void jdk_misc_signal_init() {
|
||||||
// Initialize signal structures
|
// Initialize signal structures
|
||||||
::memset((void*)pending_signals, 0, sizeof(pending_signals));
|
::memset((void*)pending_signals, 0, sizeof(pending_signals));
|
||||||
|
|
||||||
@ -3023,7 +3023,7 @@ bool unblock_program_error_signals() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Renamed from 'signalHandler' to avoid collision with other shared libs.
|
// Renamed from 'signalHandler' to avoid collision with other shared libs.
|
||||||
void javaSignalHandler(int sig, siginfo_t* info, void* uc) {
|
static void javaSignalHandler(int sig, siginfo_t* info, void* uc) {
|
||||||
assert(info != NULL && uc != NULL, "it must be old kernel");
|
assert(info != NULL && uc != NULL, "it must be old kernel");
|
||||||
|
|
||||||
// Never leave program error signals blocked;
|
// Never leave program error signals blocked;
|
||||||
@ -3582,6 +3582,10 @@ jint os::init_2(void) {
|
|||||||
|
|
||||||
Aix::signal_sets_init();
|
Aix::signal_sets_init();
|
||||||
Aix::install_signal_handlers();
|
Aix::install_signal_handlers();
|
||||||
|
// Initialize data for jdk.internal.misc.Signal
|
||||||
|
if (!ReduceSignalUsage) {
|
||||||
|
jdk_misc_signal_init();
|
||||||
|
}
|
||||||
|
|
||||||
// Check and sets minimum stack sizes against command line options
|
// Check and sets minimum stack sizes against command line options
|
||||||
if (Posix::set_minimum_stack_sizes() == JNI_ERR) {
|
if (Posix::set_minimum_stack_sizes() == JNI_ERR) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -26,7 +26,6 @@
|
|||||||
#define OS_AIX_VM_OS_SHARE_AIX_HPP
|
#define OS_AIX_VM_OS_SHARE_AIX_HPP
|
||||||
|
|
||||||
// misc
|
// misc
|
||||||
void signalHandler(int, siginfo_t*, ucontext_t*);
|
|
||||||
void handle_unexpected_exception(Thread* thread, int sig, siginfo_t* info, address pc, address adjusted_pc);
|
void handle_unexpected_exception(Thread* thread, int sig, siginfo_t* info, address pc, address adjusted_pc);
|
||||||
#ifndef PRODUCT
|
#ifndef PRODUCT
|
||||||
void continue_with_dump(void);
|
void continue_with_dump(void);
|
||||||
|
@ -1818,7 +1818,7 @@ int os::sigexitnum_pd() {
|
|||||||
static volatile jint pending_signals[NSIG+1] = { 0 };
|
static volatile jint pending_signals[NSIG+1] = { 0 };
|
||||||
static Semaphore* sig_sem = NULL;
|
static Semaphore* sig_sem = NULL;
|
||||||
|
|
||||||
void os::signal_init_pd() {
|
static void jdk_misc_signal_init() {
|
||||||
// Initialize signal structures
|
// Initialize signal structures
|
||||||
::memset((void*)pending_signals, 0, sizeof(pending_signals));
|
::memset((void*)pending_signals, 0, sizeof(pending_signals));
|
||||||
|
|
||||||
@ -1831,7 +1831,7 @@ void os::signal_notify(int sig) {
|
|||||||
Atomic::inc(&pending_signals[sig]);
|
Atomic::inc(&pending_signals[sig]);
|
||||||
sig_sem->signal();
|
sig_sem->signal();
|
||||||
} else {
|
} else {
|
||||||
// Signal thread is not created with ReduceSignalUsage and signal_init_pd
|
// Signal thread is not created with ReduceSignalUsage and jdk_misc_signal_init
|
||||||
// initialization isn't called.
|
// initialization isn't called.
|
||||||
assert(ReduceSignalUsage, "signal semaphore should be created");
|
assert(ReduceSignalUsage, "signal semaphore should be created");
|
||||||
}
|
}
|
||||||
@ -2761,7 +2761,7 @@ extern "C" JNIEXPORT int JVM_handle_bsd_signal(int signo, siginfo_t* siginfo,
|
|||||||
void* ucontext,
|
void* ucontext,
|
||||||
int abort_if_unrecognized);
|
int abort_if_unrecognized);
|
||||||
|
|
||||||
void signalHandler(int sig, siginfo_t* info, void* uc) {
|
static void signalHandler(int sig, siginfo_t* info, void* uc) {
|
||||||
assert(info != NULL && uc != NULL, "it must be old kernel");
|
assert(info != NULL && uc != NULL, "it must be old kernel");
|
||||||
int orig_errno = errno; // Preserve errno value over signal handler.
|
int orig_errno = errno; // Preserve errno value over signal handler.
|
||||||
JVM_handle_bsd_signal(sig, info, uc, true);
|
JVM_handle_bsd_signal(sig, info, uc, true);
|
||||||
@ -3289,6 +3289,10 @@ jint os::init_2(void) {
|
|||||||
|
|
||||||
Bsd::signal_sets_init();
|
Bsd::signal_sets_init();
|
||||||
Bsd::install_signal_handlers();
|
Bsd::install_signal_handlers();
|
||||||
|
// Initialize data for jdk.internal.misc.Signal
|
||||||
|
if (!ReduceSignalUsage) {
|
||||||
|
jdk_misc_signal_init();
|
||||||
|
}
|
||||||
|
|
||||||
// Check and sets minimum stack sizes against command line options
|
// Check and sets minimum stack sizes against command line options
|
||||||
if (Posix::set_minimum_stack_sizes() == JNI_ERR) {
|
if (Posix::set_minimum_stack_sizes() == JNI_ERR) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -26,7 +26,6 @@
|
|||||||
#define OS_BSD_VM_OS_SHARE_BSD_HPP
|
#define OS_BSD_VM_OS_SHARE_BSD_HPP
|
||||||
|
|
||||||
// misc
|
// misc
|
||||||
void signalHandler(int, siginfo_t*, ucontext_t*);
|
|
||||||
void handle_unexpected_exception(Thread* thread, int sig, siginfo_t* info, address pc, address adjusted_pc);
|
void handle_unexpected_exception(Thread* thread, int sig, siginfo_t* info, address pc, address adjusted_pc);
|
||||||
#ifndef PRODUCT
|
#ifndef PRODUCT
|
||||||
void continue_with_dump(void);
|
void continue_with_dump(void);
|
||||||
|
@ -2520,7 +2520,7 @@ static volatile jint pending_signals[NSIG+1] = { 0 };
|
|||||||
static Semaphore* sig_sem = NULL;
|
static Semaphore* sig_sem = NULL;
|
||||||
static PosixSemaphore sr_semaphore;
|
static PosixSemaphore sr_semaphore;
|
||||||
|
|
||||||
void os::signal_init_pd() {
|
static void jdk_misc_signal_init() {
|
||||||
// Initialize signal structures
|
// Initialize signal structures
|
||||||
::memset((void*)pending_signals, 0, sizeof(pending_signals));
|
::memset((void*)pending_signals, 0, sizeof(pending_signals));
|
||||||
|
|
||||||
@ -2533,7 +2533,7 @@ void os::signal_notify(int sig) {
|
|||||||
Atomic::inc(&pending_signals[sig]);
|
Atomic::inc(&pending_signals[sig]);
|
||||||
sig_sem->signal();
|
sig_sem->signal();
|
||||||
} else {
|
} else {
|
||||||
// Signal thread is not created with ReduceSignalUsage and signal_init_pd
|
// Signal thread is not created with ReduceSignalUsage and jdk_misc_signal_init
|
||||||
// initialization isn't called.
|
// initialization isn't called.
|
||||||
assert(ReduceSignalUsage, "signal semaphore should be created");
|
assert(ReduceSignalUsage, "signal semaphore should be created");
|
||||||
}
|
}
|
||||||
@ -4444,7 +4444,7 @@ extern "C" JNIEXPORT int JVM_handle_linux_signal(int signo,
|
|||||||
void* ucontext,
|
void* ucontext,
|
||||||
int abort_if_unrecognized);
|
int abort_if_unrecognized);
|
||||||
|
|
||||||
void signalHandler(int sig, siginfo_t* info, void* uc) {
|
static void signalHandler(int sig, siginfo_t* info, void* uc) {
|
||||||
assert(info != NULL && uc != NULL, "it must be old kernel");
|
assert(info != NULL && uc != NULL, "it must be old kernel");
|
||||||
int orig_errno = errno; // Preserve errno value over signal handler.
|
int orig_errno = errno; // Preserve errno value over signal handler.
|
||||||
JVM_handle_linux_signal(sig, info, uc, true);
|
JVM_handle_linux_signal(sig, info, uc, true);
|
||||||
@ -4992,6 +4992,10 @@ jint os::init_2(void) {
|
|||||||
|
|
||||||
Linux::signal_sets_init();
|
Linux::signal_sets_init();
|
||||||
Linux::install_signal_handlers();
|
Linux::install_signal_handlers();
|
||||||
|
// Initialize data for jdk.internal.misc.Signal
|
||||||
|
if (!ReduceSignalUsage) {
|
||||||
|
jdk_misc_signal_init();
|
||||||
|
}
|
||||||
|
|
||||||
// Check and sets minimum stack sizes against command line options
|
// Check and sets minimum stack sizes against command line options
|
||||||
if (Posix::set_minimum_stack_sizes() == JNI_ERR) {
|
if (Posix::set_minimum_stack_sizes() == JNI_ERR) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -26,7 +26,6 @@
|
|||||||
#define OS_LINUX_VM_OS_SHARE_LINUX_HPP
|
#define OS_LINUX_VM_OS_SHARE_LINUX_HPP
|
||||||
|
|
||||||
// misc
|
// misc
|
||||||
void signalHandler(int, siginfo_t*, ucontext_t*);
|
|
||||||
void handle_unexpected_exception(Thread* thread, int sig, siginfo_t* info, address pc, address adjusted_pc);
|
void handle_unexpected_exception(Thread* thread, int sig, siginfo_t* info, address pc, address adjusted_pc);
|
||||||
#ifndef PRODUCT
|
#ifndef PRODUCT
|
||||||
void continue_with_dump(void);
|
void continue_with_dump(void);
|
||||||
|
@ -2124,7 +2124,7 @@ void os::Solaris::init_signal_mem() {
|
|||||||
memset(ourSigFlags, 0, sizeof(int) * (Maxsignum + 1));
|
memset(ourSigFlags, 0, sizeof(int) * (Maxsignum + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void os::signal_init_pd() {
|
static void jdk_misc_signal_init() {
|
||||||
// Initialize signal semaphore
|
// Initialize signal semaphore
|
||||||
sig_sem = new Semaphore();
|
sig_sem = new Semaphore();
|
||||||
}
|
}
|
||||||
@ -2134,7 +2134,7 @@ void os::signal_notify(int sig) {
|
|||||||
Atomic::inc(&pending_signals[sig]);
|
Atomic::inc(&pending_signals[sig]);
|
||||||
sig_sem->signal();
|
sig_sem->signal();
|
||||||
} else {
|
} else {
|
||||||
// Signal thread is not created with ReduceSignalUsage and signal_init_pd
|
// Signal thread is not created with ReduceSignalUsage and jdk_misc_signal_init
|
||||||
// initialization isn't called.
|
// initialization isn't called.
|
||||||
assert(ReduceSignalUsage, "signal semaphore should be created");
|
assert(ReduceSignalUsage, "signal semaphore should be created");
|
||||||
}
|
}
|
||||||
@ -4243,6 +4243,10 @@ jint os::init_2(void) {
|
|||||||
Solaris::signal_sets_init();
|
Solaris::signal_sets_init();
|
||||||
Solaris::init_signal_mem();
|
Solaris::init_signal_mem();
|
||||||
Solaris::install_signal_handlers();
|
Solaris::install_signal_handlers();
|
||||||
|
// Initialize data for jdk.internal.misc.Signal
|
||||||
|
if (!ReduceSignalUsage) {
|
||||||
|
jdk_misc_signal_init();
|
||||||
|
}
|
||||||
|
|
||||||
// initialize synchronization primitives to use either thread or
|
// initialize synchronization primitives to use either thread or
|
||||||
// lwp synchronization (controlled by UseLWPSynchronization)
|
// lwp synchronization (controlled by UseLWPSynchronization)
|
||||||
|
@ -1993,7 +1993,7 @@ int os::sigexitnum_pd() {
|
|||||||
static volatile jint pending_signals[NSIG+1] = { 0 };
|
static volatile jint pending_signals[NSIG+1] = { 0 };
|
||||||
static Semaphore* sig_sem = NULL;
|
static Semaphore* sig_sem = NULL;
|
||||||
|
|
||||||
void os::signal_init_pd() {
|
static void jdk_misc_signal_init() {
|
||||||
// Initialize signal structures
|
// Initialize signal structures
|
||||||
memset((void*)pending_signals, 0, sizeof(pending_signals));
|
memset((void*)pending_signals, 0, sizeof(pending_signals));
|
||||||
|
|
||||||
@ -2014,10 +2014,8 @@ void os::signal_init_pd() {
|
|||||||
// the CTRL-BREAK thread dump mechanism is also disabled in this
|
// the CTRL-BREAK thread dump mechanism is also disabled in this
|
||||||
// case. See bugs 4323062, 4345157, and related bugs.
|
// case. See bugs 4323062, 4345157, and related bugs.
|
||||||
|
|
||||||
if (!ReduceSignalUsage) {
|
// Add a CTRL-C handler
|
||||||
// Add a CTRL-C handler
|
SetConsoleCtrlHandler(consoleHandler, TRUE);
|
||||||
SetConsoleCtrlHandler(consoleHandler, TRUE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void os::signal_notify(int sig) {
|
void os::signal_notify(int sig) {
|
||||||
@ -2025,7 +2023,7 @@ void os::signal_notify(int sig) {
|
|||||||
Atomic::inc(&pending_signals[sig]);
|
Atomic::inc(&pending_signals[sig]);
|
||||||
sig_sem->signal();
|
sig_sem->signal();
|
||||||
} else {
|
} else {
|
||||||
// Signal thread is not created with ReduceSignalUsage and signal_init_pd
|
// Signal thread is not created with ReduceSignalUsage and jdk_misc_signal_init
|
||||||
// initialization isn't called.
|
// initialization isn't called.
|
||||||
assert(ReduceSignalUsage, "signal semaphore should be created");
|
assert(ReduceSignalUsage, "signal semaphore should be created");
|
||||||
}
|
}
|
||||||
@ -4132,6 +4130,11 @@ jint os::init_2(void) {
|
|||||||
|
|
||||||
SymbolEngine::recalc_search_path();
|
SymbolEngine::recalc_search_path();
|
||||||
|
|
||||||
|
// Initialize data for jdk.internal.misc.Signal
|
||||||
|
if (!ReduceSignalUsage) {
|
||||||
|
jdk_misc_signal_init();
|
||||||
|
}
|
||||||
|
|
||||||
return JNI_OK;
|
return JNI_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,7 +443,7 @@ void os::init_before_ergo() {
|
|||||||
VM_Version::init_before_ergo();
|
VM_Version::init_before_ergo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void os::signal_init(TRAPS) {
|
void os::initialize_jdk_signal_support(TRAPS) {
|
||||||
if (!ReduceSignalUsage) {
|
if (!ReduceSignalUsage) {
|
||||||
// Setup JavaThread for processing signals
|
// Setup JavaThread for processing signals
|
||||||
Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK);
|
Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK);
|
||||||
@ -473,8 +473,6 @@ void os::signal_init(TRAPS) {
|
|||||||
thread_oop, // ARG 1
|
thread_oop, // ARG 1
|
||||||
CHECK);
|
CHECK);
|
||||||
|
|
||||||
os::signal_init_pd();
|
|
||||||
|
|
||||||
{ MutexLocker mu(Threads_lock);
|
{ MutexLocker mu(Threads_lock);
|
||||||
JavaThread* signal_thread = new JavaThread(&signal_thread_entry);
|
JavaThread* signal_thread = new JavaThread(&signal_thread_entry);
|
||||||
|
|
||||||
|
@ -784,8 +784,7 @@ class os: AllStatic {
|
|||||||
static struct hostent* get_host_by_name(char* name);
|
static struct hostent* get_host_by_name(char* name);
|
||||||
|
|
||||||
// Support for signals (see JVM_RaiseSignal, JVM_RegisterSignal)
|
// Support for signals (see JVM_RaiseSignal, JVM_RegisterSignal)
|
||||||
static void signal_init(TRAPS);
|
static void initialize_jdk_signal_support(TRAPS);
|
||||||
static void signal_init_pd();
|
|
||||||
static void signal_notify(int signal_number);
|
static void signal_notify(int signal_number);
|
||||||
static void* signal(int signal_number, void* handler);
|
static void* signal(int signal_number, void* handler);
|
||||||
static void signal_raise(int signal_number);
|
static void signal_raise(int signal_number);
|
||||||
|
@ -3813,7 +3813,7 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
|
|||||||
#endif // INCLUDE_MANAGEMENT
|
#endif // INCLUDE_MANAGEMENT
|
||||||
|
|
||||||
// Signal Dispatcher needs to be started before VMInit event is posted
|
// Signal Dispatcher needs to be started before VMInit event is posted
|
||||||
os::signal_init(CHECK_JNI_ERR);
|
os::initialize_jdk_signal_support(CHECK_JNI_ERR);
|
||||||
|
|
||||||
// Start Attach Listener if +StartAttachListener or it can't be started lazily
|
// Start Attach Listener if +StartAttachListener or it can't be started lazily
|
||||||
if (!DisableAttachMechanism) {
|
if (!DisableAttachMechanism) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user