RFR: Verifier should dump raw memory around the problematic oops
Aleksey Shipilev
shade at redhat.com
Wed May 16 16:53:16 UTC 2018
When Verifier fails with broken oop, it is useful to see where the memory actually points. This
helps to catch off-by-one errors, see for example off-by-one error that points to fwdptr slot, not
to object header:
---------- 8< -----------------------------------------------------------------------------
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error
(/home/shade/trunks/shenandoah-jdk/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp:62),
pid=41615, tid=41622
# Error: Before Updating References, Marked; Object klass pointer must go to metaspace
Referenced from:
no interior location recorded (probably a plain heap scan, or detached oop)
Object:
0x00000000fb8813c0 - safe print, no details
region: | 1905|R |BTE fb880000, fb8ffea0, fb900000|TAMS fb880000, fb880000|U
99%|T 0%|G 89%|S 10%|L 99%| |CP 0|SN 0, 0, 9634, 96f6
Raw heap memory:
0x00000000fb881390: 00000000 00000000 00000000 00000000
0x00000000fb8813a0: 00000000 00000000 00000000 00000000
0x00000000fb8813c0: 00000000 00000000 fb8813d0 00000000
0x00000000fb8813d0: 00000005 00000000 20002645 00000c44
0x00000000fb8813e0: baadbabe baadbabe fb8813f0 00000000
0x00000000fb8813f0: 00000005 00000000 20002645 00000c45
0x00000000fb881400: baadbabe baadbabe fb881410 00000000
0x00000000fb881410: 00000005 00000000 20002645 00000c46
0x00000000fb881420: baadbabe baadbabe fb881430 00000000
0x00000000fb881430: 00000005 00000000 20002645 00000c47
---------- 8< -----------------------------------------------------------------------------
Thanks,
-Aleksey
[0]
diff -r d136c3d3b5c7 src/hotspot/share/gc/shenandoah/shenandoahAsserts.cpp
--- a/src/hotspot/share/gc/shenandoah/shenandoahAsserts.cpp Wed May 16 08:44:23 2018 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahAsserts.cpp Wed May 16 18:47:58 2018 +0200
@@ -32,6 +32,27 @@
#include "gc/shenandoah/shenandoahTraversalGC.hpp"
#include "memory/resourceArea.hpp"
+void print_raw_memory(ShenandoahMessageBuffer &msg, void* loc) {
+ // Be extra safe. Only access data that is guaranteed to be safe:
+ // should be in heap, in known committed region, within that region.
+
+ ShenandoahHeap* heap = ShenandoahHeap::heap();
+ if (!heap->is_in(loc)) return;
+
+ ShenandoahHeapRegion* r = heap->heap_region_containing(loc);
+ if (r != NULL && r->is_committed()) {
+
+ address start = MAX2((address) r->bottom(), (address) loc - 32);
+ address end = MIN2((address) r->end(), (address) loc + 128);
+ if (start >= end) return;
+
+ stringStream ss;
+ os::print_hex_dump(&ss, start, end, 4);
+ msg.append("\n");
+ msg.append("Raw heap memory:\n%s", ss.as_string());
+ }
+}
+
void ShenandoahAsserts::print_obj(ShenandoahMessageBuffer& msg, oop obj) {
ShenandoahHeap* heap = ShenandoahHeap::heap();
ShenandoahHeapRegion *r = heap->heap_region_containing(obj);
@@ -80,6 +101,7 @@
stringStream ss;
r->print_on(&ss);
msg.append(" region: %s", ss.as_string());
+ print_raw_memory(msg, loc);
}
}
}
More information about the shenandoah-dev
mailing list