diff --git a/src/hotspot/share/gc/shared/locationPrinter.inline.hpp b/src/hotspot/share/gc/shared/locationPrinter.inline.hpp index d368aa1c6c6..ae873d52cb5 100644 --- a/src/hotspot/share/gc/shared/locationPrinter.inline.hpp +++ b/src/hotspot/share/gc/shared/locationPrinter.inline.hpp @@ -37,7 +37,7 @@ oop BlockLocationPrinter::base_oop_or_null(void* addr) { return cast_to_oop(addr); } - // Try to find addr using block_start. + // Try to find addr using block_start (not implemented for all GCs/generations). HeapWord* p = CollectedHeapT::heap()->block_start(addr); if (p != nullptr && CollectedHeapT::heap()->block_is_obj(p)) { if (!is_valid_obj(p)) { @@ -52,7 +52,9 @@ oop BlockLocationPrinter::base_oop_or_null(void* addr) { template bool BlockLocationPrinter::print_location(outputStream* st, void* addr) { // Check if addr points into Java heap. - if (CollectedHeapT::heap()->is_in(addr)) { + bool in_heap = CollectedHeapT::heap()->is_in(addr); + if (in_heap) { + // base_oop_or_null() might be unimplemented and return NULL for some GCs/generations oop o = base_oop_or_null(addr); if (o != nullptr) { if ((void*)o == addr) { @@ -83,6 +85,10 @@ bool BlockLocationPrinter::print_location(outputStream* st, void } #endif + if (in_heap) { + st->print_cr(PTR_FORMAT " is an unknown heap location", p2i(addr)); + return true; + } return false; }