8220682: Heap dumping and inspection fails with JDK-8214712
Reviewed-by: jcbeyler, jiangli, sspitsyn
--- a/src/hotspot/share/memory/heapInspection.cpp Tue Mar 26 09:16:07 2019 +0100
+++ b/src/hotspot/share/memory/heapInspection.cpp Tue Mar 26 10:23:11 2019 +0100
@@ -121,6 +121,11 @@
}
KlassInfoEntry* KlassInfoBucket::lookup(Klass* const k) {
+ // Can happen if k is an archived class that we haven't loaded yet.
+ if (k->java_mirror() == NULL) {
+ return NULL;
+ }
+
KlassInfoEntry* elt = _list;
while (elt != NULL) {
if (elt->is_equal(k)) {
@@ -202,7 +207,8 @@
assert(_buckets != NULL, "Allocation failure should have been caught");
KlassInfoEntry* e = _buckets[idx].lookup(k);
// Lookup may fail if this is a new klass for which we
- // could not allocate space for an new entry.
+ // could not allocate space for an new entry, or if it's
+ // an archived class that we haven't loaded yet.
assert(e == NULL || k == e->klass(), "must be equal");
return e;
}
--- a/src/hotspot/share/services/heapDumper.cpp Tue Mar 26 09:16:07 2019 +0100
+++ b/src/hotspot/share/services/heapDumper.cpp Tue Mar 26 10:23:11 2019 +0100
@@ -958,6 +958,11 @@
// creates HPROF_GC_INSTANCE_DUMP record for the given object
void DumperSupport::dump_instance(DumpWriter* writer, oop o) {
Klass* k = o->klass();
+ if (k->java_mirror() == NULL) {
+ // Ignoring this object since the corresponding java mirror is not loaded.
+ // Might be a dormant archive object.
+ return;
+ }
writer->write_u1(HPROF_GC_INSTANCE_DUMP);
writer->write_objectID(o);