From c764efb9eaed8ddc565fc3d907bc0357445d498b Mon Sep 17 00:00:00 2001 From: Anton Artemov Date: Wed, 16 Jul 2025 14:14:55 +0200 Subject: [PATCH 01/12] 8359820: Explicitly report SIGILL fired by handshake timeout handler in VMError::report() --- src/hotspot/share/runtime/handshake.cpp | 3 +++ src/hotspot/share/utilities/globalDefinitions.hpp | 4 ++++ src/hotspot/share/utilities/vmError.cpp | 6 +++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/runtime/handshake.cpp b/src/hotspot/share/runtime/handshake.cpp index c55803242de15..dfa7f6b5c32d4 100644 --- a/src/hotspot/share/runtime/handshake.cpp +++ b/src/hotspot/share/runtime/handshake.cpp @@ -46,6 +46,8 @@ #include "utilities/preserveException.hpp" #include "utilities/systemMemoryBarrier.hpp" +bool HandshakeTimeoutIndicator = false; + class HandshakeOperation : public CHeapObj { friend class HandshakeState; protected: @@ -201,6 +203,7 @@ static void handle_timeout(HandshakeOperation* op, JavaThread* target) { } if (target != nullptr) { + HandshakeTimeoutIndicator = true; if (os::signal_thread(target, SIGILL, "cannot be handshaked")) { // Give target a chance to report the error and terminate the VM. os::naked_sleep(3000); diff --git a/src/hotspot/share/utilities/globalDefinitions.hpp b/src/hotspot/share/utilities/globalDefinitions.hpp index 46daa8676445d..95ec398516a3c 100644 --- a/src/hotspot/share/utilities/globalDefinitions.hpp +++ b/src/hotspot/share/utilities/globalDefinitions.hpp @@ -1343,3 +1343,7 @@ std::add_rvalue_reference_t declval() noexcept; bool IEEE_subnormal_handling_OK(); #endif // SHARE_UTILITIES_GLOBALDEFINITIONS_HPP + +//---------------------------------------------------------------------------------------------------- +// Indicate VMError::report() that SIGILL came from handshake timeout handler +extern bool HandshakeTimeoutIndicator; \ No newline at end of file diff --git a/src/hotspot/share/utilities/vmError.cpp b/src/hotspot/share/utilities/vmError.cpp index 448df20c44e98..9f8c97f2b7d62 100644 --- a/src/hotspot/share/utilities/vmError.cpp +++ b/src/hotspot/share/utilities/vmError.cpp @@ -818,7 +818,11 @@ void VMError::report(outputStream* st, bool _verbose) { st->print(" (0x%x)", _id); // signal number st->print(" at pc=" PTR_FORMAT, p2i(_pc)); if (_siginfo != nullptr && os::signal_sent_by_kill(_siginfo)) { - st->print(" (sent by kill)"); + if (HandshakeTimeoutIndicator) { + st->print(" (sent by handshake timeout handler)"); + } else { + st->print(" (sent by kill)"); + } } } else { if (should_report_bug(_id)) { From 8a794a60381ea6d294b8f90e99ae853854deac76 Mon Sep 17 00:00:00 2001 From: Anton Artemov Date: Wed, 16 Jul 2025 14:24:13 +0200 Subject: [PATCH 02/12] 8359820: Fixed newline --- src/hotspot/share/utilities/globalDefinitions.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/share/utilities/globalDefinitions.hpp b/src/hotspot/share/utilities/globalDefinitions.hpp index 95ec398516a3c..c880c13a172db 100644 --- a/src/hotspot/share/utilities/globalDefinitions.hpp +++ b/src/hotspot/share/utilities/globalDefinitions.hpp @@ -1346,4 +1346,4 @@ bool IEEE_subnormal_handling_OK(); //---------------------------------------------------------------------------------------------------- // Indicate VMError::report() that SIGILL came from handshake timeout handler -extern bool HandshakeTimeoutIndicator; \ No newline at end of file +extern bool HandshakeTimeoutIndicator; From 48de6d837bb106dc8a65ef64b65109982f4a5c15 Mon Sep 17 00:00:00 2001 From: Anton Artemov Date: Thu, 17 Jul 2025 10:51:14 +0200 Subject: [PATCH 03/12] 8359820: Improved safepoint and handshake timeout report --- src/hotspot/share/runtime/handshake.cpp | 4 ++-- src/hotspot/share/runtime/safepoint.cpp | 3 +++ src/hotspot/share/utilities/globalDefinitions.hpp | 10 +++++++--- src/hotspot/share/utilities/vmError.cpp | 6 ++++-- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/hotspot/share/runtime/handshake.cpp b/src/hotspot/share/runtime/handshake.cpp index dfa7f6b5c32d4..3a30e2aafa0ad 100644 --- a/src/hotspot/share/runtime/handshake.cpp +++ b/src/hotspot/share/runtime/handshake.cpp @@ -46,7 +46,7 @@ #include "utilities/preserveException.hpp" #include "utilities/systemMemoryBarrier.hpp" -bool HandshakeTimeoutIndicator = false; +intptr_t HandshakeTimedOutThread = p2i(nullptr); class HandshakeOperation : public CHeapObj { friend class HandshakeState; @@ -203,7 +203,7 @@ static void handle_timeout(HandshakeOperation* op, JavaThread* target) { } if (target != nullptr) { - HandshakeTimeoutIndicator = true; + HandshakeTimedOutThread = p2i(target); if (os::signal_thread(target, SIGILL, "cannot be handshaked")) { // Give target a chance to report the error and terminate the VM. os::naked_sleep(3000); diff --git a/src/hotspot/share/runtime/safepoint.cpp b/src/hotspot/share/runtime/safepoint.cpp index ab896290007e0..8334ed04c4c05 100644 --- a/src/hotspot/share/runtime/safepoint.cpp +++ b/src/hotspot/share/runtime/safepoint.cpp @@ -67,6 +67,8 @@ #include "utilities/macros.hpp" #include "utilities/systemMemoryBarrier.hpp" +intptr_t SafepointTimedOutThread = p2i(nullptr); + static void post_safepoint_begin_event(EventSafepointBegin& event, uint64_t safepoint_id, int thread_count, @@ -650,6 +652,7 @@ void SafepointSynchronize::print_safepoint_timeout() { // Send the blocking thread a signal to terminate and write an error file. for (JavaThreadIteratorWithHandle jtiwh; JavaThread *cur_thread = jtiwh.next(); ) { if (cur_thread->safepoint_state()->is_running()) { + SafepointTimedOutThread = p2i(cur_thread); if (!os::signal_thread(cur_thread, SIGILL, "blocking a safepoint")) { break; // Could not send signal. Report fatal error. } diff --git a/src/hotspot/share/utilities/globalDefinitions.hpp b/src/hotspot/share/utilities/globalDefinitions.hpp index c880c13a172db..9306ab18401d9 100644 --- a/src/hotspot/share/utilities/globalDefinitions.hpp +++ b/src/hotspot/share/utilities/globalDefinitions.hpp @@ -1342,8 +1342,12 @@ std::add_rvalue_reference_t declval() noexcept; // handled. bool IEEE_subnormal_handling_OK(); +//---------------------------------------------------------------------------------------------------- +// Indicate VMError::report() that SIGILL came from handshake timeout handler, report which thread timed out +extern intptr_t HandshakeTimedOutThread; + +// Indicate VMError::report() that SIGILL came from safepoint timeout handler, report which thread timed out +extern intptr_t SafepointTimedOutThread; + #endif // SHARE_UTILITIES_GLOBALDEFINITIONS_HPP -//---------------------------------------------------------------------------------------------------- -// Indicate VMError::report() that SIGILL came from handshake timeout handler -extern bool HandshakeTimeoutIndicator; diff --git a/src/hotspot/share/utilities/vmError.cpp b/src/hotspot/share/utilities/vmError.cpp index 9f8c97f2b7d62..0fc19fc390b15 100644 --- a/src/hotspot/share/utilities/vmError.cpp +++ b/src/hotspot/share/utilities/vmError.cpp @@ -818,8 +818,10 @@ void VMError::report(outputStream* st, bool _verbose) { st->print(" (0x%x)", _id); // signal number st->print(" at pc=" PTR_FORMAT, p2i(_pc)); if (_siginfo != nullptr && os::signal_sent_by_kill(_siginfo)) { - if (HandshakeTimeoutIndicator) { - st->print(" (sent by handshake timeout handler)"); + if (HandshakeTimedOutThread != p2i(nullptr)) { + st->print(" (sent by handshake timeout handler, timed out thread " PTR_FORMAT ")", HandshakeTimedOutThread); + } else if (SafepointTimedOutThread != p2i(nullptr)) { + st->print(" (sent by safepoint timeout handler, timed out thread " PTR_FORMAT ")", SafepointTimedOutThread); } else { st->print(" (sent by kill)"); } From 044355b660b556db871b78f7c7e41b0ed43e1a78 Mon Sep 17 00:00:00 2001 From: Anton Artemov Date: Thu, 17 Jul 2025 11:03:32 +0200 Subject: [PATCH 04/12] 8359820: Removed extra line --- src/hotspot/share/utilities/globalDefinitions.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/hotspot/share/utilities/globalDefinitions.hpp b/src/hotspot/share/utilities/globalDefinitions.hpp index 9306ab18401d9..2800ad1127d4f 100644 --- a/src/hotspot/share/utilities/globalDefinitions.hpp +++ b/src/hotspot/share/utilities/globalDefinitions.hpp @@ -1350,4 +1350,3 @@ extern intptr_t HandshakeTimedOutThread; extern intptr_t SafepointTimedOutThread; #endif // SHARE_UTILITIES_GLOBALDEFINITIONS_HPP - From 4e4653150618d81ac723d74d667eff3e2ef93897 Mon Sep 17 00:00:00 2001 From: Anton Artemov Date: Thu, 17 Jul 2025 12:10:25 +0200 Subject: [PATCH 05/12] 8359820: Fixed test --- .../jtreg/runtime/Safepoint/TestAbortVMOnSafepointTimeout.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/runtime/Safepoint/TestAbortVMOnSafepointTimeout.java b/test/hotspot/jtreg/runtime/Safepoint/TestAbortVMOnSafepointTimeout.java index c85dd6573381a..9bd1000b042db 100644 --- a/test/hotspot/jtreg/runtime/Safepoint/TestAbortVMOnSafepointTimeout.java +++ b/test/hotspot/jtreg/runtime/Safepoint/TestAbortVMOnSafepointTimeout.java @@ -88,7 +88,7 @@ private static void verifyAbortVmApplied(OutputAnalyzer output) { } else { output.shouldContain("SIGILL"); if (Platform.isLinux()) { - output.shouldContain("(sent by kill)"); + output.shouldContain("(sent by safepoint timeout handler, timed out thread "); } } output.shouldNotHaveExitValue(0); From 40645638f770e9722ef080cf768a819d27018fc6 Mon Sep 17 00:00:00 2001 From: Anton Artemov Date: Fri, 18 Jul 2025 09:37:57 +0200 Subject: [PATCH 06/12] 8359820: Addressed reviewer's comments --- src/hotspot/share/runtime/handshake.cpp | 4 ++-- src/hotspot/share/runtime/safepoint.cpp | 4 ++-- src/hotspot/share/utilities/globalDefinitions.hpp | 4 ++-- src/hotspot/share/utilities/vmError.cpp | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/hotspot/share/runtime/handshake.cpp b/src/hotspot/share/runtime/handshake.cpp index 3a30e2aafa0ad..3ef6572dbd6a6 100644 --- a/src/hotspot/share/runtime/handshake.cpp +++ b/src/hotspot/share/runtime/handshake.cpp @@ -46,7 +46,7 @@ #include "utilities/preserveException.hpp" #include "utilities/systemMemoryBarrier.hpp" -intptr_t HandshakeTimedOutThread = p2i(nullptr); +intptr_t handshakeTimedOutThread = p2i(nullptr); class HandshakeOperation : public CHeapObj { friend class HandshakeState; @@ -203,7 +203,7 @@ static void handle_timeout(HandshakeOperation* op, JavaThread* target) { } if (target != nullptr) { - HandshakeTimedOutThread = p2i(target); + handshakeTimedOutThread = p2i(target); if (os::signal_thread(target, SIGILL, "cannot be handshaked")) { // Give target a chance to report the error and terminate the VM. os::naked_sleep(3000); diff --git a/src/hotspot/share/runtime/safepoint.cpp b/src/hotspot/share/runtime/safepoint.cpp index 8334ed04c4c05..1db73eefcce58 100644 --- a/src/hotspot/share/runtime/safepoint.cpp +++ b/src/hotspot/share/runtime/safepoint.cpp @@ -67,7 +67,7 @@ #include "utilities/macros.hpp" #include "utilities/systemMemoryBarrier.hpp" -intptr_t SafepointTimedOutThread = p2i(nullptr); +intptr_t safepointTimedOutThread = p2i(nullptr); static void post_safepoint_begin_event(EventSafepointBegin& event, uint64_t safepoint_id, @@ -652,7 +652,7 @@ void SafepointSynchronize::print_safepoint_timeout() { // Send the blocking thread a signal to terminate and write an error file. for (JavaThreadIteratorWithHandle jtiwh; JavaThread *cur_thread = jtiwh.next(); ) { if (cur_thread->safepoint_state()->is_running()) { - SafepointTimedOutThread = p2i(cur_thread); + safepointTimedOutThread = p2i(cur_thread); if (!os::signal_thread(cur_thread, SIGILL, "blocking a safepoint")) { break; // Could not send signal. Report fatal error. } diff --git a/src/hotspot/share/utilities/globalDefinitions.hpp b/src/hotspot/share/utilities/globalDefinitions.hpp index 2800ad1127d4f..455d30652d95d 100644 --- a/src/hotspot/share/utilities/globalDefinitions.hpp +++ b/src/hotspot/share/utilities/globalDefinitions.hpp @@ -1344,9 +1344,9 @@ bool IEEE_subnormal_handling_OK(); //---------------------------------------------------------------------------------------------------- // Indicate VMError::report() that SIGILL came from handshake timeout handler, report which thread timed out -extern intptr_t HandshakeTimedOutThread; +extern intptr_t handshakeTimedOutThread; // Indicate VMError::report() that SIGILL came from safepoint timeout handler, report which thread timed out -extern intptr_t SafepointTimedOutThread; +extern intptr_t safepointTimedOutThread; #endif // SHARE_UTILITIES_GLOBALDEFINITIONS_HPP diff --git a/src/hotspot/share/utilities/vmError.cpp b/src/hotspot/share/utilities/vmError.cpp index 0fc19fc390b15..4d720c4b1f86a 100644 --- a/src/hotspot/share/utilities/vmError.cpp +++ b/src/hotspot/share/utilities/vmError.cpp @@ -818,10 +818,10 @@ void VMError::report(outputStream* st, bool _verbose) { st->print(" (0x%x)", _id); // signal number st->print(" at pc=" PTR_FORMAT, p2i(_pc)); if (_siginfo != nullptr && os::signal_sent_by_kill(_siginfo)) { - if (HandshakeTimedOutThread != p2i(nullptr)) { - st->print(" (sent by handshake timeout handler, timed out thread " PTR_FORMAT ")", HandshakeTimedOutThread); - } else if (SafepointTimedOutThread != p2i(nullptr)) { - st->print(" (sent by safepoint timeout handler, timed out thread " PTR_FORMAT ")", SafepointTimedOutThread); + if (handshakeTimedOutThread == p2i(_thread)) { + st->print(" (sent by handshake timeout handler, timed out thread " PTR_FORMAT ")", handshakeTimedOutThread); + } else if (safepointTimedOutThread == p2i(_thread)) { + st->print(" (sent by safepoint timeout handler, timed out thread " PTR_FORMAT ")", safepointTimedOutThread); } else { st->print(" (sent by kill)"); } From 27cb77d2dbcdb60d95687c174093782bbda8fc23 Mon Sep 17 00:00:00 2001 From: Anton Artemov Date: Fri, 18 Jul 2025 11:09:38 +0200 Subject: [PATCH 07/12] 8359820: Addressed reviewer's comments --- src/hotspot/share/runtime/handshake.hpp | 3 +++ src/hotspot/share/runtime/safepoint.hpp | 3 +++ src/hotspot/share/utilities/globalDefinitions.hpp | 7 ------- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/hotspot/share/runtime/handshake.hpp b/src/hotspot/share/runtime/handshake.hpp index c6f3aad08db19..9260e232b5ce8 100644 --- a/src/hotspot/share/runtime/handshake.hpp +++ b/src/hotspot/share/runtime/handshake.hpp @@ -32,6 +32,9 @@ #include "runtime/orderAccess.hpp" #include "utilities/filterQueue.hpp" +// Indicate VMError::report() that SIGILL came from handshake timeout handler, report which thread timed out +extern intptr_t handshakeTimedOutThread; + class HandshakeOperation; class AsyncHandshakeOperation; class JavaThread; diff --git a/src/hotspot/share/runtime/safepoint.hpp b/src/hotspot/share/runtime/safepoint.hpp index 190095ec30ba0..df7301a8dc9fb 100644 --- a/src/hotspot/share/runtime/safepoint.hpp +++ b/src/hotspot/share/runtime/safepoint.hpp @@ -46,6 +46,9 @@ // exit safepoint methods, when a thread is blocked/restarted. Hence, all mutex exter/ // exit points *must* be at a safepoint. +// Indicate VMError::report() that SIGILL came from safepoint timeout handler, report which thread timed out +extern intptr_t safepointTimedOutThread; + class ThreadSafepointState; class SafepointStateTracker { diff --git a/src/hotspot/share/utilities/globalDefinitions.hpp b/src/hotspot/share/utilities/globalDefinitions.hpp index 455d30652d95d..46daa8676445d 100644 --- a/src/hotspot/share/utilities/globalDefinitions.hpp +++ b/src/hotspot/share/utilities/globalDefinitions.hpp @@ -1342,11 +1342,4 @@ std::add_rvalue_reference_t declval() noexcept; // handled. bool IEEE_subnormal_handling_OK(); -//---------------------------------------------------------------------------------------------------- -// Indicate VMError::report() that SIGILL came from handshake timeout handler, report which thread timed out -extern intptr_t handshakeTimedOutThread; - -// Indicate VMError::report() that SIGILL came from safepoint timeout handler, report which thread timed out -extern intptr_t safepointTimedOutThread; - #endif // SHARE_UTILITIES_GLOBALDEFINITIONS_HPP From 80a0b056561b9c509e702274a59608d23945a111 Mon Sep 17 00:00:00 2001 From: Anton Artemov Date: Fri, 18 Jul 2025 17:01:50 +0200 Subject: [PATCH 08/12] 8359820: Addressed reviewer's comments --- src/hotspot/share/runtime/handshake.cpp | 11 +++++++---- src/hotspot/share/runtime/handshake.hpp | 3 --- src/hotspot/share/runtime/safepoint.cpp | 5 ++--- src/hotspot/share/runtime/safepoint.hpp | 3 --- src/hotspot/share/utilities/vmError.cpp | 14 ++++++++++++-- src/hotspot/share/utilities/vmError.hpp | 7 +++++++ .../Safepoint/TestAbortVMOnSafepointTimeout.java | 2 +- 7 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/hotspot/share/runtime/handshake.cpp b/src/hotspot/share/runtime/handshake.cpp index 3ef6572dbd6a6..cd63316b3f30f 100644 --- a/src/hotspot/share/runtime/handshake.cpp +++ b/src/hotspot/share/runtime/handshake.cpp @@ -45,8 +45,7 @@ #include "utilities/globalDefinitions.hpp" #include "utilities/preserveException.hpp" #include "utilities/systemMemoryBarrier.hpp" - -intptr_t handshakeTimedOutThread = p2i(nullptr); +#include "utilities/vmError.hpp" class HandshakeOperation : public CHeapObj { friend class HandshakeState; @@ -203,7 +202,7 @@ static void handle_timeout(HandshakeOperation* op, JavaThread* target) { } if (target != nullptr) { - handshakeTimedOutThread = p2i(target); + VMError::set_handshake_timed_out_thread(p2i(target)); if (os::signal_thread(target, SIGILL, "cannot be handshaked")) { // Give target a chance to report the error and terminate the VM. os::naked_sleep(3000); @@ -211,7 +210,11 @@ static void handle_timeout(HandshakeOperation* op, JavaThread* target) { } else { log_error(handshake)("No thread with an unfinished handshake op(" INTPTR_FORMAT ") found.", p2i(op)); } - fatal("Handshake timeout"); + if (target != nullptr) { + fatal("Thread " PTR_FORMAT " has not cleared handshake op: " PTR_FORMAT ", then failed to terminate JVM", p2i(target), p2i(op)); + } else { + fatal("Handshake timeout"); + } } static void check_handshake_timeout(jlong start_time, HandshakeOperation* op, JavaThread* target = nullptr) { diff --git a/src/hotspot/share/runtime/handshake.hpp b/src/hotspot/share/runtime/handshake.hpp index 9260e232b5ce8..c6f3aad08db19 100644 --- a/src/hotspot/share/runtime/handshake.hpp +++ b/src/hotspot/share/runtime/handshake.hpp @@ -32,9 +32,6 @@ #include "runtime/orderAccess.hpp" #include "utilities/filterQueue.hpp" -// Indicate VMError::report() that SIGILL came from handshake timeout handler, report which thread timed out -extern intptr_t handshakeTimedOutThread; - class HandshakeOperation; class AsyncHandshakeOperation; class JavaThread; diff --git a/src/hotspot/share/runtime/safepoint.cpp b/src/hotspot/share/runtime/safepoint.cpp index 1db73eefcce58..6fcf1e6c0f5bf 100644 --- a/src/hotspot/share/runtime/safepoint.cpp +++ b/src/hotspot/share/runtime/safepoint.cpp @@ -66,8 +66,7 @@ #include "utilities/events.hpp" #include "utilities/macros.hpp" #include "utilities/systemMemoryBarrier.hpp" - -intptr_t safepointTimedOutThread = p2i(nullptr); +#include "utilities/vmError.hpp" static void post_safepoint_begin_event(EventSafepointBegin& event, uint64_t safepoint_id, @@ -652,7 +651,7 @@ void SafepointSynchronize::print_safepoint_timeout() { // Send the blocking thread a signal to terminate and write an error file. for (JavaThreadIteratorWithHandle jtiwh; JavaThread *cur_thread = jtiwh.next(); ) { if (cur_thread->safepoint_state()->is_running()) { - safepointTimedOutThread = p2i(cur_thread); + VMError::set_safepoint_timed_out_thread(p2i(cur_thread)); if (!os::signal_thread(cur_thread, SIGILL, "blocking a safepoint")) { break; // Could not send signal. Report fatal error. } diff --git a/src/hotspot/share/runtime/safepoint.hpp b/src/hotspot/share/runtime/safepoint.hpp index df7301a8dc9fb..190095ec30ba0 100644 --- a/src/hotspot/share/runtime/safepoint.hpp +++ b/src/hotspot/share/runtime/safepoint.hpp @@ -46,9 +46,6 @@ // exit safepoint methods, when a thread is blocked/restarted. Hence, all mutex exter/ // exit points *must* be at a safepoint. -// Indicate VMError::report() that SIGILL came from safepoint timeout handler, report which thread timed out -extern intptr_t safepointTimedOutThread; - class ThreadSafepointState; class SafepointStateTracker { diff --git a/src/hotspot/share/utilities/vmError.cpp b/src/hotspot/share/utilities/vmError.cpp index 4d720c4b1f86a..d76700b70a889 100644 --- a/src/hotspot/share/utilities/vmError.cpp +++ b/src/hotspot/share/utilities/vmError.cpp @@ -104,6 +104,8 @@ int VMError::_lineno; size_t VMError::_size; const size_t VMError::_reattempt_required_stack_headroom = 64 * K; const intptr_t VMError::segfault_address = pd_segfault_address; +volatile intptr_t VMError::handshakeTimedOutThread = p2i(nullptr); +volatile intptr_t VMError::safepointTimedOutThread = p2i(nullptr); // List of environment variables that should be reported in error log file. static const char* env_list[] = { @@ -819,9 +821,9 @@ void VMError::report(outputStream* st, bool _verbose) { st->print(" at pc=" PTR_FORMAT, p2i(_pc)); if (_siginfo != nullptr && os::signal_sent_by_kill(_siginfo)) { if (handshakeTimedOutThread == p2i(_thread)) { - st->print(" (sent by handshake timeout handler, timed out thread " PTR_FORMAT ")", handshakeTimedOutThread); + st->print(" (sent by handshake timeout handler"); } else if (safepointTimedOutThread == p2i(_thread)) { - st->print(" (sent by safepoint timeout handler, timed out thread " PTR_FORMAT ")", safepointTimedOutThread); + st->print(" (sent by safepoint timeout handler"); } else { st->print(" (sent by kill)"); } @@ -1335,6 +1337,14 @@ void VMError::report(outputStream* st, bool _verbose) { # undef END } +void VMError::set_handshake_timed_out_thread(intptr_t x){ + handshakeTimedOutThread = x; +} + +void VMError::set_safepoint_timed_out_thread(intptr_t x){ + safepointTimedOutThread = x; +} + // Report for the vm_info_cmd. This prints out the information above omitting // crash and thread specific information. If output is added above, it should be added // here also, if it is safe to call during a running process. diff --git a/src/hotspot/share/utilities/vmError.hpp b/src/hotspot/share/utilities/vmError.hpp index 0109b9bf0bd02..10b72e57f10b6 100644 --- a/src/hotspot/share/utilities/vmError.hpp +++ b/src/hotspot/share/utilities/vmError.hpp @@ -142,6 +142,10 @@ class VMError : public AllStatic { static jlong get_step_start_time(); static void clear_step_start_time(); + // Handshake/safepoint timed out threads + static volatile intptr_t handshakeTimedOutThread; + static volatile intptr_t safepointTimedOutThread; + WINDOWS_ONLY([[noreturn]] static void raise_fail_fast(const void* exrecord, const void* context);) public: @@ -218,6 +222,9 @@ class VMError : public AllStatic { static int prepare_log_file(const char* pattern, const char* default_pattern, bool overwrite_existing, char* buf, size_t buflen); static bool was_assert_poison_crash(const void* sigInfo); + + static void set_handshake_timed_out_thread(intptr_t x); + static void set_safepoint_timed_out_thread(intptr_t x); }; class VMErrorCallback { diff --git a/test/hotspot/jtreg/runtime/Safepoint/TestAbortVMOnSafepointTimeout.java b/test/hotspot/jtreg/runtime/Safepoint/TestAbortVMOnSafepointTimeout.java index 9bd1000b042db..e28dd7f4d2ae2 100644 --- a/test/hotspot/jtreg/runtime/Safepoint/TestAbortVMOnSafepointTimeout.java +++ b/test/hotspot/jtreg/runtime/Safepoint/TestAbortVMOnSafepointTimeout.java @@ -88,7 +88,7 @@ private static void verifyAbortVmApplied(OutputAnalyzer output) { } else { output.shouldContain("SIGILL"); if (Platform.isLinux()) { - output.shouldContain("(sent by safepoint timeout handler, timed out thread "); + output.shouldContain("(sent by safepoint timeout handler"); } } output.shouldNotHaveExitValue(0); From 9ccf09602af1d334f09566603d652f3bec43b63f Mon Sep 17 00:00:00 2001 From: Anton Artemov Date: Fri, 18 Jul 2025 17:04:56 +0200 Subject: [PATCH 09/12] 8359820: Fixed spaces --- src/hotspot/share/utilities/vmError.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/utilities/vmError.cpp b/src/hotspot/share/utilities/vmError.cpp index d76700b70a889..9fad49c2acebd 100644 --- a/src/hotspot/share/utilities/vmError.cpp +++ b/src/hotspot/share/utilities/vmError.cpp @@ -1337,11 +1337,11 @@ void VMError::report(outputStream* st, bool _verbose) { # undef END } -void VMError::set_handshake_timed_out_thread(intptr_t x){ +void VMError::set_handshake_timed_out_thread(intptr_t x) { handshakeTimedOutThread = x; } -void VMError::set_safepoint_timed_out_thread(intptr_t x){ +void VMError::set_safepoint_timed_out_thread(intptr_t x) { safepointTimedOutThread = x; } From 9392d81d4e723f70215b9a6b5c93fe6e752d36d4 Mon Sep 17 00:00:00 2001 From: Anton Artemov Date: Mon, 28 Jul 2025 12:03:12 +0200 Subject: [PATCH 10/12] 8359820: Addressed reviewer's comments --- src/hotspot/share/runtime/handshake.cpp | 2 +- src/hotspot/share/utilities/vmError.cpp | 16 ++++++++-------- src/hotspot/share/utilities/vmError.hpp | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/hotspot/share/runtime/handshake.cpp b/src/hotspot/share/runtime/handshake.cpp index cd63316b3f30f..39ae4f18998f2 100644 --- a/src/hotspot/share/runtime/handshake.cpp +++ b/src/hotspot/share/runtime/handshake.cpp @@ -211,7 +211,7 @@ static void handle_timeout(HandshakeOperation* op, JavaThread* target) { log_error(handshake)("No thread with an unfinished handshake op(" INTPTR_FORMAT ") found.", p2i(op)); } if (target != nullptr) { - fatal("Thread " PTR_FORMAT " has not cleared handshake op: " PTR_FORMAT ", then failed to terminate JVM", p2i(target), p2i(op)); + fatal("Thread " PTR_FORMAT " has not cleared handshake op %s, and failed to terminate the JVM", p2i(target), op->name()); } else { fatal("Handshake timeout"); } diff --git a/src/hotspot/share/utilities/vmError.cpp b/src/hotspot/share/utilities/vmError.cpp index 2878ce0cd0bb8..3cb322ab5091e 100644 --- a/src/hotspot/share/utilities/vmError.cpp +++ b/src/hotspot/share/utilities/vmError.cpp @@ -104,8 +104,8 @@ int VMError::_lineno; size_t VMError::_size; const size_t VMError::_reattempt_required_stack_headroom = 64 * K; const intptr_t VMError::segfault_address = pd_segfault_address; -volatile intptr_t VMError::handshakeTimedOutThread = p2i(nullptr); -volatile intptr_t VMError::safepointTimedOutThread = p2i(nullptr); +volatile intptr_t VMError::_handshake_timeout_thread = p2i(nullptr); +volatile intptr_t VMError::_safepoint_timeout_thread = p2i(nullptr); // List of environment variables that should be reported in error log file. static const char* env_list[] = { @@ -820,9 +820,9 @@ void VMError::report(outputStream* st, bool _verbose) { st->print(" (0x%x)", _id); // signal number st->print(" at pc=" PTR_FORMAT, p2i(_pc)); if (_siginfo != nullptr && os::signal_sent_by_kill(_siginfo)) { - if (handshakeTimedOutThread == p2i(_thread)) { + if (_handshake_timeout_thread == p2i(_thread)) { st->print(" (sent by handshake timeout handler"); - } else if (safepointTimedOutThread == p2i(_thread)) { + } else if (_safepoint_timeout_thread == p2i(_thread)) { st->print(" (sent by safepoint timeout handler"); } else { st->print(" (sent by kill)"); @@ -1337,12 +1337,12 @@ void VMError::report(outputStream* st, bool _verbose) { # undef END } -void VMError::set_handshake_timed_out_thread(intptr_t x) { - handshakeTimedOutThread = x; +void VMError::set_handshake_timed_out_thread(intptr_t thread_addr) { + _handshake_timeout_thread = thread_addr; } -void VMError::set_safepoint_timed_out_thread(intptr_t x) { - safepointTimedOutThread = x; +void VMError::set_safepoint_timed_out_thread(intptr_t thread_addr) { + _safepoint_timeout_thread = thread_addr; } // Report for the vm_info_cmd. This prints out the information above omitting diff --git a/src/hotspot/share/utilities/vmError.hpp b/src/hotspot/share/utilities/vmError.hpp index 10b72e57f10b6..ce5ffb21733fa 100644 --- a/src/hotspot/share/utilities/vmError.hpp +++ b/src/hotspot/share/utilities/vmError.hpp @@ -143,8 +143,8 @@ class VMError : public AllStatic { static void clear_step_start_time(); // Handshake/safepoint timed out threads - static volatile intptr_t handshakeTimedOutThread; - static volatile intptr_t safepointTimedOutThread; + static volatile intptr_t _handshake_timeout_thread; + static volatile intptr_t _safepoint_timeout_thread; WINDOWS_ONLY([[noreturn]] static void raise_fail_fast(const void* exrecord, const void* context);) From 9c914a50500e9a5147ea6099eadf7993a9849122 Mon Sep 17 00:00:00 2001 From: Anton Artemov Date: Mon, 28 Jul 2025 12:06:01 +0200 Subject: [PATCH 11/12] 8359820: Addressed reviewer's comments --- src/hotspot/share/utilities/vmError.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/utilities/vmError.hpp b/src/hotspot/share/utilities/vmError.hpp index ce5ffb21733fa..989e01cf10f54 100644 --- a/src/hotspot/share/utilities/vmError.hpp +++ b/src/hotspot/share/utilities/vmError.hpp @@ -223,8 +223,8 @@ class VMError : public AllStatic { static bool was_assert_poison_crash(const void* sigInfo); - static void set_handshake_timed_out_thread(intptr_t x); - static void set_safepoint_timed_out_thread(intptr_t x); + static void set_handshake_timed_out_thread(intptr_t thread_addr); + static void set_safepoint_timed_out_thread(intptr_t thread_addr); }; class VMErrorCallback { From d85769af641ce4b9aee02eff30af2a547b468492 Mon Sep 17 00:00:00 2001 From: Anton Artemov Date: Mon, 4 Aug 2025 10:34:07 +0200 Subject: [PATCH 12/12] 8359820: Addressed reviewer's comments --- src/hotspot/share/utilities/vmError.cpp | 12 ++++++------ src/hotspot/share/utilities/vmError.hpp | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/hotspot/share/utilities/vmError.cpp b/src/hotspot/share/utilities/vmError.cpp index 1b61d52e91dee..bd882a7ef3cbb 100644 --- a/src/hotspot/share/utilities/vmError.cpp +++ b/src/hotspot/share/utilities/vmError.cpp @@ -104,8 +104,8 @@ int VMError::_lineno; size_t VMError::_size; const size_t VMError::_reattempt_required_stack_headroom = 64 * K; const intptr_t VMError::segfault_address = pd_segfault_address; -volatile intptr_t VMError::_handshake_timeout_thread = p2i(nullptr); -volatile intptr_t VMError::_safepoint_timeout_thread = p2i(nullptr); +volatile intptr_t VMError::_handshake_timed_out_thread = p2i(nullptr); +volatile intptr_t VMError::_safepoint_timed_out_thread = p2i(nullptr); // List of environment variables that should be reported in error log file. static const char* env_list[] = { @@ -821,9 +821,9 @@ void VMError::report(outputStream* st, bool _verbose) { st->print(" (0x%x)", _id); // signal number st->print(" at pc=" PTR_FORMAT, p2i(_pc)); if (_siginfo != nullptr && os::signal_sent_by_kill(_siginfo)) { - if (_handshake_timeout_thread == p2i(_thread)) { + if (_handshake_timed_out_thread == p2i(_thread)) { st->print(" (sent by handshake timeout handler"); - } else if (_safepoint_timeout_thread == p2i(_thread)) { + } else if (_safepoint_timed_out_thread == p2i(_thread)) { st->print(" (sent by safepoint timeout handler"); } else { st->print(" (sent by kill)"); @@ -1339,11 +1339,11 @@ void VMError::report(outputStream* st, bool _verbose) { } void VMError::set_handshake_timed_out_thread(intptr_t thread_addr) { - _handshake_timeout_thread = thread_addr; + _handshake_timed_out_thread = thread_addr; } void VMError::set_safepoint_timed_out_thread(intptr_t thread_addr) { - _safepoint_timeout_thread = thread_addr; + _safepoint_timed_out_thread = thread_addr; } // Report for the vm_info_cmd. This prints out the information above omitting diff --git a/src/hotspot/share/utilities/vmError.hpp b/src/hotspot/share/utilities/vmError.hpp index 989e01cf10f54..96e37acff576f 100644 --- a/src/hotspot/share/utilities/vmError.hpp +++ b/src/hotspot/share/utilities/vmError.hpp @@ -143,8 +143,8 @@ class VMError : public AllStatic { static void clear_step_start_time(); // Handshake/safepoint timed out threads - static volatile intptr_t _handshake_timeout_thread; - static volatile intptr_t _safepoint_timeout_thread; + static volatile intptr_t _handshake_timed_out_thread; + static volatile intptr_t _safepoint_timed_out_thread; WINDOWS_ONLY([[noreturn]] static void raise_fail_fast(const void* exrecord, const void* context);)