"InternalError: Metadata does not appear to be polymorphic" When Running jmap, jstack, or jinfo
Environment
- Oracle JDK
- 1.8
- OpenJDK
- 1.8
- jinfo -sysprops
- jmap
- jstack -F -l
Issue
-
We see the following error:
# /usr/lib/jvm/java-1.8.0/bin/jmap -F -dump:format=b,file=dump.hprof 6503 Attaching to process ID 6503, please wait... Debugger attached successfully. Server compiler detected. JVM version is 25.65-b01 Dumping heap to java_pid6503_va1rprdljap7496.hprof ... Exception in thread "main" java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ... at java.lang.reflect.Method.invoke(Method.java:497) at sun.tools.jmap.JMap.runTool(JMap.java:201) at sun.tools.jmap.JMap.main(JMap.java:130) Caused by: java.lang.InternalError: Metadata does not appear to be polymorphic at sun.jvm.hotspot.types.basic.BasicTypeDataBase.findDynamicTypeForAddress(BasicTypeDataBase.java:278) at sun.jvm.hotspot.runtime.VirtualBaseConstructor.instantiateWrapperFor(VirtualBaseConstructor.java:102) at sun.jvm.hotspot.oops.Metadata.instantiateWrapperFor(Metadata.java:68) ... at sun.jvm.hotspot.tools.HeapDumper.main(HeapDumper.java:83) ... 6 more -
Results in the following exception:
java.lang.RuntimeException: Unable to deduce type of thread from address 0x00007fac6c4f3000 (expected type JavaThread, CompilerThread, ServiceThread, JvmtiAgentThread, or SurrogateLockerThread) at sun.jvm.hotspot.runtime.Threads.createJavaThreadWrapper(Threads.java:166) ... at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:45) ... at sun.jvm.hotspot.tools.JStack.main(JStack.java:92) ... at sun.tools.jstack.JStack.main(JStack.java:106) Caused by: sun.jvm.hotspot.types.WrongTypeException: No suitable match for type of address 0x00007fac6c4f3000 at sun.jvm.hotspot.runtime.InstanceConstructor.newWrongTypeException(InstanceConstructor.java:62) at sun.jvm.hotspot.runtime.VirtualConstructor.instantiateWrapperFor(VirtualConstructor.java:80) at sun.jvm.hotspot.runtime.Threads.createJavaThreadWrapper(Threads.java:162) ... 17 more Exception in thread "main" java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ... at sun.tools.jstack.JStack.main(JStack.java:106) Caused by: java.lang.InternalError: Metadata does not appear to be polymorphic at sun.jvm.hotspot.types.basic.BasicTypeDataBase.findDynamicTypeForAddress(BasicTypeDataBase.java:278) at sun.jvm.hotspot.runtime.VirtualBaseConstructor.instantiateWrapperFor(VirtualBaseConstructor.java:102) at sun.jvm.hotspot.oops.Metadata.instantiateWrapperFor(Metadata.java:68) ... at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:45) ... at sun.jvm.hotspot.tools.JStack.main(JStack.java:92) ... 6 more
Resolution
Java Diagnostics tool, jcmd, is the official and supported tool for debugging. See solution JCMD usage in OpenJDK for troubleshooting.
-
Make sure that you are running
jinfo,jmaporjstackas the user that started the java process. -
jmap -heapandjstack -FThis content is not included.require debuginfo.Use
debuginfo-installto Install the OpenJDK -debuginfo package and its dependencies:$ sudo debuginfo-install java-1.8.0-openjdkNOTE: Using
yumto install the debuginfo package (e.g.yum install java-1.8.0-openjdk-debuginfo) will not work, as it will not install the required dependencies. -
Try an alternative way to get a heap dump or thread dump on Linux or Microsoft Windows.
Root Cause
Requiring the debuginfo package be installed is only relevant for very old JDK versions:
This content is not included.jmap and jstack are not working with openjdk
In recent Red Hat builds of OpenJDK, we set _find_debuginfo_opts -g so the stripping routines preserve some minimal debuginfo that should be enough for jinfo/jmap/jstack to work.
Diagnostic Steps
- Check that you used the correct process id and that it's owned by the same user as is running the command. You can check the processes owner as follows:
$ ps aux
- Check if the java executable is stripped or not:
$ file /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64/jre/bin/java
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64/jre/bin/java: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=df3fba6cc0f63b51a2270014a3994480680a8ca0, stripped
If it is stripped, the debuginfo package must be installed.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.