Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/hotspot/share/runtime/handshake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/runtime/safepoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
Expand Down
32 changes: 22 additions & 10 deletions src/hotspot/share/utilities/vmError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = {
Expand Down Expand Up @@ -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)");
}
Expand Down Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions src/hotspot/share/utilities/vmError.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);)

Expand Down Expand Up @@ -223,8 +223,10 @@ class VMError : public AllStatic {

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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private static void verifyAbortVmApplied(OutputAnalyzer output) {
} else {
output.shouldContain("SIGILL");
if (Platform.isLinux()) {
output.shouldContain("(sent by safepoint timeout handler");
output.shouldContain("(sent by safepoint timeout handler)");
}
}
output.shouldNotHaveExitValue(0);
Expand Down