Process.exec with the linux posix_spawn mode has a bug

Remi Forax forax at univ-mlv.fr
Sat May 11 14:48:14 UTC 2019


I've seen a weird error on my CI [1] since the 15th of February when using the jdk 13,
i was not able to run jshell* using the programmatic API (java tool) anymore.

Yesterday, i took the time to track that issue and i believe i've found the root cause, trying to execute the java launcher using ProcessBuilder.start() with the jdk 13 sometimes fails with an i/o exception (errno 13) which is weird because you are trying to execute the same process that the one you are executing. Note that this is a spurious bug, I was not able to find the exact condition that triggers that bug.
So sometime it works, sometime it doesn't.

If i pass -Djdk.lang.Process.launchMechanism=fork (or vfork) when starting the VM, the bug disappear meaning that the bug occurs when the VM is trying to use posix_spawn, perhaps spawn is trying to do an optimization when you try to execute the same process as the one you are running under some conditions ?

Given the use of posix_spawn by default was enabled by the changeset f037d1a2e899 at the beginning of February, i believe i've spotted the issue.

regards,
Rémi


[1] https://travis-ci.org/forax/pratt_parser/jobs/493756422
[2] http://hg.openjdk.java.net/jdk/jdk/file/f037d1a2e899/src/java.base/unix/classes/java/lang/ProcessImpl.java

* jshell works by spawning and controlling a new VM.


More information about the core-libs-dev mailing list