JVM freezes when executing a jmap command using the Process and Runtime API

XMLWordPrintable

    • svc
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      This is true on Linux and Windows.

      A DESCRIPTION OF THE PROBLEM :
      If the following command jmap -histo:live <pid> is executed through the JVM (using Process and Runtime API), the JVM of Java 25.0.0+ freezes.

      The JVM of Java 21 did not freeze running the exact same code.

      REGRESSION - Customer Java Version: 25



      REGRESSION : Last worked in version 21.0.9

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the snippet with a JVM 25 (tested on version 25.0.0 and 25.0.1).

      ---------- BEGIN SOURCE ----------
      import java.io.File;
      import java.io.IOException;
      import java.nio.file.Paths;

      public class JmapJava25 {

          static void main() throws IOException, InterruptedException {
              File jmapHome = Paths.get(System.getProperty("java.home"))
                      .resolve("bin/jmap")
                      .toAbsolutePath()
                      .normalize()
                      .getParent()
                      .toFile();
              new Thread(() ->
              {
                  while (true) {
                      try {
                          Thread.sleep(1000);
                      } catch (InterruptedException e) {
                          throw new RuntimeException(e);
                      }
                      System.out.println(System.currentTimeMillis());
                  }
              }).start();
              Thread.sleep(5000);
              Runtime.getRuntime().exec(new String[] {"jmap", "-histo:live", ProcessHandle.current().pid() + ""}, null, jmapHome);
          }
      }
      ---------- END SOURCE ----------
      FREQUENCY :
      ALWAYS

            Assignee:
            Unassigned
            Reporter:
            Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: