8364819: Post-integration cleanups for JDK-8359820

Reviewed-by: dholmes, ayang, shade
This commit is contained in:
Anton Artemov 2025-08-20 07:28:36 +00:00 committed by Albert Mingkun Yang
parent c220a6c7bb
commit 4ffd2a8aa4
5 changed files with 31 additions and 17 deletions

View File

@ -202,7 +202,7 @@ static void handle_timeout(HandshakeOperation* op, JavaThread* target) {
}
if (target != nullptr) {
VMError::set_handshake_timed_out_thread(p2i(target));
VMError::set_handshake_timed_out_thread(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);

View File

@ -651,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()) {
VMError::set_safepoint_timed_out_thread(p2i(cur_thread));
VMError::set_safepoint_timed_out_thread(cur_thread);
if (!os::signal_thread(cur_thread, SIGILL, "blocking a safepoint")) {
break; // Could not send signal. Report fatal error.
}

View File

@ -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_timed_out_thread = p2i(nullptr);
volatile intptr_t VMError::_safepoint_timed_out_thread = p2i(nullptr);
Thread* volatile VMError::_handshake_timed_out_thread = nullptr;
Thread* volatile VMError::_safepoint_timed_out_thread = nullptr;
// List of environment variables that should be reported in error log file.
static const char* env_list[] = {
@ -821,10 +821,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 (_handshake_timed_out_thread == p2i(_thread)) {
st->print(" (sent by handshake timeout handler");
} else if (_safepoint_timed_out_thread == p2i(_thread)) {
st->print(" (sent by safepoint timeout handler");
if (get_handshake_timed_out_thread() == _thread) {
st->print(" (sent by handshake timeout handler)");
} else if (get_safepoint_timed_out_thread() == _thread) {
st->print(" (sent by safepoint timeout handler)");
} else {
st->print(" (sent by kill)");
}
@ -1338,12 +1338,24 @@ void VMError::report(outputStream* st, bool _verbose) {
# undef END
}
void VMError::set_handshake_timed_out_thread(intptr_t thread_addr) {
_handshake_timed_out_thread = thread_addr;
void VMError::set_handshake_timed_out_thread(Thread* thread) {
// Only preserve the first thread to time-out this way. The atomic operation ensures
// visibility to the target thread.
Atomic::replace_if_null(&_handshake_timed_out_thread, thread);
}
void VMError::set_safepoint_timed_out_thread(intptr_t thread_addr) {
_safepoint_timed_out_thread = thread_addr;
void VMError::set_safepoint_timed_out_thread(Thread* thread) {
// Only preserve the first thread to time-out this way. The atomic operation ensures
// visibility to the target thread.
Atomic::replace_if_null(&_safepoint_timed_out_thread, thread);
}
Thread* VMError::get_handshake_timed_out_thread() {
return Atomic::load(&_handshake_timed_out_thread);
}
Thread* VMError::get_safepoint_timed_out_thread() {
return Atomic::load(&_safepoint_timed_out_thread);
}
// Report for the vm_info_cmd. This prints out the information above omitting

View File

@ -143,8 +143,8 @@ class VMError : public AllStatic {
static void clear_step_start_time();
// Handshake/safepoint timed out threads
static volatile intptr_t _handshake_timed_out_thread;
static volatile intptr_t _safepoint_timed_out_thread;
static Thread* volatile _handshake_timed_out_thread;
static Thread* volatile _safepoint_timed_out_thread;
WINDOWS_ONLY([[noreturn]] static void raise_fail_fast(const void* exrecord, const void* context);)
@ -223,8 +223,10 @@ public:
static bool was_assert_poison_crash(const void* sigInfo);
static void set_handshake_timed_out_thread(intptr_t thread_addr);
static void set_safepoint_timed_out_thread(intptr_t thread_addr);
static void set_handshake_timed_out_thread(Thread* thread);
static void set_safepoint_timed_out_thread(Thread* thread);
static Thread* get_handshake_timed_out_thread();
static Thread* get_safepoint_timed_out_thread();
};
class VMErrorCallback {

View File

@ -88,7 +88,7 @@ public class TestAbortVMOnSafepointTimeout {
} else {
output.shouldContain("SIGILL");
if (Platform.isLinux()) {
output.shouldContain("(sent by safepoint timeout handler");
output.shouldContain("(sent by safepoint timeout handler)");
}
}
output.shouldNotHaveExitValue(0);