8033405: metaspace/stressHierarchy/stressHierarchy005 hangs in atexit handler
authorctornqvi
Thu, 24 Apr 2014 00:46:17 +0200
changeset 24236 02c0f8873a3c
parent 24087 51f0152bc545
child 24237 7b210ef8c830
8033405: metaspace/stressHierarchy/stressHierarchy005 hangs in atexit handler Summary: <ake sure we shut down NMT before the VM exits and do not track malloc/free when NMT is shutting down Reviewed-by: coleenp, zgu
hotspot/src/os/windows/vm/os_windows.cpp
hotspot/src/share/vm/services/memTracker.cpp
--- a/hotspot/src/os/windows/vm/os_windows.cpp	Fri Apr 18 10:55:41 2014 -0700
+++ b/hotspot/src/os/windows/vm/os_windows.cpp	Thu Apr 24 00:46:17 2014 +0200
@@ -130,6 +130,13 @@
     case DLL_PROCESS_DETACH:
       if(ForceTimeHighResolution)
         timeEndPeriod(1L);
+
+      // Workaround for issue when a custom launcher doesn't call
+      // DestroyJavaVM and NMT is trying to track memory when free is
+      // called from a static destructor
+      if (MemTracker::is_on()) {
+          MemTracker::shutdown(MemTracker::NMT_normal);
+      }
       break;
     default:
       break;
--- a/hotspot/src/share/vm/services/memTracker.cpp	Fri Apr 18 10:55:41 2014 -0700
+++ b/hotspot/src/share/vm/services/memTracker.cpp	Thu Apr 24 00:46:17 2014 +0200
@@ -785,7 +785,7 @@
   MEMFLAGS flags, address pc) {
   assert(old_addr != NULL && new_addr != NULL, "Sanity check");
   assert(_op == Realloc || _op == NoOp, "Wrong call");
-  if (MemTracker::is_on() && NMT_CAN_TRACK(flags) && _op != NoOp) {
+  if (MemTracker::is_on() && NMT_CAN_TRACK(flags) && _op != NoOp && !MemTracker::shutdown_in_progress()) {
     assert(_seq > 0, "Need pre-reserve sequence number");
     if (_need_thread_critical_lock) {
       ThreadCritical tc;
@@ -811,7 +811,7 @@
   // OOM already?
   if (addr == NULL) return;
 
-  if (MemTracker::is_on() && NMT_CAN_TRACK(flags) && _op != NoOp) {
+  if (MemTracker::is_on() && NMT_CAN_TRACK(flags) && _op != NoOp && !MemTracker::shutdown_in_progress()) {
     bool pre_reserved_seq = (_seq != 0);
     address  pc = CALLER_CALLER_PC;
     MEMFLAGS orig_flags = flags;