Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8335743

jhsdb jstack cannot print some information on the waiting thread

XMLWordPrintable

    • 21
    • b06
    • generic
    • generic

        When producing the thread dumps with jhsdb command in jdk21 or later, the lock information for waiting threads is missing.

        How to reproduce:
        1. Start a Java process that has a thread which will be WAITING status due to calling Object.wait().

        ```
                Object lock = new Object();
                Thread t = new Thread(() -> {
                    synchronized (lock) {
                        try {
                            lock.wait();
                        } catch (InterruptedException ie) {}
                    }
                }, "WaitThread");
                t.start();
        ```

        2. Use jhsdb to attach to the process and print stack and locks information.

        > jhsdb jstack --pid <PID>

        3. There is a difference in the lock information by jdk21 or later and by jdk17. In jdk21 and later, the line "waiting on ..." indicating the lock information of the waiting thread is not printed.

        - in jdk24

        "WaitThread" #19 prio=5 tid=0x0000029087102ae0 nid=691792 in Object.wait() [0x000000e228aff000]
           java.lang.Thread.State: WAITING (on object monitor)
           JavaThread state: _thread_blocked
         - java.lang.Object.wait0(long) @bci=0 (Interpreted frame)
         - java.lang.Object.wait(long) @bci=11, line=374 (Interpreted frame)
         - java.lang.Object.wait() @bci=2, line=348 (Interpreted frame)
         - WaitTest.lambda$main$0(java.lang.Object) @bci=5, line=37 (Interpreted frame)
                - locked <0x0000000087ff8c38> (a java.lang.Object)
         - WaitTest$$Lambda+0x0000029043000a10.run() @bci=4 (Interpreted frame)
         - java.lang.Thread.runWith(java.lang.Object, java.lang.Runnable) @bci=5, line=1588 (Interpreted frame)
         - java.lang.Thread.run() @bci=19, line=1575 (Interpreted frame)

        - in jdk17

        "WaitThread" #13 prio=5 tid=0x00000183b1369ea0 nid=0xabec8 in Object.wait() [0x0000007943aff000]
           java.lang.Thread.State: WAITING (on object monitor)
           JavaThread state: _thread_blocked
         - java.lang.Object.wait(long) @bci=0 (Interpreted frame)
                - waiting on <0x0000000087ff0388> (a java.lang.Object)
         - java.lang.Object.wait() @bci=2, line=338 (Interpreted frame)
         - WaitTest.lambda$main$0(java.lang.Object) @bci=5, line=37 (Interpreted frame)
                - locked <0x0000000087ff0388> (a java.lang.Object)
         - WaitTest$$Lambda$1+0x00000183b3000a00.run() @bci=4 (Interpreted frame)
         - java.lang.Thread.run() @bci=11, line=840 (Interpreted frame)

        This problem also occurs when you start the interactive command-line debugger with "jhsdb clhsdb" and print a thread dump with the "jstack" or "where" command. On the other hand, when using "jstack" or "jcmd Thread.print", the lock information will be printed correctly.

              tkiriyama Takuya Kiriyama
              tkiriyama Takuya Kiriyama
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: