< prev index next >
src/share/vm/runtime/thread.cpp
Print this page
rev 12508 : 8166944: Hanging Error Reporting steps may lead to torn error logs.
Reviewed-by: cjplummer, dholmes
Summary: Interupt error reporting if reporting steps hang to enable subsequent reporting steps to run.
*** 1287,1318 ****
int time_waited = sleep();
if (is_error_reported()) {
// A fatal error has happened, the error handler(VMError::report_and_die)
// should abort JVM after creating an error log file. However in some
! // rare cases, the error handler itself might deadlock. Here we try to
! // kill JVM if the fatal error handler fails to abort in 2 minutes.
! //
// This code is in WatcherThread because WatcherThread wakes up
// periodically so the fatal error handler doesn't need to do anything;
// also because the WatcherThread is less likely to crash than other
// threads.
for (;;) {
! if (!ShowMessageBoxOnError
! && (OnError == NULL || OnError[0] == '\0')
! && Arguments::abort_hook() == NULL) {
! os::sleep(this, (jlong)ErrorLogTimeout * 1000, false); // in seconds
fdStream err(defaultStream::output_fd());
err.print_raw_cr("# [ timer expired, abort... ]");
// skip atexit/vm_exit/vm_abort hooks
os::die();
}
! // Wake up 5 seconds later, the fatal handler may reset OnError or
! // ShowMessageBoxOnError when it is ready to abort.
! os::sleep(this, 5 * 1000, false);
}
}
if (_should_terminate) {
// check for termination before posting the next tick
--- 1287,1322 ----
int time_waited = sleep();
if (is_error_reported()) {
// A fatal error has happened, the error handler(VMError::report_and_die)
// should abort JVM after creating an error log file. However in some
! // rare cases, the error handler itself might deadlock. Here periodically
! // check for error reporting timeouts, and if it happens, just proceed to
! // abort the VM.
!
// This code is in WatcherThread because WatcherThread wakes up
// periodically so the fatal error handler doesn't need to do anything;
// also because the WatcherThread is less likely to crash than other
// threads.
for (;;) {
! // Note: we use naked sleep in this loop because we want to avoid using
! // any kind of VM infrastructure which may be broken at this point.
! if (VMError::check_timeout()) {
! // We hit error reporting timeout. Error reporting was interrupted and
! // will be wrapping things up now (closing files etc). Give it some more
! // time, then quit the VM.
! os::naked_short_sleep(200);
! // Print a message to stderr.
fdStream err(defaultStream::output_fd());
err.print_raw_cr("# [ timer expired, abort... ]");
// skip atexit/vm_exit/vm_abort hooks
os::die();
}
! // Wait a second, then recheck for timeout.
! os::naked_short_sleep(999);
}
}
if (_should_terminate) {
// check for termination before posting the next tick
< prev index next >