java - 为什么jstack无法获取Java进程进程的threadump?

标签 java java-8

我对 JSTACK 无法获取进程的线程转储一无所知。它正在重新调整错误“java.lang.RuntimeException:无法从地址推断线程类型...”

我尝试了以下命令:

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

任何线索都会真正帮助我。以下是我遇到的错误:

 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)

最佳答案

实际上,当我以进程所有者的身份运行 jstack 命令时它起作用了。我以 root 用户身份运行 jstack,我尝试进行线程转储的进程是一个 Cassandra DB 进程。该进程的所有者是“cassandra”用户,当我从“cassandra”用户运行“jstack”命令时,一切正常。

但是 jstack 错误输出应该能够指示该问题,不幸的是它喷出了不同的东西。

关于java - 为什么jstack无法获取Java进程进程的threadump?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50444493/

相关文章:

java - 从批处理文件运行后 Swing UI 终止

Java - 如何读取 7z 的输出?

java - 使用注释来提供 Google guice MapBinder

json - 使用 Jackson 序列化和反序列化 Lambda

java - 如何在 Java 中模拟可在运行时扩展的枚举?

java - 如何按输入顺序保存和检索共享首选项中的数据?

java - 使用 Java8 将数组迭代转换为 lambda 函数

Java 8 HashTable 与 HashMap 冲突处理

java-8 - Guava 缓存异步重新加载

java - CSV 阅读器不注册更改