Uploaded image for project: 'Code Tools'
  1. Code Tools
  2. CODETOOLS-7902047

Fix the way jtreg Agent opens sockets.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P2
    • Resolution: Fixed
    • Affects Version/s: jt4.2
    • Fix Version/s: jt4.2
    • Component/s: tools
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b09

      Description

      From [~dcubed] (edited)

      Looks like JTREG has an instance of the ServerSocket bug.

      com/sun/javatest/regtest/exec/Agent.java:

      private Agent(File dir, JDK jdk, List<String> vmOpts, Map<String, String> envVars,
      File policyFile) throws Fault {
      <snip>
      ServerSocket ss = new ServerSocket(/port:/ 0, /backlog:/ 1);
      cmd.add(AgentServer.PORT);
      cmd.add(String.valueOf(ss.getLocalPort()));

      show("Started " + cmd);

      ProcessBuilder pb = new ProcessBuilder(cmd);
      pb.directory(dir);
      Map<String, String> env = pb.environment();
      env.clear();
      env.putAll(envVars);
      process = pb.start();
      copyStream("stdout", process.getInputStream(), System.out);
      copyStream("stderr", process.getErrorStream(), System.err);

      try {
      final int ACCEPT_TIMEOUT = 60*1000; // 1 minute, for server to start and "phone home"
      ss.setSoTimeout(ACCEPT_TIMEOUT);
      Socket s = ss.accept();}}

      The ServerSocket constructor above passes port==0 so it uses an
      anonymous port. On platforms where SO_REUSEADDR is enabled
      by default, that anonymous port can be stolen by another process
      that is also creating a ServerSocket with an anonymous port. The
      "interloper" process steals the "connect" that JTREG is waiting for
      in the ss.accept() call which results in the failure mode that we're
      seeing.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jjg Jonathan Gibbons
              Reporter:
              jjg Jonathan Gibbons
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: