8155730: HeapInfoDCmd should get Heap_lock
authorysuenaga
Tue, 21 Jun 2016 09:19:53 +0200
changeset 39401 318e93828de1
parent 39400 daf3af35d6bf
child 39402 cf2142b8d40f
8155730: HeapInfoDCmd should get Heap_lock Reviewed-by: tschatzl, jprovino
hotspot/src/share/vm/memory/universe.cpp
hotspot/src/share/vm/services/diagnosticCommand.cpp
hotspot/src/share/vm/utilities/vmError.cpp
--- a/hotspot/src/share/vm/memory/universe.cpp	Mon Jun 20 22:02:20 2016 -0700
+++ b/hotspot/src/share/vm/memory/universe.cpp	Tue Jun 21 09:19:53 2016 +0200
@@ -1070,13 +1070,13 @@
 }
 
 void Universe::print_on(outputStream* st) {
+  GCMutexLocker hl(Heap_lock); // Heap_lock might be locked by caller thread.
   st->print_cr("Heap");
   heap()->print_on(st);
 }
 
 void Universe::print_heap_at_SIGBREAK() {
   if (PrintHeapAtSIGBREAK) {
-    MutexLocker hl(Heap_lock);
     print_on(tty);
     tty->cr();
     tty->flush();
--- a/hotspot/src/share/vm/services/diagnosticCommand.cpp	Mon Jun 20 22:02:20 2016 -0700
+++ b/hotspot/src/share/vm/services/diagnosticCommand.cpp	Tue Jun 21 09:19:53 2016 +0200
@@ -413,6 +413,7 @@
 }
 
 void HeapInfoDCmd::execute(DCmdSource source, TRAPS) {
+  MutexLocker hl(Heap_lock);
   Universe::heap()->print_on(output());
 }
 
--- a/hotspot/src/share/vm/utilities/vmError.cpp	Mon Jun 20 22:02:20 2016 -0700
+++ b/hotspot/src/share/vm/utilities/vmError.cpp	Tue Jun 21 09:19:53 2016 +0200
@@ -908,6 +908,7 @@
   // STEP("printing heap information")
 
   if (Universe::is_fully_initialized()) {
+    MutexLocker hl(Heap_lock);
     Universe::heap()->print_on_error(st);
     st->cr();
     st->print_cr("Polling page: " INTPTR_FORMAT, p2i(os::get_polling_page()));