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

jtools do not list VM process launched with the debugger option suspend=y

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8, 9, 10, 11, 12
    • Fix Version/s: 12
    • Component/s: core-svc
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b23
    • CPU:
      generic
    • OS:
      generic

      Description

      The jcmd, jps, jinfo, jmap and jstack do not list the VM processes launched with the debugger option suspend=y

      Please, find the debuggerattach.jar in the bug report attachments.

      1) Run the following command in one Terminal:

      % /java/re/jdk/9/promoted/latest/binaries/linux-x64/bin/java -cp debuggerattach.jar -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5900
      Listening for transport dt_socket at address: 5900

      2) In another terminal:

      % ps -ef | g debuggerattach
      sspitsyn 28995 28282 0 14:20 pts/0 00:00:00 /java/re/jdk/9/promoted/latest/binaries/linux-x64/bin/java -cp debuggerattach.jar -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5900

      % /java/re/jdk/9/promoted/latest/binaries/linux-x64/bin/jcmd -l
      27015 jdk.jcmd/sun.tools.jcmd.JCmd -l

      The process 28995 was not listed above.
      The same issue exist for other jtools like jps, jinfo, jmap and jstack.

      This is a comment from Robbin Ehn:

      It is the AttachProvider that don't see the VM when you have "suspend=y".
      So jcmd never get it at all.

      E.g. if you are running this code:
          public static void main(String[] args) {
              List<VirtualMachineDescriptor> vmds = com.sun.tools.attach.VirtualMachine.list();
              for (VirtualMachineDescriptor vmd : vmds) {
                  System.out.println(vmd);
              }
          }
      It's not listed as long as it's suspended.

      Adding some tracing allows to see this:

      $BIN/jcmd -l
      MYTRACE: listVirtualMachines: next pid: 31240
      MYTRACE: listVirtualMachines: Exception for pid: 31240
      sun.jvmstat.monitor.MonitorException: Could not synchronize with target
      at jdk.internal.jvmstat/sun.jvmstat.perfdata.monitor.v2_0.PerfDataBuffer.synchWithTarget(PerfDataBuffer.java:274)
      at jdk.internal.jvmstat/sun.jvmstat.perfdata.monitor.v2_0.PerfDataBuffer.buildMonitorMap(PerfDataBuffer.java:132)
      at jdk.internal.jvmstat/sun.jvmstat.perfdata.monitor.PerfDataBufferImpl.findByName(PerfDataBufferImpl.java:242)
      at jdk.internal.jvmstat/sun.jvmstat.perfdata.monitor.AbstractPerfDataBuffer.findByName(AbstractPerfDataBuffer.java:99)
      at jdk.internal.jvmstat/sun.jvmstat.perfdata.monitor.AbstractMonitoredVm.findByName(AbstractMonitoredVm.java:82)
      at jdk.internal.jvmstat/sun.jvmstat.monitor.MonitoredVmUtil.isAttachable(MonitoredVmUtil.java:181)
      at jdk.attach/sun.tools.attach.HotSpotAttachProvider.listVirtualMachines(HotSpotAttachProvider.java:95)
      at jdk.attach/com.sun.tools.attach.VirtualMachine.list(VirtualMachine.java:146)
      at jdk.jcmd/sun.tools.common.ProcessArgumentMatcher.getVMDs(ProcessArgumentMatcher.java:131)
      at jdk.jcmd/sun.tools.common.ProcessArgumentMatcher.getVirtualMachineDescriptors(ProcessArgumentMatcher.java:144)
      at jdk.jcmd/sun.tools.common.ProcessArgumentMatcher.getVirtualMachineDescriptors(ProcessArgumentMatcher.java:149)
      at jdk.jcmd/sun.tools.jcmd.JCmd.main(JCmd.java:77)
      MYTRACE: listVirtualMachines: next pid: 16893
      16893 jdk.jcmd/sun.tools.jcmd.JCmd -l

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              gadams Gary Adams (Inactive)
              Reporter:
              sspitsyn Serguei Spitsyn
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: