manovenkatesh
manovenkatesh

Reputation: 21

jstack - Dont contains the thread stack trace

While using the jstack to know about the threads for the particular process. For numerous Threads, I can't find any stack trace.

"Thread-4978" #5139 prio=5 os_prio=0 tid=0x000000001d451800 nid=0x8530 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Thread-4808" #4969 prio=5 os_prio=0 tid=0x000000001d44f000 nid=0x8eb0 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

Other than the runnable state I can't get any information from it. Please guide me to debug the issue.

Upvotes: 2

Views: 1539

Answers (2)

apangin
apangin

Reputation: 98330

Java thread has no Java stack trace, when

  • The thread is about to start, and is running pre-start initialization or JVM TI ThreadStart handler.
  • The thread is about to terminate, and is running post-exit cleanup or JVM TI ThreadEnd handler.
  • The thread is a JVM TI agent thread, which is running native code.

To find out what these threads are doing, it's not enough to get Java stack trace - you'd need to get native stack traces as well.

On JDK 8 run

jstack -m <pid>

On JDK 11 and later

jhsdb jstack --mixed --pid <pid>

Another option is to use a profiler which is aware of native stacks, e.g. async-profiler

When used in threaded mode (-t), async-profiler can show mixed stack traces of all threads in the JVM, even if they have no Java stack trace.

For example, when I debugged a similar issue, async-profiler showed me the following stack trace:

native-stack

In my case, this was a JDWP agent running post-thread-end hook. Note that the standard Java debug agent (libjdwp) is a particular case of a JVM TI agent, which has non-trivial ThreadEnd handler.

This was a bug JDK-8227269 that resulted in slow termination of threads. So, if you experience problems with debug agent turned on, the first recommendation is to run JVM without JDWP.

Upvotes: 2

Allen Wu
Allen Wu

Reputation: 32

You can try "-l" and "-e" option, it could provide more information on the other hand, also you can get the information via java code.

jstack -l -e 18632

Thread.currentThread().getStackTrace()

Upvotes: 0

Related Questions