8055338: (process) Add instrumentation to help diagnose JDK-6573254
authorigerasim
Thu, 21 Aug 2014 16:32:36 -0700
changeset 26295 6a9d9192f215
parent 26294 ff1a31478531
child 26296 fd6180a0e0ab
8055338: (process) Add instrumentation to help diagnose JDK-6573254 Reviewed-by: dcubed, ohair, iklam, dholmes, sspitsyn, sla
hotspot/src/os/windows/vm/os_windows.cpp
hotspot/src/share/vm/runtime/java.cpp
--- a/hotspot/src/os/windows/vm/os_windows.cpp	Thu Aug 21 01:43:27 2014 +0000
+++ b/hotspot/src/os/windows/vm/os_windows.cpp	Thu Aug 21 16:32:36 2014 -0700
@@ -409,6 +409,8 @@
 
 LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo);
 
+extern jint volatile vm_getting_terminated;
+
 // Thread start routine for all new Java threads
 static unsigned __stdcall java_start(Thread* thread) {
   // Try to randomize the cache line index of hot stack frames.
@@ -430,9 +432,17 @@
     }
   }
 
+  // Diagnostic code to investigate JDK-6573254 (Part I)
+  unsigned res = 90115;  // non-java thread
+  if (thread->is_Java_thread()) {
+    JavaThread* java_thread = (JavaThread*)thread;
+    res = java_lang_Thread::is_daemon(java_thread->threadObj())
+          ? 70115        // java daemon thread
+          : 80115;       // java non-daemon thread
+  }
 
   // Install a win32 structured exception handler around every thread created
-  // by VM, so VM can genrate error dump when an exception occurred in non-
+  // by VM, so VM can generate error dump when an exception occurred in non-
   // Java thread (e.g. VM thread).
   __try {
      thread->run();
@@ -448,6 +458,11 @@
     Atomic::dec_ptr((intptr_t*)&os::win32::_os_thread_count);
   }
 
+  // Diagnostic code to investigate JDK-6573254 (Part II)
+  if (OrderAccess::load_acquire(&vm_getting_terminated)) {
+    return res;
+  }
+
   return 0;
 }
 
--- a/hotspot/src/share/vm/runtime/java.cpp	Thu Aug 21 01:43:27 2014 +0000
+++ b/hotspot/src/share/vm/runtime/java.cpp	Thu Aug 21 16:32:36 2014 -0700
@@ -430,6 +430,8 @@
   }
 }
 
+jint volatile vm_getting_terminated = 0;
+
 // Note: before_exit() can be executed only once, if more than one threads
 //       are trying to shutdown the VM at the same time, only one thread
 //       can run before_exit() and all other threads must wait.
@@ -460,6 +462,8 @@
     }
   }
 
+  OrderAccess::release_store(&vm_getting_terminated, 1);
+
   // The only difference between this and Win32's _onexit procs is that
   // this version is invoked before any threads get killed.
   ExitProc* current = exit_procs;