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

jhsdb jstack does not work with debugd server on OSX

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 15
    • Fix Version/s: tbd
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      os_x

      Description

      The easiest way to reproduce this is with serviceability/sa/sadebugd/DebugdConnectTest.java. It time out. However, if you look in the log the real issue is the following, which happens repeatedly:

      java.lang.ClassCastException: class sun.jvm.hotspot.debugger.remote.RemoteDebuggerClient cannot be cast to class sun.jvm.hotspot.debugger.bsd.BsdDebuggerLocal (sun.jvm.hotspot.debugger.remote.RemoteDebuggerClient and sun.jvm.hotspot.debugger.bsd.BsdDebuggerLocal are in module jdk.hotspot.agent of loader 'app')
      at jdk.hotspot.agent/sun.jvm.hotspot.runtime.bsd_amd64.BsdAMD64JavaThreadPDAccess.getThreadProxy(BsdAMD64JavaThreadPDAccess.java:135)
      at jdk.hotspot.agent/sun.jvm.hotspot.runtime.bsd_amd64.BsdAMD64JavaThreadPDAccess.getCurrentFrameGuess(BsdAMD64JavaThreadPDAccess.java:96)
      at jdk.hotspot.agent/sun.jvm.hotspot.runtime.JavaThread.getCurrentFrameGuess(JavaThread.java:265)
      at jdk.hotspot.agent/sun.jvm.hotspot.runtime.JavaThread.getLastJavaVFrameDbg(JavaThread.java:227)
      at jdk.hotspot.agent/sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:81)
      at jdk.hotspot.agent/sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:45)
      at jdk.hotspot.agent/sun.jvm.hotspot.tools.JStack.run(JStack.java:67)
      at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.startInternal(Tool.java:262)
      at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.start(Tool.java:225)
      at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.execute(Tool.java:118)
      at jdk.hotspot.agent/sun.jvm.hotspot.tools.JStack.runWithArgs(JStack.java:90)
      at jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.runJSTACK(SALauncher.java:290)
      at jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.main(SALauncher.java:406)

      The ClassCastException is the real issue, causing jstack to fail. However it's not clear why this results in a test timeout. The test properly detects the jstack failure and throws an exception. A finally block triggers kill the debugd process by calling debugd.detach(). Since debudg was attached to the LingeredApp, this should allow the LingeredApp to continue to run. Next the test calls LingeredApp.stopApp() and this is where stack traces show the test is stuck when the timeout happens. If debugd had not exited, then it would make sense that LingeredApp would not be able to exit (and can't run until debugd has detached from it), but this is not the case. I did try simiulating all this from the command line (running a simple app, attaching to it with debugd, and running jstack through the debugd to reproduce the same exception above). Once doing this, I exited debugd, and the app was responsive again.

      You can also easily reproduce this failure from the command line. Start by running a simple java app. I used "jhsdb clhsdb" since it is convenient:

       ./jhsdb clhsdb

      From another shell run debugd, and attach to the clhsdb process (use jps to get the pid):

      ./jhsdb debugd --serverid foo --pid 53938

      And from a 3rd shell run jstack, connecting to the debugd server:

      $ ./jhsdb jstack --connect foo@localhost
      Attaching to remote server foo@localhost, please wait...
      Debugger attached successfully.
      Server compiler detected.
      JVM version is 15-internal+0-2020-01-23-2238326.cplummer...
      Deadlock Detection:

      No deadlocks found.

      "main" #1 prio=5 tid=0x00007fede6008000 nid=0x1f03 runnable [0x0000700004200000]
         java.lang.Thread.State: RUNNABLE
         JavaThread state: _thread_in_native
      Error occurred during stack walking:
      java.lang.ClassCastException: class sun.jvm.hotspot.debugger.remote.RemoteDebuggerClient cannot be cast to class sun.jvm.hotspot.debugger.bsd.BsdDebuggerLocal (sun.jvm.hotspot.debugger.remote.RemoteDebuggerClient and sun.jvm.hotspot.debugger.bsd.BsdDebuggerLocal are in module jdk.hotspot.agent of loader 'app')
      at jdk.hotspot.agent/sun.jvm.hotspot.runtime.bsd_amd64.BsdAMD64JavaThreadPDAccess.getThreadProxy(BsdAMD64JavaThreadPDAccess.java:134)
      at jdk.hotspot.agent/sun.jvm.hotspot.runtime.bsd_amd64.BsdAMD64JavaThreadPDAccess.getCurrentFrameGuess(BsdAMD64JavaThreadPDAccess.java:96)
      at jdk.hotspot.agent/sun.jvm.hotspot.runtime.JavaThread.getCurrentFrameGuess(JavaThread.java:265)
      at jdk.hotspot.agent/sun.jvm.hotspot.runtime.JavaThread.getLastJavaVFrameDbg(JavaThread.java:227)
      at jdk.hotspot.agent/sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:81)
      at jdk.hotspot.agent/sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:45)
      at jdk.hotspot.agent/sun.jvm.hotspot.tools.JStack.run(JStack.java:67)
      at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.startInternal(Tool.java:262)
      at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.start(Tool.java:225)
      at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.execute(Tool.java:118)
      at jdk.hotspot.agent/sun.jvm.hotspot.tools.JStack.runWithArgs(JStack.java:90)
      at jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.runJSTACK(SALauncher.java:290)
      at jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.main(SALauncher.java:406)

      ...and a bunch more similar failures. Each thread will produce this backtrace.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                cjplummer Chris Plummer
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: