RFR: 8307990: jspawnhelper must close its writing side of a pipe before reading from it
Volker Simonis
simonis at openjdk.org
Mon May 15 12:34:44 UTC 2023
On Fri, 12 May 2023 21:37:36 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
> Looks ok.
>
> Is it practical to write a test for this situation? Can I assume you've validated the improvement as a remedy for the observed hangs?
I thought about a test but couldn't come up with a practical way to write it. The JVM has to exit in the time frame after the `posix_spawn()` and before `jspawnhelper` has read its data from the parent. In production this usually happens due to memory constraints on the particular host which let the OOM-killer kill the JVM process because it is the biggest memory consumer.
The production issue could be mitigated by going back to using vfork (i.e. `-Djdk.lang.Process.launchMechanism=VFORK`). I could locally reproduce the problem manually in gdb and with the help of a small C program. I've verified that the proposed change of closing the child's write end of the pipe fixes the problem both in the small C example as well as in the JDK if the issue is reproduced manually in gdb.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/13956#issuecomment-1547777042
More information about the core-libs-dev
mailing list