openjdk-1.8.0/8159461-8288556-getComponentType.patch
2025-02-27 16:26:50 +08:00

227 lines
9.6 KiB
Diff

From 372039cd8e13b946a93c56a98b019552e4944ee1 Mon Sep 17 00:00:00 2001
Subject: 8159461-8288556-getComponentType
---
hotspot/src/os/aix/vm/os_aix.cpp | 37 ++++++++++++++++++++---
hotspot/src/os/bsd/vm/os_bsd.cpp | 38 ++++++++++++++++++++----
hotspot/src/os/linux/vm/os_linux.cpp | 35 +++++++++++++++++++---
hotspot/src/share/vm/opto/c2compiler.cpp | 1 +
hotspot/src/share/vm/runtime/thread.cpp | 6 ++--
5 files changed, 102 insertions(+), 15 deletions(-)
diff --git a/hotspot/src/os/aix/vm/os_aix.cpp b/hotspot/src/os/aix/vm/os_aix.cpp
index c6ccec8a8..f7520dedd 100644
--- a/hotspot/src/os/aix/vm/os_aix.cpp
+++ b/hotspot/src/os/aix/vm/os_aix.cpp
@@ -3066,7 +3066,8 @@ void os::hint_no_preempt() {}
// - sets target osthread state to continue
// - sends signal to end the sigsuspend loop in the SR_handler
//
-// Note that the SR_lock plays no role in this suspend/resume protocol.
+// Note that the SR_lock plays no role in this suspend/resume protocol,
+// but is checked for NULL in SR_handler as a thread termination indicator.
//
static void resume_clear_context(OSThread *osthread) {
@@ -3098,10 +3099,38 @@ static void SR_handler(int sig, siginfo_t* siginfo, ucontext_t* context) {
// after sigsuspend.
int old_errno = errno;
- Thread* thread = Thread::current();
- OSThread* osthread = thread->osthread();
+ Thread* thread = Thread::current_or_null();
+
+ // 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 == NULL) {
+ bufferedStream st;
+ st.print_raw("Non-attached thread received stray SR signal (");
+ os::Posix::print_siginfo_brief(&st, siginfo);
+ st.print_raw(").");
+ assert(thread != NULL, st.base());
+ warning("%s", st.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
+ // has not already terminated (via SR_lock()) - else the following assertion
+ // will fail because the thread is no longer a JavaThread as the ~JavaThread
+ // destructor has completed.
+
+ if (thread->SR_lock() == NULL) {
+ return;
+ }
+
assert(thread->is_VM_thread() || thread->is_Java_thread(), "Must be VMThread or JavaThread");
+ OSThread* osthread = thread->osthread();
+
os::SuspendResume::State current = osthread->sr.state();
if (current == os::SuspendResume::SR_SUSPEND_REQUEST) {
suspend_save_context(osthread, siginfo, context);
@@ -5299,4 +5328,4 @@ void TestReserveMemorySpecial_test() {
// stubbed-out trim-native support
bool os::can_trim_native_heap() { return false; }
bool os::should_trim_native_heap() { return false; }
-bool os::trim_native_heap(os::size_change_t* rss_change) { return false; }
\ No newline at end of file
+bool os::trim_native_heap(os::size_change_t* rss_change) { return false; }
diff --git a/hotspot/src/os/bsd/vm/os_bsd.cpp b/hotspot/src/os/bsd/vm/os_bsd.cpp
index 7942c8545..223222602 100644
--- a/hotspot/src/os/bsd/vm/os_bsd.cpp
+++ b/hotspot/src/os/bsd/vm/os_bsd.cpp
@@ -2902,8 +2902,8 @@ void os::hint_no_preempt() {}
// - sets target osthread state to continue
// - sends signal to end the sigsuspend loop in the SR_handler
//
-// Note that the SR_lock plays no role in this suspend/resume protocol.
-//
+// Note that the SR_lock plays no role in this suspend/resume protocol,
+// but is checked for NULL in SR_handler as a thread termination indicator.
static void resume_clear_context(OSThread *osthread) {
osthread->set_ucontext(NULL);
@@ -2934,10 +2934,38 @@ static void SR_handler(int sig, siginfo_t* siginfo, ucontext_t* context) {
// after sigsuspend.
int old_errno = errno;
- Thread* thread = Thread::current();
- OSThread* osthread = thread->osthread();
+ Thread* thread = Thread::current_or_null();
+
+ // 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 == NULL) {
+ bufferedStream st;
+ st.print_raw("Non-attached thread received stray SR signal (");
+ os::Posix::print_siginfo_brief(&st, siginfo);
+ st.print_raw(").");
+ assert(thread != NULL, st.base());
+ warning("%s", st.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
+ // has not already terminated (via SR_lock()) - else the following assertion
+ // will fail because the thread is no longer a JavaThread as the ~JavaThread
+ // destructor has completed.
+
+ if (thread->SR_lock() == NULL) {
+ return;
+ }
+
assert(thread->is_VM_thread() || thread->is_Java_thread(), "Must be VMThread or JavaThread");
+ OSThread* osthread = thread->osthread();
+
os::SuspendResume::State current = osthread->sr.state();
if (current == os::SuspendResume::SR_SUSPEND_REQUEST) {
suspend_save_context(osthread, siginfo, context);
@@ -4911,4 +4939,4 @@ void TestReserveMemorySpecial_test() {
// stubbed-out trim-native support
bool os::can_trim_native_heap() { return false; }
bool os::should_trim_native_heap() { return false; }
-bool os::trim_native_heap(os::size_change_t* rss_change) { return false; }
\ No newline at end of file
+bool os::trim_native_heap(os::size_change_t* rss_change) { return false; }
diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp
index 8d846b57b..ec4222d42 100644
--- a/hotspot/src/os/linux/vm/os_linux.cpp
+++ b/hotspot/src/os/linux/vm/os_linux.cpp
@@ -4698,8 +4698,8 @@ void os::hint_no_preempt() {}
// - sets target osthread state to continue
// - sends signal to end the sigsuspend loop in the SR_handler
//
-// Note that the SR_lock plays no role in this suspend/resume protocol.
-//
+// Note that the SR_lock plays no role in this suspend/resume protocol,
+// but is checked for NULL in SR_handler as a thread termination indicator.
static void resume_clear_context(OSThread *osthread) {
osthread->set_ucontext(NULL);
@@ -4731,10 +4731,37 @@ static void SR_handler(int sig, siginfo_t* siginfo, ucontext_t* context) {
int old_errno = errno;
Thread* thread = Thread::current_or_null();
- assert(thread != NULL, "Missing current thread in SR_handler");
- OSThread* osthread = thread->osthread();
+
+ // 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 == NULL) {
+ bufferedStream st;
+ st.print_raw("Non-attached thread received stray SR signal (");
+ os::Posix::print_siginfo_brief(&st, siginfo);
+ st.print_raw(").");
+ assert(thread != NULL, st.base());
+ warning("%s", st.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
+ // has not already terminated (via SR_lock()) - else the following assertion
+ // will fail because the thread is no longer a JavaThread as the ~JavaThread
+ // destructor has completed.
+
+ if (thread->SR_lock() == NULL) {
+ return;
+ }
+
assert(thread->is_VM_thread() || thread->is_Java_thread(), "Must be VMThread or JavaThread");
+ OSThread* osthread = thread->osthread();
+
os::SuspendResume::State current = osthread->sr.state();
if (current == os::SuspendResume::SR_SUSPEND_REQUEST) {
suspend_save_context(osthread, siginfo, context);
diff --git a/hotspot/src/share/vm/opto/c2compiler.cpp b/hotspot/src/share/vm/opto/c2compiler.cpp
index d2485ddfc..8fdbb93f1 100644
--- a/hotspot/src/share/vm/opto/c2compiler.cpp
+++ b/hotspot/src/share/vm/opto/c2compiler.cpp
@@ -435,6 +435,7 @@ bool C2Compiler::is_intrinsic_supported(methodHandle method, bool is_virtual) {
case vmIntrinsics::_dgemm_dgemm:
case vmIntrinsics::_dgemv_dgemv:
case vmIntrinsics::_f2jblas_ddot:
+ case vmIntrinsics::_getComponentType:
break;
default:
return false;
diff --git a/hotspot/src/share/vm/runtime/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp
index 95dbb77fb..a5758734b 100644
--- a/hotspot/src/share/vm/runtime/thread.cpp
+++ b/hotspot/src/share/vm/runtime/thread.cpp
@@ -380,11 +380,13 @@ Thread::~Thread() {
delete handle_area();
delete metadata_handles();
+ // SR_handler uses this as a termination indicator -
+ delete _SR_lock;
+ _SR_lock = NULL;
+
// osthread() can be NULL, if creation of thread failed.
if (osthread() != NULL) os::free_thread(osthread());
- delete _SR_lock;
-
// clear thread local storage if the Thread is deleting itself
if (this == Thread::current()) {
ThreadLocalStorage::set_thread(NULL);
--
2.22.0