Skip to content

Commit 4ffd2a8

Browse files
toxaartalbertnetymk
authored andcommitted
8364819: Post-integration cleanups for JDK-8359820
Reviewed-by: dholmes, ayang, shade
1 parent c220a6c commit 4ffd2a8

File tree

5 files changed

+31
-17
lines changed

5 files changed

+31
-17
lines changed

src/hotspot/share/runtime/handshake.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ static void handle_timeout(HandshakeOperation* op, JavaThread* target) {
202202
}
203203

204204
if (target != nullptr) {
205-
VMError::set_handshake_timed_out_thread(p2i(target));
205+
VMError::set_handshake_timed_out_thread(target);
206206
if (os::signal_thread(target, SIGILL, "cannot be handshaked")) {
207207
// Give target a chance to report the error and terminate the VM.
208208
os::naked_sleep(3000);

src/hotspot/share/runtime/safepoint.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ void SafepointSynchronize::print_safepoint_timeout() {
651651
// Send the blocking thread a signal to terminate and write an error file.
652652
for (JavaThreadIteratorWithHandle jtiwh; JavaThread *cur_thread = jtiwh.next(); ) {
653653
if (cur_thread->safepoint_state()->is_running()) {
654-
VMError::set_safepoint_timed_out_thread(p2i(cur_thread));
654+
VMError::set_safepoint_timed_out_thread(cur_thread);
655655
if (!os::signal_thread(cur_thread, SIGILL, "blocking a safepoint")) {
656656
break; // Could not send signal. Report fatal error.
657657
}

src/hotspot/share/utilities/vmError.cpp

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ int VMError::_lineno;
104104
size_t VMError::_size;
105105
const size_t VMError::_reattempt_required_stack_headroom = 64 * K;
106106
const intptr_t VMError::segfault_address = pd_segfault_address;
107-
volatile intptr_t VMError::_handshake_timed_out_thread = p2i(nullptr);
108-
volatile intptr_t VMError::_safepoint_timed_out_thread = p2i(nullptr);
107+
Thread* volatile VMError::_handshake_timed_out_thread = nullptr;
108+
Thread* volatile VMError::_safepoint_timed_out_thread = nullptr;
109109

110110
// List of environment variables that should be reported in error log file.
111111
static const char* env_list[] = {
@@ -821,10 +821,10 @@ void VMError::report(outputStream* st, bool _verbose) {
821821
st->print(" (0x%x)", _id); // signal number
822822
st->print(" at pc=" PTR_FORMAT, p2i(_pc));
823823
if (_siginfo != nullptr && os::signal_sent_by_kill(_siginfo)) {
824-
if (_handshake_timed_out_thread == p2i(_thread)) {
825-
st->print(" (sent by handshake timeout handler");
826-
} else if (_safepoint_timed_out_thread == p2i(_thread)) {
827-
st->print(" (sent by safepoint timeout handler");
824+
if (get_handshake_timed_out_thread() == _thread) {
825+
st->print(" (sent by handshake timeout handler)");
826+
} else if (get_safepoint_timed_out_thread() == _thread) {
827+
st->print(" (sent by safepoint timeout handler)");
828828
} else {
829829
st->print(" (sent by kill)");
830830
}
@@ -1338,12 +1338,24 @@ void VMError::report(outputStream* st, bool _verbose) {
13381338
# undef END
13391339
}
13401340

1341-
void VMError::set_handshake_timed_out_thread(intptr_t thread_addr) {
1342-
_handshake_timed_out_thread = thread_addr;
1341+
void VMError::set_handshake_timed_out_thread(Thread* thread) {
1342+
// Only preserve the first thread to time-out this way. The atomic operation ensures
1343+
// visibility to the target thread.
1344+
Atomic::replace_if_null(&_handshake_timed_out_thread, thread);
13431345
}
13441346

1345-
void VMError::set_safepoint_timed_out_thread(intptr_t thread_addr) {
1346-
_safepoint_timed_out_thread = thread_addr;
1347+
void VMError::set_safepoint_timed_out_thread(Thread* thread) {
1348+
// Only preserve the first thread to time-out this way. The atomic operation ensures
1349+
// visibility to the target thread.
1350+
Atomic::replace_if_null(&_safepoint_timed_out_thread, thread);
1351+
}
1352+
1353+
Thread* VMError::get_handshake_timed_out_thread() {
1354+
return Atomic::load(&_handshake_timed_out_thread);
1355+
}
1356+
1357+
Thread* VMError::get_safepoint_timed_out_thread() {
1358+
return Atomic::load(&_safepoint_timed_out_thread);
13471359
}
13481360

13491361
// Report for the vm_info_cmd. This prints out the information above omitting

src/hotspot/share/utilities/vmError.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ class VMError : public AllStatic {
143143
static void clear_step_start_time();
144144

145145
// Handshake/safepoint timed out threads
146-
static volatile intptr_t _handshake_timed_out_thread;
147-
static volatile intptr_t _safepoint_timed_out_thread;
146+
static Thread* volatile _handshake_timed_out_thread;
147+
static Thread* volatile _safepoint_timed_out_thread;
148148

149149
WINDOWS_ONLY([[noreturn]] static void raise_fail_fast(const void* exrecord, const void* context);)
150150

@@ -223,8 +223,10 @@ class VMError : public AllStatic {
223223

224224
static bool was_assert_poison_crash(const void* sigInfo);
225225

226-
static void set_handshake_timed_out_thread(intptr_t thread_addr);
227-
static void set_safepoint_timed_out_thread(intptr_t thread_addr);
226+
static void set_handshake_timed_out_thread(Thread* thread);
227+
static void set_safepoint_timed_out_thread(Thread* thread);
228+
static Thread* get_handshake_timed_out_thread();
229+
static Thread* get_safepoint_timed_out_thread();
228230
};
229231

230232
class VMErrorCallback {

test/hotspot/jtreg/runtime/Safepoint/TestAbortVMOnSafepointTimeout.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ private static void verifyAbortVmApplied(OutputAnalyzer output) {
8888
} else {
8989
output.shouldContain("SIGILL");
9090
if (Platform.isLinux()) {
91-
output.shouldContain("(sent by safepoint timeout handler");
91+
output.shouldContain("(sent by safepoint timeout handler)");
9292
}
9393
}
9494
output.shouldNotHaveExitValue(0);

0 commit comments

Comments
 (0)