Comment 5 for bug 2055280

Revision history for this message
Dimitry Andric (dimitry.unified-streaming.com) wrote :

Okay, I think the mystery might be solved.

The root cause is that unattended-upgrades (or some other apt upgrade) does a openjdk-17 package update, while at the same time a java process is running. After this minor upgrade, the protocol between the JRE's forkAndExec JNI function and the jspawnhelper tool is changed! The jspawnhelper tool now expects argv[0] to be the executable name of itself, argv[1] to be a "%d:%d" format string with two file descriptors, and argv[2] to be NULL.

However, the any already-running java process will still use the old protocol, which invoked jspawnhelper with the "%d:%d" format string in argv[0], and argv[1] set to NULL. This is what makes the new jspawnhelper executable segfault.

Therefore, with this particular openjdk-17 upgrade, even it is a minor 'patch' upgrade, it is vital that _ALL_ java processes that intend to spawn external processes are immediately terminated, and restarted.

I would suggest a BIG PROMINENT note in the upgrade message for this particular update, since it is likely to bite a lot of people...

Some references:

https://bugs.openjdk.org/browse/JDK-8310265 ("(process) jspawnhelper should not use argv[0]") is the bug that eventually changed to the JRE <--> jspawnhelper protocol

https://github.com/openjdk/jdk17u-dev/commit/cd6cb730c934d8e16d4bd8e3342e59e806f158f9 is the corresponding commit for OpenJDK 17.

https://bugs.openjdk.org/browse/JDK-8325567 ("jspawnhelper without args fails with segfault") is a related upstream bug. I also noticed the same after the Ubuntu 17.0.10+7-1~22.04.1 package upgrade, because I tried running jspawnhelper myself, and the very first invocation (without arguments) segfaulted. :)

In that bug, Aleksey Shipilev notes:
> So this would only affect whoever is invoking jspawnhelper directly. But that would also run into problems when jspawnhelper protocol changes like in JDK-8310265.

E.g. it is clear that the jspawnhelper protocol was changed without taking into account that any "old" JRE process would now run the helper tool in a way that makes it segfault. I don't think they thought this through correctly, even though it is an internal JRE implementation detail...

Bottom line, this is not really an Ubuntu bug in the package, so feel free to close this ticket, but I would still suggest adding a visible notice that any running OpenJDK processes should be restarted!