Steps to reproduce:
// Setup a heap size that doesn't fit in 4GB to ensure shifted compressed oops are used:
$ java -Xlog:gc -XX:+UseG1GC -Xmx30G -Xms256m HelloSleep
// Connect with the SA aggent
$ jhsdb hsdb
// Attach to the pid from the HelloSleep process
// Look for the exceptions similar to this:
Exception in thread "AWT-EventQueue-0" sun.jvm.hotspot.oops.UnknownOopException
at jdk.hotspot.agent/sun.jvm.hotspot.oops.ObjectHeap.newOop(ObjectHeap.java:264)
at jdk.hotspot.agent/sun.jvm.hotspot.oops.OopField.getValue(OopField.java:49)
at jdk.hotspot.agent/sun.jvm.hotspot.oops.OopUtilities.threadOopGetName(OopUtilities.java:263)
at jdk.hotspot.agent/sun.jvm.hotspot.runtime.JavaThread.getThreadName(JavaThread.java:372)
--- HelloSleep.java ---
public class HelloSleep {
public static void main(String... args) throws Exception {
Thread.sleep(100000000000000L);
}
}
---
--- Potential fix ---
http://hg.openjdk.java.net/zgc/zgc/raw-rev/fb9665b5737c
diff -r 66ba26710c09 -r fb9665b5737c src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shared/CollectedHeap.java
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shared/CollectedHeap.java Mon Apr 16 15:44:08 2018 +0200
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shared/CollectedHeap.java Mon Apr 16 15:44:08 2018 +0200
@@ -75,6 +75,12 @@
public abstract CollectedHeapName kind();
+ public OopHandle oop_load_at(OopHandle handle, long offset) {
+ return VM.getVM().isCompressedOopsEnabled()
+ ? handle.getCompOopHandleAt(offset)
+ : handle.getOopHandleAt(offset);
+ }
+
public void print() { printOn(System.out); }
public void printOn(PrintStream tty) {
MemRegion mr = reservedRegion();
diff -r 66ba26710c09 -r fb9665b5737c src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/OopField.java
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/OopField.java Mon Apr 16 15:44:08 2018 +0200
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/OopField.java Mon Apr 16 15:44:08 2018 +0200
@@ -54,7 +54,8 @@
if (!isVMField() && !obj.isInstance() && !obj.isArray()) {
throw new InternalError(obj.toString());
}
- return obj.getHandle().getOopHandleAt(getOffset());
+
+ return VM.getVM().getUniverse().heap().oop_load_at(obj.getHandle(), getOffset());
}
public Oop getValue(VMObject obj) {
---
// Setup a heap size that doesn't fit in 4GB to ensure shifted compressed oops are used:
$ java -Xlog:gc -XX:+UseG1GC -Xmx30G -Xms256m HelloSleep
// Connect with the SA aggent
$ jhsdb hsdb
// Attach to the pid from the HelloSleep process
// Look for the exceptions similar to this:
Exception in thread "AWT-EventQueue-0" sun.jvm.hotspot.oops.UnknownOopException
at jdk.hotspot.agent/sun.jvm.hotspot.oops.ObjectHeap.newOop(ObjectHeap.java:264)
at jdk.hotspot.agent/sun.jvm.hotspot.oops.OopField.getValue(OopField.java:49)
at jdk.hotspot.agent/sun.jvm.hotspot.oops.OopUtilities.threadOopGetName(OopUtilities.java:263)
at jdk.hotspot.agent/sun.jvm.hotspot.runtime.JavaThread.getThreadName(JavaThread.java:372)
--- HelloSleep.java ---
public class HelloSleep {
public static void main(String... args) throws Exception {
Thread.sleep(100000000000000L);
}
}
---
--- Potential fix ---
http://hg.openjdk.java.net/zgc/zgc/raw-rev/fb9665b5737c
diff -r 66ba26710c09 -r fb9665b5737c src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shared/CollectedHeap.java
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shared/CollectedHeap.java Mon Apr 16 15:44:08 2018 +0200
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shared/CollectedHeap.java Mon Apr 16 15:44:08 2018 +0200
@@ -75,6 +75,12 @@
public abstract CollectedHeapName kind();
+ public OopHandle oop_load_at(OopHandle handle, long offset) {
+ return VM.getVM().isCompressedOopsEnabled()
+ ? handle.getCompOopHandleAt(offset)
+ : handle.getOopHandleAt(offset);
+ }
+
public void print() { printOn(System.out); }
public void printOn(PrintStream tty) {
MemRegion mr = reservedRegion();
diff -r 66ba26710c09 -r fb9665b5737c src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/OopField.java
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/OopField.java Mon Apr 16 15:44:08 2018 +0200
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/OopField.java Mon Apr 16 15:44:08 2018 +0200
@@ -54,7 +54,8 @@
if (!isVMField() && !obj.isInstance() && !obj.isArray()) {
throw new InternalError(obj.toString());
}
- return obj.getHandle().getOopHandleAt(getOffset());
+
+ return VM.getVM().getUniverse().heap().oop_load_at(obj.getHandle(), getOffset());
}
public Oop getValue(VMObject obj) {
---