Process.exec with the linux posix_spawn mode has a bug
david.lloyd at redhat.com
Sat May 11 15:14:56 UTC 2019
On Sat, May 11, 2019 at 9:49 AM Remi Forax <forax at univ-mlv.fr> wrote:
> I've seen a weird error on my CI  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.
Assuming you're running on Linux (given that the changeset only
applies to Linux), errno 13 is EACCES which would indicate a
filesystem permission issue. Are you sure you have permission to
execute `jspawnhelper` in your JVM installation? Could there be an
SELinux restriction in place?
Here's what the man page says:
[EACCES] Search permission is denied for a component of
the path prefix.
[EACCES] The new process file is not an ordinary file.
[EACCES] The new process file mode denies execute permission.
[EACCES] The new process file is on a filesystem
mounted with execution
disabled (MNT_NOEXEC in <sys/mount.h>).
> 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 ?
The posix_spawn approach executes an intermediate support process
(`jspawnhelper`) which in turn executes the target process. I believe
there's an extensive discussion on the reasons for this in the
More information about the core-libs-dev