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.
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.
- relates to
-
CODETOOLS-7902049 Fix the way javatest Agent opens sockets
- Resolved
-
CODETOOLS-7901836 Cannot get VM for test during run java/util/concurrent/forkjoin/Integrate.java
- Closed