-
Bug
-
Resolution: Fixed
-
P4
-
17, 21, 22
-
b08
During investigation of a customer core file with graphic SA, it printed in stack memory:
````
Error while performing oopsDo for frame sp: 0x00007f2c602378f0, unextendedSP: 0x00007f2c602378f0, fp: 0x00007f2c60237938, pc: 0x00007f2c47e2b88a
java.lang.NullPointerException: Cannot invoke "sun.jvm.hotspot.gc.g1.HeapRegion.isFree()" because "region" is null
at jdk.hotspot.agent/sun.jvm.hotspot.HSDB$34$1.addAnnotation(HSDB.java:1099)
at jdk.hotspot.agent/sun.jvm.hotspot.HSDB$34$1.visitAddress(HSDB.java:1059)
at jdk.hotspot.agent/sun.jvm.hotspot.runtime.InterpreterFrameClosure.offsetDo(Frame.java:675)
at jdk.hotspot.agent/sun.jvm.hotspot.interpreter.OopMapCacheEntry.iterateOop(OopMapCacheEntry.java:38)
at jdk.hotspot.agent/sun.jvm.hotspot.runtime.Frame.oopsInterpretedDo(Frame.java:591)
at jdk.hotspot.agent/sun.jvm.hotspot.runtime.Frame.oopsDo(Frame.java:442)
at jdk.hotspot.agent/sun.jvm.hotspot.HSDB$34.run(HSDB.java:1052)
at jdk.hotspot.agent/sun.jvm.hotspot.utilities.WorkerThread$MainLoop.run(WorkerThread.java:70)
at java.base/java.lang.Thread.run(Thread.java:1570
````
The reproducer is attached.
1. Compile and launch it with G1 enabled.
2. Attach HSDB
3. Select "main" thread
4. Click "Stack Memory" icon on "Java Threads" toolbar.
The fix is trivial (will create PR soon):
diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HSDB.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HSDB.java
index 9cc51934d08..e59c3da379e 100644
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HSDB.java
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HSDB.java
@@ -1096,7 +1096,9 @@ public class HSDB implements ObjectHistogramPanel.Listener, SAListener {
G1CollectedHeap heap = (G1CollectedHeap)collHeap;
HeapRegion region = heap.hrm().getByAddress(handle);
- if (region.isFree()) {
+ if (region == null) {
+ anno = "NOTG1REGION";
+ } else if (region.isFree()) {
anno = "Free ";
bad = false;
} else if (region.isYoung()) {
````
Error while performing oopsDo for frame sp: 0x00007f2c602378f0, unextendedSP: 0x00007f2c602378f0, fp: 0x00007f2c60237938, pc: 0x00007f2c47e2b88a
java.lang.NullPointerException: Cannot invoke "sun.jvm.hotspot.gc.g1.HeapRegion.isFree()" because "region" is null
at jdk.hotspot.agent/sun.jvm.hotspot.HSDB$34$1.addAnnotation(HSDB.java:1099)
at jdk.hotspot.agent/sun.jvm.hotspot.HSDB$34$1.visitAddress(HSDB.java:1059)
at jdk.hotspot.agent/sun.jvm.hotspot.runtime.InterpreterFrameClosure.offsetDo(Frame.java:675)
at jdk.hotspot.agent/sun.jvm.hotspot.interpreter.OopMapCacheEntry.iterateOop(OopMapCacheEntry.java:38)
at jdk.hotspot.agent/sun.jvm.hotspot.runtime.Frame.oopsInterpretedDo(Frame.java:591)
at jdk.hotspot.agent/sun.jvm.hotspot.runtime.Frame.oopsDo(Frame.java:442)
at jdk.hotspot.agent/sun.jvm.hotspot.HSDB$34.run(HSDB.java:1052)
at jdk.hotspot.agent/sun.jvm.hotspot.utilities.WorkerThread$MainLoop.run(WorkerThread.java:70)
at java.base/java.lang.Thread.run(Thread.java:1570
````
The reproducer is attached.
1. Compile and launch it with G1 enabled.
2. Attach HSDB
3. Select "main" thread
4. Click "Stack Memory" icon on "Java Threads" toolbar.
The fix is trivial (will create PR soon):
diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HSDB.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HSDB.java
index 9cc51934d08..e59c3da379e 100644
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HSDB.java
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HSDB.java
@@ -1096,7 +1096,9 @@ public class HSDB implements ObjectHistogramPanel.Listener, SAListener {
G1CollectedHeap heap = (G1CollectedHeap)collHeap;
HeapRegion region = heap.hrm().getByAddress(handle);
- if (region.isFree()) {
+ if (region == null) {
+ anno = "NOTG1REGION";
+ } else if (region.isFree()) {
anno = "Free ";
bad = false;
} else if (region.isYoung()) {