RFR: 8352533: Report useful IOExceptions when jspawnhelper fails
Aleksey Shipilev
shade at openjdk.org
Fri Mar 21 10:13:04 UTC 2025
On Fri, 21 Mar 2025 10:00:26 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
> When jspawnhelper fails for whatever reason, but more prominently due to [JDK-8325621](https://bugs.openjdk.org/browse/JDK-8325621), it will report the errors into stdout, but not to the relevant `IOException`. So, if the application is configured to only capture the exception logs (e.g. through `java.util.logging`), we will miss any output from `jspawnhelper`, and user would be left without a clue what have happened. We have seen customers spending weeks trying to figure out what went wrong.
>
> It would be good to provide useful `IOException` when `jspawnhelper` fails. We already have a precedent with vmError [printing helpful suggestions](https://github.com/openjdk/jdk/blob/master/src/hotspot/share/utilities/vmError.cpp#L422) when VM fails, we can do a similar thing here.
>
> I am very open to bike-shedding about the actual message :)
>
> Additional testing:
> - [x] Ad-hoc experiments with breaking jspawnhelper
> - [x] macos-aarch64-server-fastdebug, `java/lang/Process java/lang/ProcessBuilder`
Easiest way to see what kind of exception is printed on jspawnhelper failure is to run `jdk/java/lang/ProcessBuilder/JspawnhelperProtocol.java`, and see this in its output:
Command line: [... Djdk.lang.Process.launchMechanism=posix_spawn JspawnhelperProtocol simulateCrashInChild4 ]
Recursively executing 'JspawnhelperProtocol simulateCrashInChild4'
posix_spawn:0
java.io.IOException: Cannot run program "pwd": error=0, Failed to exec spawn helper: pid: 85166, exit value: 4
Possible reasons:
- Spawn helper ran into JDK version or configuration problems
- Spawn helper ran into unexpected internal error
- Spawn helper was terminated by another process
Possible solutions:
- Restart JVM, especially after in-place JDK updates
- Check system logs for JDK-related errors
- Re-install JDK to fix permission/versioning problems
- Switch to legacy launch mechanism with -Djdk.lang.Process.launchMechanism=VFORK
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1110)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1044)
at java.base/java.lang.Runtime.exec(Runtime.java:605)
at java.base/java.lang.Runtime.exec(Runtime.java:470)
at JspawnhelperProtocol.parentCode(JspawnhelperProtocol.java:56)
at JspawnhelperProtocol.main(JspawnhelperProtocol.java:230)
-------------
PR Comment: https://git.openjdk.org/jdk/pull/24149#issuecomment-2742889069
More information about the core-libs-dev
mailing list