7

I'm trying to run jstack on ubuntu in mixed mode:

 $ jstack -m 7219     

The result is this exception:

Attaching to process ID 7219, please wait...
Debugger attached successfully.
Server compiler detected.
  JVM version is 25.162-b12
  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 0x00007f02cc002800 (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.PStack.initJFrameCache(PStack.java:200)
    at sun.jvm.hotspot.tools.PStack.run(PStack.java:71)
    at sun.jvm.hotspot.tools.PStack.run(PStack.java:58)
    at sun.jvm.hotspot.tools.PStack.run(PStack.java:53)
    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 0x00007f02cc002800
    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)
    ... 16 more

The process with PID 7219 was started with the same user as jstack.

chrempl
  • 91
  • 1
  • 5
  • This can be either a bug in HotSpot Serviceability Agent or an attempt to get a stacktrace while JVM is in inconsistent state. In both cases you can hardly do anything about it. – apangin Jul 14 '18 at 23:05
  • Why do you want `-m` mode? If you are interested in non-Java stack, then `gdb` should be a better tool for this. – apangin Jul 14 '18 at 23:06
  • I'm observing long running requests in a web application. Threaddumps point at native classloading methods. My question in https://stackoverflow.com/questions/49507981/unsafe-defineclass-hangs-slow-reflection-calls lead to this tooling issue. – chrempl Jul 16 '18 at 04:28

3 Answers3

2

I've had the same issue on Ubuntu, with openjdk-9-jdk-headless installed, jstack alone would work fine but jstack -m would fail with same error as you.

Installing openjdk-9-dbg (package that brings debug symbols) solved it.

Hugues M.
  • 19,846
  • 6
  • 37
  • 65
  • Exactly the same issue: jstack without the mixed mode flag is running fine. But i'm using Oracle jdk 1.8.0_172. – chrempl Jul 13 '18 at 05:11
0

The same user is fine, but make also sure you are using the jstack that is bundled the exact same JVM as the one that is running the process 7219.

TacheDeChoco
  • 3,683
  • 1
  • 14
  • 17
0

I had the same problem when using HSDB on openjdk-8. Installing lib sudo apt-get install openjdk-8-dbg works.

wangsir
  • 374
  • 2
  • 7