Github user bersprockets commented on a diff in the pull request: https://github.com/apache/spark/pull/20424#discussion_r164641641 --- Diff: core/src/main/scala/org/apache/spark/api/python/PythonWorkerFactory.scala --- @@ -191,7 +191,20 @@ private[spark] class PythonWorkerFactory(pythonExec: String, envVars: Map[String daemon = pb.start() val in = new DataInputStream(daemon.getInputStream) - daemonPort = in.readInt() + try { + daemonPort = in.readInt() + } catch { + case exc: EOFException => + throw new IOException(s"No port number in $daemonModule's stdout") + } + + // test that the returned port number is within a valid range. + // note: this does not cover the case where the port number + // is arbitrary data but is also coincidentally within range + if (daemonPort < 1 || daemonPort > 0xffff) { --- End diff -- Port 0 has special meaning. A program passes port 0 when it wants the system to choose an unused port on the program's behalf. So, the daemon should not return 0. It's valid to pass port 0 to InetSocketAddress, since you might be asking for the system to assign a port for you. However, following my own logic, the code in my pull request really should be checking for the range 49152-65535 (ephemeral range) instead of 1-65535, but I didn't have the nerve to make it that restrictive.
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org