RFR: 8325567: jspawnhelper without args fails with segfault

Vladimir Petko vpetko at openjdk.org
Fri Mar 1 03:18:12 UTC 2024


This MR fixes segsegv in jspawnhelper when it is called without args. 
This scenario happens when a long running Java process is not restarted during upgrade. 

It updates test/jdk/java/lang/ProcessBuilder/JspawnhelperProtocol.java to check that jspawnhelper exits with code 1:

After test update:

$ make CONF=linux-x86_64-server-fastdebug test TEST=test/jdk/java/lang/ProcessBuilder/JspawnhelperProtocol.java
...
Running jspawnhelper without args
STDERR:
java.lang.Exception: Parent process exited with 12
        at JspawnhelperProtocol.simulateJspawnhelperWithoutArgs(JspawnhelperProtocol.java:126)
        at JspawnhelperProtocol.main(JspawnhelperProtocol.java:267)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at com.sun.javatest.regtest.agent.MainWrapper$MainTask.run(MainWrapper.java:138)
        at java.base/java.lang.Thread.run(Thread.java:1575)
...
==============================
Test summary
==============================
   TEST                                              TOTAL  PASS  FAIL ERROR   
   jtreg:test/jdk/java/lang/ProcessBuilder/JspawnhelperProtocol.java
>>                                                       1     0     1     0 <<
==============================
TEST FAILURE

After jspawnhelper change the test passes:

==============================
Test summary
==============================
   TEST                                              TOTAL  PASS  FAIL ERROR   
   jtreg:test/jdk/java/lang/ProcessBuilder/JspawnhelperProtocol.java
                                                         1     1     0     0   
==============================
TEST SUCCESS


The user will see the following output in the logs:

An earlier version of Java is trying to call jspawnhelper.
Please restart Java process.
Exception in thread "main" java.io.IOException: Cannot run program "ls": error=0, Failed to exec spawn helper: pid: 2168121, exit value: 1
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1143)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
        at Test.main(Test.java:3)
Caused by: java.io.IOException: error=0, Failed to exec spawn helper: pid: 2168121, exit value: 1
        at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
        at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:314)
        at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:244)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1110)

-------------

Commit messages:
 - update copyright year
 - handle no-args call in jspawnhelper
 - update JspawnhelperProtocol.java to test jspawnhelper call without args

Changes: https://git.openjdk.org/jdk/pull/18074/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=18074&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8325567
  Stats: 46 lines in 2 files changed: 44 ins; 0 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/18074.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/18074/head:pull/18074

PR: https://git.openjdk.org/jdk/pull/18074


More information about the core-libs-dev mailing list