src/hotspot/share/runtime/safepoint.cpp
changeset 54031 feea57b38a1c
parent 54009 13acb4339895
child 54323 846bc643f4ef
--- a/src/hotspot/share/runtime/safepoint.cpp	Thu Mar 07 16:15:43 2019 +0100
+++ b/src/hotspot/share/runtime/safepoint.cpp	Fri Mar 08 11:23:30 2019 +0100
@@ -902,6 +902,16 @@
   // To debug the long safepoint, specify both AbortVMOnSafepointTimeout &
   // ShowMessageBoxOnError.
   if (AbortVMOnSafepointTimeout) {
+    // Send the blocking thread a signal to terminate and write an error file.
+    for (JavaThreadIteratorWithHandle jtiwh; JavaThread *cur_thread = jtiwh.next(); ) {
+      if (cur_thread->safepoint_state()->is_running()) {
+        if (!os::signal_thread(cur_thread, SIGILL, "blocking a safepoint")) {
+          break; // Could not send signal. Report fatal error.
+        }
+        // Give cur_thread a chance to report the error and terminate the VM.
+        os::sleep(Thread::current(), 3000, false);
+      }
+    }
     fatal("Safepoint sync time longer than " INTX_FORMAT "ms detected when executing %s.",
           SafepointTimeoutDelay, VMThread::vm_operation()->name());
   }