oracle / graal

GraalVM compiles Java applications into native executables that start instantly, scale fast, and use fewer compute resources 🚀
https://www.graalvm.org
Other
20.39k stars 1.64k forks source link

Incompatibility between GraalVM 21.0.5+9.1 and Truffle/Polyglot version 24.0.2 #9992

Open mikehearn opened 1 week ago

mikehearn commented 1 week ago

⚠️ NOTICE: Incompatibility between Truffle and GraalVM ⚠️

There is a regression between GraalVM build 21.0.4+8.1 and GraalVM build 21.0.5+9.1 that causes JVM crashes (aborts) when used with Truffle/Polyglot versions 24.0.x due to a mistake during back porting. The error message you get is:

ERROR: com.oracle.truffle.runtime.hotspot.libgraal.TruffleFromLibGraalEntryPoints.onFailure(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/String;ZZIJ)V: Expected 7 parameters, got 6

Because this is a very low level crash that happens in very restricted/sensitive code:

This may surface in tests that use Gradle as the following error:

Failure while communicating with forked test JVM; process has terminated unexpectedly with exit value 99

This bug cannot be fixed as the incompatible versions are now in the wild, but I'm filing it in the hope that people can find it if they encounter the relevant error message.

The fix is to upgrade the Truffle language dependencies, e.g. to org.graalvm.polyglot:{js,polyglot}:24.1.1 or higher.

oubidar-Abderrahim commented 1 week ago

Hi, I tested using a simple hello world polyglot example and was able to run it without errors. Can you share a reproducer to this issue?

chumer commented 1 week ago

Here is my analysis:

1) What is the problem? The problem is that we the new compiler version 23.1.5 (or GraalVM JDK 21.0.5) was calling a method in the Truffle runtime with the same name but different signature. That method did not exist in 23.1.4 and 24.0.x. Since the method had the same name, the method did not show up as not found but it just pushed invalid values on the stack. The invalid value on the stack causes the crash.

2) When does the problem occur? The Problem is limited to using GraalVM for JDK 21.0.5 with polyglot 24.0.x. The problem would also occur with 23.1.4 polyglot, but the version check triggers here to prevent a crash. It is not a problem for any version on master or 24.1. The problem occurs when a compilation fails. Unfortunately this can also happen in regular compilations due to expected temporary bailouts of the compiler. So the scope of the error is unfortunately not reduced.

3) What is the recommended workaround? The recommended workaround ist to upgrade to polyglot from 24.0.x to 24.1.x. 24.0.x is no longer supported anyway.

chumer commented 1 week ago

We will implement a fix for the problem by changing the signature back to the old version. So GraalVM for JDK 21.0.6 will again work with 24.0.x.