7110428: Crash during HeapDump operation
authorpoonam
Wed, 16 Nov 2011 16:27:29 -0800
changeset 11000 e7c4440c05e2
parent 10999 83a6068d99c5
child 11001 4ba0436b3b29
7110428: Crash during HeapDump operation Reviewed-by: ysr, dholmes
hotspot/src/share/vm/services/heapDumper.cpp
--- a/hotspot/src/share/vm/services/heapDumper.cpp	Tue Nov 15 20:17:33 2011 +0100
+++ b/hotspot/src/share/vm/services/heapDumper.cpp	Wed Nov 16 16:27:29 2011 -0800
@@ -27,6 +27,7 @@
 #include "classfile/systemDictionary.hpp"
 #include "classfile/vmSymbols.hpp"
 #include "gc_implementation/shared/vmGCOperations.hpp"
+#include "memory/gcLocker.inline.hpp"
 #include "memory/genCollectedHeap.hpp"
 #include "memory/universe.hpp"
 #include "oops/objArrayKlass.hpp"
@@ -1709,11 +1710,16 @@
 
   HandleMark hm;
   CollectedHeap* ch = Universe::heap();
+
+  ch->ensure_parsability(false); // must happen, even if collection does
+                                 // not happen (e.g. due to GC_locker)
+
   if (_gc_before_heap_dump) {
-    ch->collect_as_vm_thread(GCCause::_heap_dump);
-  } else {
-    // make the heap parsable (no need to retire TLABs)
-    ch->ensure_parsability(false);
+    if (GC_locker::is_active()) {
+      warning("GC locker is held; pre-heapdump GC was skipped");
+    } else {
+      ch->collect_as_vm_thread(GCCause::_heap_dump);
+    }
   }
 
   // At this point we should be the only dumper active, so