hotspot/src/share/vm/runtime/thread.cpp
changeset 46284 ad578adff5df
parent 46273 898ec28d19d7
child 46329 53ccc37bda19
equal deleted inserted replaced
46283:09e328af295a 46284:ad578adff5df
  1287     int time_waited = sleep();
  1287     int time_waited = sleep();
  1288 
  1288 
  1289     if (is_error_reported()) {
  1289     if (is_error_reported()) {
  1290       // A fatal error has happened, the error handler(VMError::report_and_die)
  1290       // A fatal error has happened, the error handler(VMError::report_and_die)
  1291       // should abort JVM after creating an error log file. However in some
  1291       // should abort JVM after creating an error log file. However in some
  1292       // rare cases, the error handler itself might deadlock. Here we try to
  1292       // rare cases, the error handler itself might deadlock. Here periodically
  1293       // kill JVM if the fatal error handler fails to abort in 2 minutes.
  1293       // check for error reporting timeouts, and if it happens, just proceed to
  1294       //
  1294       // abort the VM.
       
  1295 
  1295       // This code is in WatcherThread because WatcherThread wakes up
  1296       // This code is in WatcherThread because WatcherThread wakes up
  1296       // periodically so the fatal error handler doesn't need to do anything;
  1297       // periodically so the fatal error handler doesn't need to do anything;
  1297       // also because the WatcherThread is less likely to crash than other
  1298       // also because the WatcherThread is less likely to crash than other
  1298       // threads.
  1299       // threads.
  1299 
  1300 
  1300       for (;;) {
  1301       for (;;) {
  1301         if (!ShowMessageBoxOnError
  1302         // Note: we use naked sleep in this loop because we want to avoid using
  1302             && (OnError == NULL || OnError[0] == '\0')
  1303         // any kind of VM infrastructure which may be broken at this point.
  1303             && Arguments::abort_hook() == NULL) {
  1304         if (VMError::check_timeout()) {
  1304           os::sleep(this, (jlong)ErrorLogTimeout * 1000, false); // in seconds
  1305           // We hit error reporting timeout. Error reporting was interrupted and
       
  1306           // will be wrapping things up now (closing files etc). Give it some more
       
  1307           // time, then quit the VM.
       
  1308           os::naked_short_sleep(200);
       
  1309           // Print a message to stderr.
  1305           fdStream err(defaultStream::output_fd());
  1310           fdStream err(defaultStream::output_fd());
  1306           err.print_raw_cr("# [ timer expired, abort... ]");
  1311           err.print_raw_cr("# [ timer expired, abort... ]");
  1307           // skip atexit/vm_exit/vm_abort hooks
  1312           // skip atexit/vm_exit/vm_abort hooks
  1308           os::die();
  1313           os::die();
  1309         }
  1314         }
  1310 
  1315 
  1311         // Wake up 5 seconds later, the fatal handler may reset OnError or
  1316         // Wait a second, then recheck for timeout.
  1312         // ShowMessageBoxOnError when it is ready to abort.
  1317         os::naked_short_sleep(999);
  1313         os::sleep(this, 5 * 1000, false);
       
  1314       }
  1318       }
  1315     }
  1319     }
  1316 
  1320 
  1317     if (_should_terminate) {
  1321     if (_should_terminate) {
  1318       // check for termination before posting the next tick
  1322       // check for termination before posting the next tick