--- old/src/share/vm/gc/g1/g1CollectedHeap.cpp 2016-05-09 21:13:14.123390177 +0900 +++ new/src/share/vm/gc/g1/g1CollectedHeap.cpp 2016-05-09 21:13:13.919890873 +0900 @@ -2641,6 +2641,8 @@ } void G1CollectedHeap::print_on(outputStream* st) const { + assert_locked_or_safepoint(Heap_lock); + st->print(" %-20s", "garbage-first heap"); st->print(" total " SIZE_FORMAT "K, used " SIZE_FORMAT "K", capacity()/K, used_unlocked()/K); --- old/src/share/vm/gc/parallel/parallelScavengeHeap.cpp 2016-05-09 21:13:15.249052993 +0900 +++ new/src/share/vm/gc/parallel/parallelScavengeHeap.cpp 2016-05-09 21:13:15.040053708 +0900 @@ -551,6 +551,8 @@ } void ParallelScavengeHeap::print_on(outputStream* st) const { + assert_locked_or_safepoint(Heap_lock); + young_gen()->print_on(st); old_gen()->print_on(st); MetaspaceAux::print_on(st); --- old/src/share/vm/gc/shared/genCollectedHeap.cpp 2016-05-09 21:13:15.934717315 +0900 +++ new/src/share/vm/gc/shared/genCollectedHeap.cpp 2016-05-09 21:13:15.793551131 +0900 @@ -1089,6 +1089,8 @@ } void GenCollectedHeap::print_on(outputStream* st) const { + assert_locked_or_safepoint(Heap_lock); + _young_gen->print_on(st); _old_gen->print_on(st); MetaspaceAux::print_on(st); --- old/src/share/vm/memory/universe.cpp 2016-05-09 21:13:16.601131702 +0900 +++ new/src/share/vm/memory/universe.cpp 2016-05-09 21:13:16.443465575 +0900 @@ -1071,13 +1071,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(); --- old/src/share/vm/services/diagnosticCommand.cpp 2016-05-09 21:13:17.760153788 +0900 +++ new/src/share/vm/services/diagnosticCommand.cpp 2016-05-09 21:13:17.143796513 +0900 @@ -413,6 +413,7 @@ } void HeapInfoDCmd::execute(DCmdSource source, TRAPS) { + MutexLocker hl(Heap_lock); Universe::heap()->print_on(output()); } --- old/src/share/vm/utilities/vmError.cpp 2016-05-09 21:13:18.470568025 +0900 +++ new/src/share/vm/utilities/vmError.cpp 2016-05-09 21:13:18.287235318 +0900 @@ -731,6 +731,7 @@ STEP("printing heap information") if (_verbose && Universe::is_fully_initialized()) { + MutexLockerEx hl(Heap_lock, true); // No safepoint check Universe::heap()->print_on_error(st); st->cr(); st->print_cr("Polling page: " INTPTR_FORMAT, p2i(os::get_polling_page())); @@ -907,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()));