简体   繁体   中英

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.

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, eg 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:

本机堆栈

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.

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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM