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.42k stars 1.64k forks source link

Unexpected number of values in state to merge error when compiling Truffle language to native #3448

Closed borkdude closed 3 years ago

borkdude commented 3 years ago

Describe the issue I'm trying to compile the "make a lisp" java-truffle example to native.

The repo: https://github.com/kanaka/mal/tree/master/impls/java-truffle

The script:

#!/bin/bash

make all

CP=$(gradle -q --console plain printClasspath)

$GRAALVM_HOME/bin/native-image \
    --no-server \
    --no-fallback \
    --macro:truffle \
    --initialize-at-build-time \
    -classpath $CP \
    truffle.mal.${STEP:-stepE_macros} "$@"

Steps to reproduce the issue Please include both build steps as well as run steps

  1. Clone the repo
  2. Run the above script

Describe GraalVM and your environment:

More details

Output:

$ ./native
gradle build

> Configure project :
/private/tmp/mal/impls/java-truffle/build/classes/java/main:/private/tmp/mal/impls/java-truffle/build/resources/main:/Users/borkdude/.m2/repository/org/graalvm/truffle/truffle-api/21.1.0/truffle-api-21.1.0.jar:/Users/borkdude/.gradle/caches/modules-2/files-2.1/org.organicdesign/Paguro/3.2.0/c437a15a2eb0a1f3efbdbf995c7ee8c988201963/Paguro-3.2.0.jar:/Users/borkdude/.m2/repository/org/graalvm/sdk/graal-sdk/21.1.0/graal-sdk-21.1.0.jar

> Task :compileJava
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

BUILD SUCCESSFUL in 4s
2 actionable tasks: 2 executed
[truffle.mal.stepe_macros:38209]    classlist:     853.39 ms,  0.96 GB
[truffle.mal.stepe_macros:38209]        (cap):     936.44 ms,  0.96 GB
[truffle.mal.stepe_macros:38209]        setup:   2,268.14 ms,  0.96 GB
[truffle.mal.stepe_macros:38209]     (clinit):     468.59 ms,  3.20 GB
[truffle.mal.stepe_macros:38209]   (typeflow):   8,444.53 ms,  3.20 GB
[truffle.mal.stepe_macros:38209]    (objects):  14,876.74 ms,  3.20 GB
[truffle.mal.stepe_macros:38209]   (features):   8,625.51 ms,  3.20 GB
[truffle.mal.stepe_macros:38209]     analysis:  33,304.50 ms,  3.20 GB
[truffle.mal.stepe_macros:38209]     universe:     867.86 ms,  3.20 GB
19216 method(s) included for runtime compilation
Fatal error:com.oracle.svm.core.util.VMError$HostedError: Unexpected number of values in state to merge.
DeoptSourceFrameInfo: locals-13, stack-2, locks-1.
Merge FrameState: locals-13, stack-0, locks-1.

    at com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:68)
    at com.oracle.svm.hosted.code.CompilationInfoSupport$DeoptSourceFrameInfo.mergeStateInfo(CompilationInfoSupport.java:101)
    at com.oracle.svm.hosted.code.CompilationInfoSupport.lambda$registerDeoptEntry$2(CompilationInfoSupport.java:164)
    at java.base/java.util.HashMap.compute(HashMap.java:1228)
    at com.oracle.svm.hosted.code.CompilationInfoSupport.registerDeoptEntry(CompilationInfoSupport.java:164)
    at com.oracle.svm.graal.hosted.GraalFeature.registerDeoptEntries(GraalFeature.java:756)
    at com.oracle.svm.graal.hosted.GraalFeature.beforeCompilation(GraalFeature.java:712)
    at com.oracle.svm.hosted.NativeImageGenerator.lambda$doRun$8(NativeImageGenerator.java:644)
    at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:71)
    at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:644)
    at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$2(NativeImageGenerator.java:495)
    at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Error: Image build request failed with exit status 1
oubidar-Abderrahim commented 3 years ago

Tracked internally at GR-31878

teshull commented 3 years ago

I was able to recreate the problem and a fix should be merged to master soon for this specific error (not the blacklisted method issues which are addressed in https://github.com/kanaka/mal/pull/572)

teshull commented 3 years ago

Fixed with https://github.com/oracle/graal/commit/506dc2f1ad7a8a23466199cfc6c9c1d824678643