JDK-8268636 : ZGC: serviceability/sa/TestJmapCoreMetaspace.java fails with "ClassCastException: class sun.jvm.hotspot.oops.TypeArray cannot be cast to class sun.jvm.hotspot.oops.Instance"
  • Type: Bug
  • Component: hotspot
  • Sub-Component: svc-agent
  • Affected Version: 17,18
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: linux
  • CPU: x86_64
  • Submitted: 2021-06-11
  • Updated: 2023-09-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Sub Tasks
JDK-8268863 :  
JDK-8269265 :  
Description
The following test failed in the JDK17 CI:

serviceability/sa/TestJmapCoreMetaspace.java

Here's a snippet from the log file:

----------System.err:(36/2638)----------
java.lang.ClassCastException: class sun.jvm.hotspot.oops.TypeArray cannot be cast to class sun.jvm.hotspot.oops.Instance (sun.jvm.hotspot.oops.TypeArray and sun.jvm.hotspot.oops.Instance are in module jdk.hotspot.agent of loader 'app')
	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:1140)
	at jdk.hotspot.agent/sun.jvm.hotspot.classfile.ClassLoaderData.classesDo(ClassLoaderData.java:114)
	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:1137)
	at jdk.hotspot.agent/sun.jvm.hotspot.utilities.HeapHprofBinWriter.write(HeapHprofBinWriter.java:460)
	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)

The test task's JVM args are:

-XX:+CreateCoredumpOnCrash -XX:+UseZGC
Comments
Yes, use a new subtask and push to 17. Thanks!
24-06-2021

> This test probably should be problem listed on all platforms. Ok, I will do that. Can I add a new subtask for it? and should we also add it to 17?
24-06-2021

This test probably should be problem listed on all platforms. Right now it is just problem listed on macosx-x64 and linux-x64.
23-06-2021

Here's a log file snippet for the jdk-18+3-71-tier3 sighting on windows: serviceability/sa/TestJmapCoreMetaspace.java The test task's JVM args are: -XX:+CreateCoredumpOnCrash -XX:+UseZGC ----------System.err:(36/2674)---------- java.lang.ClassCastException: class sun.jvm.hotspot.oops.TypeArray cannot be cast to class sun.jvm.hotspot.oops.Instance (sun.jvm.hotspot.oops.TypeArray and sun.jvm.hotspot.oops.Instance are in module jdk.hotspot.agent of loader 'app') 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:1140) at jdk.hotspot.agent/sun.jvm.hotspot.classfile.ClassLoaderData.classesDo(ClassLoaderData.java:114) 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:1137) at jdk.hotspot.agent/sun.jvm.hotspot.utilities.HeapHprofBinWriter.write(HeapHprofBinWriter.java:460) 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) java.io.EOFException at java.base/java.io.DataInputStream.readFully(DataInputStream.java:203) at java.base/java.io.DataInputStream.readFully(DataInputStream.java:172) at jdk.test.lib.hprof.parser.HprofReader.read(HprofReader.java:228) at jdk.test.lib.hprof.parser.Reader.readFile(Reader.java:95) at jdk.test.lib.hprof.HprofParser.parse(HprofParser.java:85) at jdk.test.lib.hprof.HprofParser.parse(HprofParser.java:54) at TestJmapCore.test(TestJmapCore.java:106) at TestJmapCore.main(TestJmapCore.java:70) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:312) at java.base/java.lang.Thread.run(Thread.java:833) JavaTest Message: Test threw exception: java.io.EOFException JavaTest Message: shutting down test result: Failed. Execution failed: `main' threw exception: java.io.EOFException
23-06-2021

As Chris said, TestJmapCore and TestJmapCoreMetaspace share the code, so the root cause might be the same, but I'm not sure now. I've not also reproduce this problem my Linux x64 box, so it is difficult to fix this ASAP. So I will add subtask to add this to ProblemList for Linux x64.
16-06-2021

This is the same failure as we see with JDK-8268283. However, JDK-8268283 is with TestJmapCore.java, not TestJmapCoreMetaspace.java (although they share the same test source). Also, JDK-8268283 happens about 25% of the time on linux-aarch64, but this failure on linux-x64 seems to be rare. I previously tried 100 times to reproduce JDK-8268283 on linux-x64, but was unsuccessful.
15-06-2021