为什么jstack无法获得Java进程的线程?

Nip*_*dar 5 java java-8

我对JSTACK无法获得进程的线程转储很无能为力.它是重新调整错误"java.lang.RuntimeException:无法从地址中推断出线程的类型......"

我试过下面的命令:

$ sudo bin/jstack   42846
$ sudo bin/jstack -F 42846
Run Code Online (Sandbox Code Playgroud)

任何线索都会对我有所帮助.以下是我遇到的错误:

 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)
Run Code Online (Sandbox Code Playgroud)

Nip*_*dar 8

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

但是 jstack 错误输出应该能够表明这个问题,不幸的是它喷出了一些不同的东西。