[8u60] RFR: 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
david.holmes at oracle.com
Fri Apr 24 02:03:52 UTC 2015
On 23/04/2015 6:00 PM, Thomas Stüfe wrote:
> On Thu, Apr 23, 2015 at 9:50 AM, David Holmes <david.holmes at oracle.com
> <mailto:david.holmes at oracle.com>> wrote:
> On 23/04/2015 5:24 PM, Thomas Stüfe wrote:
> - would it be possible to use vfork() instead of fork()? Might
> the chance of fork() succeeding in out-of-memory scenarios. The way
> fork/execve is used here is simple enough for vfork().
> I'm reluctant to use vfork() as it is an unknown. The use of fork()
> has been trialled by Google with no problem.
> I understand.
> We use vfork() by default on Linux and HP-UX since 3-4 years for
> Runtime.exec() without problems (but our implementation differs wildly
> from the standard one). But then, Runtime.exec does not get called in
> error situations, so the conditions may be different for
Right - os::fork_and_exec is potentially a lot more fragile given the
potential execution context. Which prompted me to add a second test for
the general OnError handling case. I also moved the tests to
runtime/ErrorHandling to match the directory that exists in JDK 9.
> - would it be possible to print out errno in case fork fails?
> Regards, Thomas
> On Thu, Apr 23, 2015 at 8:40 AM, David Holmes
> <david.holmes at oracle.com <mailto:david.holmes at oracle.com>
> <mailto:david.holmes at oracle.com
> <mailto:david.holmes at oracle.com>>> wrote:
> webrev: http://cr.openjdk.java.net/~dholmes/8078470/webrev/
> bug: https://bugs.openjdk.java.net/browse/JDK-8078470
> For historical reasons, dating back to LinuxThreads,
> os::fork_and_exec uses direct syscalls to perform fork and
> functions. The fork syscall has been deprecated on linux
> for quite
> some time and some distributions are now shipping with
> syscalls removed - this results in a ENOSYS error and the
> commands that utilize os::fork_and_exec no longer work.
> The problem was discussed here:
> It seems the concerns surrounding direct use of glibc
> fork() and
> exec() are no longer legitimate and Martin Buchholz reports
> Google replaced the syscalls with glibc calls some time ago
> and have
> not had any problems. So we propose to apply the same change
> uniformly on Linux.
> This is initially going into 8u60 via jdk8u-hs-dev due to time
> constraints on the 8u60 schedule, and an internal limitation
> preventing me from pushing this to 9 right now. But it will be
> "backported" to 9 ASAP.
More information about the hotspot-dev