@@ -104,8 +104,8 @@ int VMError::_lineno;
104104size_t VMError::_size;
105105const size_t VMError::_reattempt_required_stack_headroom = 64 * K;
106106const 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.
111111static 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
0 commit comments