Although we frequently run this sun/tools/jhsdb/HeapDumpTestWithActiveProcess.java with SerialGC, due to JDK-8307408 the debuggee process (jshell) is always run with the default GC (G1). When I fix JDK-8307408 to pass the test args to the debuggee process so SerialGC will get used, I see frequent failures. For example:
sun.jvm.hotspot.types.WrongTypeException: No suitable match for type of address 0x00007f2fd6400000
at jdk.hotspot.agent/sun.jvm.hotspot.runtime.InstanceConstructor.newWrongTypeException(InstanceConstructor.java:62)
at jdk.hotspot.agent/sun.jvm.hotspot.runtime.VirtualBaseConstructor.instantiateWrapperFor(VirtualBaseConstructor.java:111)
at jdk.hotspot.agent/sun.jvm.hotspot.oops.Metadata.instantiateWrapperFor(Metadata.java:78)
at jdk.hotspot.agent/sun.jvm.hotspot.oops.Oop.getKlassForOopHandle(Oop.java:210)
at jdk.hotspot.agent/sun.jvm.hotspot.oops.ObjectHeap.newOop(ObjectHeap.java:181)
at jdk.hotspot.agent/sun.jvm.hotspot.oops.VMOopHandle.resolve(VMOopHandle.java:61)
at jdk.hotspot.agent/sun.jvm.hotspot.oops.Klass.getJavaMirror(Klass.java:114)
at jdk.hotspot.agent/sun.jvm.hotspot.utilities.HeapHprofBinWriter$5.visit(HeapHprofBinWriter.java:1242)
at jdk.hotspot.agent/sun.jvm.hotspot.classfile.ClassLoaderData.classesDo(ClassLoaderData.java:107)
at jdk.hotspot.agent/sun.jvm.hotspot.classfile.ClassLoaderDataGraph.classesDo(ClassLoaderDataGraph.java:84)
at jdk.hotspot.agent/sun.jvm.hotspot.utilities.HeapHprofBinWriter.writeClasses(HeapHprofBinWriter.java:1239)
at jdk.hotspot.agent/sun.jvm.hotspot.utilities.HeapHprofBinWriter.write(HeapHprofBinWriter.java:457)
at jdk.hotspot.agent/sun.jvm.hotspot.tools.JMap.writeHeapHprofBin(JMap.java:216)
at jdk.hotspot.agent/sun.jvm.hotspot.tools.JMap.run(JMap.java:103)
at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.startInternal(Tool.java:278)
at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.start(Tool.java:241)
at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.execute(Tool.java:134)
at jdk.hotspot.agent/sun.jvm.hotspot.tools.JMap.main(JMap.java:202)
at jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.runJMAP(SALauncher.java:340)
at jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.main(SALauncher.java:500)
There are some other exceptions that can also be thrown, such as UnalignedAddressException. In all case the stack is the same up to ClassLoaderData.classesDo(), and maybe even a few frames above it.
It's not surprising that we see an issue once in a while since the debuggee process is active and might be in the middle of a GC. What is surprising perhaps is that don't sometimes see this with G1. I can only assume there are differences in how ClassLoaderData is handled between G1 and SerialGC.
This to me seems to be a test bug since JMap always is at risk of failing when used on an active process. The test should probably defend against it.
Since we can't problem list tests for just SerialGC, and I don't want to disable this test for G1, I'll just modify the test so it will use G1 in place of SerialGC.