Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is jstack is unable to get the threadump of a Java process process?

Tags:

java

java-8

I am cluless about JSTACK is being unable to get thread dump of a process. It is retuning errors "java.lang.RuntimeException: Unable to deduce type of thread from address... "

I tried below commands:

$ sudo bin/jstack   42846
$ sudo bin/jstack -F 42846

Any clue will really help me. Below are the errors I am encountering:

 Attaching to process ID 42846, please wait...
    Debugger attached successfully.
    Server compiler detected.
    JVM version is 25.131-b11
    Deadlock Detection:

    java.lang.RuntimeException: Unable to deduce type of thread from address 0x00007fb1f430f000 (expected type JavaThread, CompilerThread, ServiceThread, JvmtiAgentThread, or SurrogateLockerThread)
        at sun.jvm.hotspot.runtime.Threads.createJavaThreadWrapper(Threads.java:166)
        at sun.jvm.hotspot.runtime.Threads.first(Threads.java:150)
        at sun.jvm.hotspot.runtime.DeadlockDetector.createThreadTable(DeadlockDetector.java:149)
        at sun.jvm.hotspot.runtime.DeadlockDetector.print(DeadlockDetector.java:56)
        at sun.jvm.hotspot.runtime.DeadlockDetector.print(DeadlockDetector.java:39)
        at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:62)
        at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:45)
        at sun.jvm.hotspot.tools.JStack.run(JStack.java:66)
        at sun.jvm.hotspot.tools.Tool.startInternal(Tool.java:260)
        at sun.jvm.hotspot.tools.Tool.start(Tool.java:223)
        at sun.jvm.hotspot.tools.Tool.execute(Tool.java:118)
        at sun.jvm.hotspot.tools.JStack.main(JStack.java:92)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at sun.tools.jstack.JStack.runJStackTool(JStack.java:140)
        at sun.tools.jstack.JStack.main(JStack.java:106)
    Caused by: sun.jvm.hotspot.types.WrongTypeException: No suitable match for type of address 0x00007fb1f430f000
        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
    Can't print deadlocks:Unable to deduce type of thread from address 0x00007fb1f430f000 (expected type JavaThread, CompilerThread, ServiceThread, JvmtiAgentThread, or SurrogateLockerThread)
    Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at sun.tools.jstack.JStack.runJStackTool(JStack.java:140)
        at sun.tools.jstack.JStack.main(JStack.java:106)
    Caused by: java.lang.RuntimeException: Unable to deduce type of thread from address 0x00007fb1f430f000 (expected type JavaThread, CompilerThread, ServiceThread, JvmtiAgentThread, or SurrogateLockerThread)
        at sun.jvm.hotspot.runtime.Threads.createJavaThreadWrapper(Threads.java:166)
        at sun.jvm.hotspot.runtime.Threads.first(Threads.java:150)
        at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:75)
        at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:45)
        at sun.jvm.hotspot.tools.JStack.run(JStack.java:66)
        at sun.jvm.hotspot.tools.Tool.startInternal(Tool.java:260)
        at sun.jvm.hotspot.tools.Tool.start(Tool.java:223)
        at sun.jvm.hotspot.tools.Tool.execute(Tool.java:118)
        at sun.jvm.hotspot.tools.JStack.main(JStack.java:92)
        ... 6 more
    Caused by: sun.jvm.hotspot.types.WrongTypeException: No suitable match for type of address 0x00007fb1f430f000
        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)
like image 946
Nipun Talukdar Avatar asked May 21 '18 08:05

Nipun Talukdar


2 Answers

Actually, it worked when I run the jstack command as the owner of the process. I was running jstack as root user and the process I was trying to take thread dump was a Cassandra DB process. Owner of the process was "cassandra" user and when I run the "jstack" command from "cassandra" user, everything worked.

But the jstack error output should have been able to indicate that issue, unfortunately it spews out something different.

like image 160
Nipun Talukdar Avatar answered Nov 15 '22 20:11

Nipun Talukdar


Another option might be missing debuginfo on CentOS, I've solved it by

#debuginfo-install java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64
like image 34
Stepan Yakovenko Avatar answered Nov 15 '22 21:11

Stepan Yakovenko