diff -r 3bd979f09721 -r 74832e7b5cad src/hotspot/share/utilities/vmError.cpp --- a/src/hotspot/share/utilities/vmError.cpp Wed Jun 05 14:01:01 2019 -0400 +++ b/src/hotspot/share/utilities/vmError.cpp Wed Jun 05 14:07:14 2019 -0400 @@ -406,12 +406,16 @@ return Atomic::load(&_step_start_time); } +void VMError::clear_step_start_time() { + return Atomic::store((jlong)0, &_step_start_time); +} + void VMError::report(outputStream* st, bool _verbose) { # define BEGIN if (_current_step == 0) { _current_step = __LINE__; # define STEP(s) } if (_current_step < __LINE__) { _current_step = __LINE__; _current_step_info = s; \ record_step_start_time(); _step_did_timeout = false; -# define END } +# define END clear_step_start_time(); } // don't allocate large buffer on stack static char buf[O_BUFLEN]; @@ -451,6 +455,15 @@ // Step to global timeout ratio is 4:1, so in order to be absolutely sure we hit the // global timeout, let's execute the timeout step five times. // See corresponding test in test/runtime/ErrorHandling/TimeoutInErrorHandlingTest.java + STEP("setup for test unresponsive error reporting step") + if (_verbose && TestUnresponsiveErrorHandler) { + // We record reporting_start_time for this test here because we + // care about the time spent executing TIMEOUT_TEST_STEP and not + // about the time it took us to get here. + tty->print_cr("Recording reporting_start_time for TestUnresponsiveErrorHandler."); + record_reporting_start_time(); + } + #define TIMEOUT_TEST_STEP STEP("test unresponsive error reporting step") \ if (_verbose && TestUnresponsiveErrorHandler) { os::infinite_sleep(); } TIMEOUT_TEST_STEP @@ -1358,7 +1371,14 @@ _error_reported = true; reporting_started(); - record_reporting_start_time(); + if (!TestUnresponsiveErrorHandler) { + // Record reporting_start_time unless we're running the + // TestUnresponsiveErrorHandler test. For that test we record + // reporting_start_time at the beginning of the test. + record_reporting_start_time(); + } else { + out.print_raw_cr("Delaying recording reporting_start_time for TestUnresponsiveErrorHandler."); + } if (ShowMessageBoxOnError || PauseAtExit) { show_message_box(buffer, sizeof(buffer)); @@ -1665,7 +1685,9 @@ // Timestamp is stored in nanos. if (reporting_start_time_l > 0) { const jlong end = reporting_start_time_l + (jlong)ErrorLogTimeout * TIMESTAMP_TO_SECONDS_FACTOR; - if (end <= now) { + if (end <= now && !_reporting_did_timeout) { + // We hit ErrorLogTimeout and we haven't interrupted the reporting + // thread yet. _reporting_did_timeout = true; interrupt_reporting_thread(); return true; // global timeout @@ -1678,7 +1700,9 @@ // hang for some reason, so this simple rule allows for three hanging step and still // hopefully leaves time enough for the rest of the steps to finish. const jlong end = step_start_time_l + (jlong)ErrorLogTimeout * TIMESTAMP_TO_SECONDS_FACTOR / 4; - if (end <= now) { + if (end <= now && !_step_did_timeout) { + // The step timed out and we haven't interrupted the reporting + // thread yet. _step_did_timeout = true; interrupt_reporting_thread(); return false; // (Not a global timeout)