native image fails to generate binary for a simple array manipulation with the error below...
Steps to reproduce the issue
echo "
public class zzz {
public static void main(String args[]) {
int[] pos = new int[16]; /// fun fact, int[8] works just fine... :)
int mov = 1;
for (;;) {
for (int i = pos.length - 1; i > 0; i--) {
pos[i] = pos[i - 1];
}
pos[0] += mov;
}
}
}
" > zzz.java ; javac zzz.java ; native-image zzz
Describe GraalVM and your environment:
graalvm ce 22.0.2
jdk bundled with graalvm 22 (same if i compile with openjdk 24 with --release 21)
debian linux sid on amd64
[1/8] Initializing... (2.7s @ 0.07GB)
Java version: 22.0.2+9, vendor version: GraalVM CE 22.0.2+9.1
Graal compiler: optimization level: 2, target machine: x86-64-v3
C compiler: gcc (linux, x86_64, 14.1.0)
Garbage collector: Serial GC (max heap size: 80% of RAM)
1 user-specific feature(s):
com.oracle.svm.thirdparty.gson.GsonFeature
Build resources:
11.55GB of memory (75.6% of 15.29GB system memory, determined at start)
12 thread(s) (100.0% of 12 available processor(s), determined at start)
[2/8] Performing analysis... [*] (11.6s @ 0.28GB)
3,195 reachable types (71.4% of 4,473 total)
3,714 reachable fields (42.8% of 8,670 total)
14,805 reachable methods (43.7% of 33,894 total)
1,035 types, 61 fields, and 533 methods registered for reflection
57 types, 57 fields, and 52 methods registered for JNI access
4 native libraries: dl, pthread, rt, z
[3/8] Building universe... (1.7s @ 0.36GB)
[4/8] Parsing methods... [] (1.3s @ 0.34GB)
[5/8] Inlining methods... [*] (1.5s @ 0.26GB)
[6/8] Compiling methods... [***] (10.5s @ 0.30GB)
Fatal error: jdk.graal.compiler.debug.GraalError: too many iterations at loop 0 depth 1 header:6|LoopBegin
at method: void zzz.main(String[]) [Direct call from int JavaMainWrapper.runCore0()]
at jdk.graal.compiler/jdk.graal.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:519)
at jdk.graal.compiler/jdk.graal.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:75)
at jdk.graal.compiler/jdk.graal.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:241)
at jdk.graal.compiler/jdk.graal.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:167)
at jdk.graal.compiler/jdk.graal.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:128)
at jdk.graal.compiler/jdk.graal.compiler.virtual.phases.ea.EffectsPhase.runAnalysis(EffectsPhase.java:115)
at jdk.graal.compiler/jdk.graal.compiler.virtual.phases.ea.PartialEscapePhase.run(PartialEscapePhase.java:141)
at jdk.graal.compiler/jdk.graal.compiler.virtual.phases.ea.FinalPartialEscapePhase.run(FinalPartialEscapePhase.java:64)
at jdk.graal.compiler/jdk.graal.compiler.virtual.phases.ea.FinalPartialEscapePhase.run(FinalPartialEscapePhase.java:42)
at jdk.graal.compiler/jdk.graal.compiler.phases.BasePhase.apply(BasePhase.java:435)
at jdk.graal.compiler/jdk.graal.compiler.phases.BasePhase.apply(BasePhase.java:323)
at jdk.graal.compiler/jdk.graal.compiler.core.phases.BaseTier.run(BaseTier.java:58)
at jdk.graal.compiler/jdk.graal.compiler.phases.BasePhase.apply(BasePhase.java:435)
at jdk.graal.compiler/jdk.graal.compiler.phases.BasePhase.apply(BasePhase.java:323)
at jdk.graal.compiler/jdk.graal.compiler.core.GraalCompiler.emitFrontEnd(GraalCompiler.java:294)
at jdk.graal.compiler/jdk.graal.compiler.core.GraalCompiler.compile(GraalCompiler.java:169)
at jdk.graal.compiler/jdk.graal.compiler.core.GraalCompiler.compileGraph(GraalCompiler.java:137)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.code.CompileQueue.defaultCompileFunction(CompileQueue.java:1214)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.code.CompileQueue.doCompile(CompileQueue.java:1162)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.code.CompileQueue$CompileTask.run(CompileQueue.java:294)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.executeCommand(CompletionExecutor.java:169)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.lambda$executeService$0(CompletionExecutor.java:154)
at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.compute(ForkJoinTask.java:1726)
at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.compute(ForkJoinTask.java:1717)
at java.base/java.util.concurrent.ForkJoinTask$InterruptibleTask.exec(ForkJoinTask.java:1641)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1489)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:2071)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2033)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:187)
1.2s (4.0% of total time) in 197 GCs | Peak RSS: 0.74GB | CPU load: 8.84
=======================================================================================================================
Failed generating 'zzz' after 29.7s.
com.oracle.svm.driver.NativeImage$NativeImageError
at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.showError(NativeImage.java:2258)
at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.build(NativeImage.java:1871)
at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.performBuild(NativeImage.java:1830)
at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.main(NativeImage.java:1812)
at java.base@22.0.2/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
Describe the issue
native image fails to generate binary for a simple array manipulation with the error below...
Steps to reproduce the issue
echo "
public class zzz { public static void main(String args[]) { int[] pos = new int[16]; /// fun fact, int[8] works just fine... :) int mov = 1; for (;;) { for (int i = pos.length - 1; i > 0; i--) { pos[i] = pos[i - 1]; } pos[0] += mov; } } }
" > zzz.java ; javac zzz.java ; native-image zzz
Describe GraalVM and your environment:
graalvm ce 22.0.2 jdk bundled with graalvm 22 (same if i compile with openjdk 24 with --release 21) debian linux sid on amd64
More details
Apply jar:file:///usr/lib/jvm/graalvm/lib/svm/library-support.jar!/META-INF/native-image/com.oracle.svm/thirdparty/native-image.properties Apply jar:file:///usr/lib/jvm/graalvm/lib/svm/library-support.jar!/META-INF/native-image/com.oracle.svm/polyglot/native-image.properties Executing [ HOME=/home/mc36 \ LANG=en_US.UTF-8 \ PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games \ PWD=/home/mc36 \ USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM=true \ /usr/lib/jvm/graalvm/bin/java \ -XX:+UseParallelGC \ -XX:+UnlockExperimentalVMOptions \ -XX:+EnableJVMCI \ -Dtruffle.TrustAllTruffleRuntimeProviders=true \ -Dtruffle.TruffleRuntime=com.oracle.truffle.api.impl.DefaultTruffleRuntime \ -Dgraalvm.ForcePolyglotInvalid=true \ -Dgraalvm.locatorDisabled=true \ -Dsubstratevm.HostLibC=glibc \ --add-exports=java.base/com.sun.crypto.provider=org.graalvm.nativeimage.builder \ --add-exports=java.base/jdk.internal.access=org.graalvm.nativeimage.builder \ --add-exports=java.base/jdk.internal.event=org.graalvm.nativeimage.builder \ --add-exports=java.base/jdk.internal.loader=org.graalvm.nativeimage.builder \ --add-exports=java.base/jdk.internal.logger=org.graalvm.nativeimage.builder \ --add-exports=java.base/jdk.internal.misc=org.graalvm.nativeimage.builder,org.graalvm.nativeimage.objectfile,org.graalvm.nativeimage.pointsto \ --add-exports=java.base/jdk.internal.module=org.graalvm.nativeimage.base,org.graalvm.nativeimage.builder \ --add-exports=java.base/jdk.internal.org.objectweb.asm=org.graalvm.nativeimage.builder \ --add-exports=java.base/jdk.internal.perf=org.graalvm.nativeimage.builder \ --add-exports=java.base/jdk.internal.platform=org.graalvm.nativeimage.builder \ --add-exports=java.base/jdk.internal.ref=org.graalvm.nativeimage.builder,org.graalvm.nativeimage.objectfile \ --add-exports=java.base/jdk.internal.reflect=org.graalvm.nativeimage.builder \ --add-exports=java.base/jdk.internal.util=org.graalvm.nativeimage.builder \ --add-exports=java.base/jdk.internal.vm.annotation=org.graalvm.nativeimage.builder \ --add-exports=java.base/jdk.internal.vm=org.graalvm.nativeimage.builder \ --add-exports=java.base/jdk.internal=org.graalvm.nativeimage.builder \ --add-exports=java.base/sun.invoke.util=org.graalvm.nativeimage.builder \ --add-exports=java.base/sun.net.www=org.graalvm.nativeimage.builder \ --add-exports=java.base/sun.net=org.graalvm.nativeimage.builder \ --add-exports=java.base/sun.nio.ch=org.graalvm.nativeimage.builder,org.graalvm.nativeimage.objectfile \ --add-exports=java.base/sun.reflect.annotation=org.graalvm.nativeimage.builder \ --add-exports=java.base/sun.reflect.generics.factory=org.graalvm.nativeimage.builder \ --add-exports=java.base/sun.reflect.generics.reflectiveObjects=org.graalvm.nativeimage.builder \ --add-exports=java.base/sun.reflect.generics.repository=org.graalvm.nativeimage.builder \ --add-exports=java.base/sun.reflect.generics.scope=org.graalvm.nativeimage.builder \ --add-exports=java.base/sun.reflect.generics.tree=org.graalvm.nativeimage.builder \ --add-exports=java.base/sun.security.jca=org.graalvm.nativeimage.builder \ --add-exports=java.base/sun.security.provider=org.graalvm.nativeimage.builder \ --add-exports=java.base/sun.security.ssl=org.graalvm.nativeimage.builder \ --add-exports=java.base/sun.security.util=org.graalvm.nativeimage.builder \ --add-exports=java.base/sun.security.x509=org.graalvm.nativeimage.builder \ --add-exports=java.base/sun.text.spi=org.graalvm.nativeimage.builder \ --add-exports=java.base/sun.util.calendar=org.graalvm.nativeimage.builder \ --add-exports=java.base/sun.util.cldr=org.graalvm.nativeimage.builder \ --add-exports=java.base/sun.util.locale.provider=org.graalvm.nativeimage.builder \ --add-exports=java.base/sun.util.locale=org.graalvm.nativeimage.builder \ --add-exports=java.base/sun.util.resources=org.graalvm.nativeimage.builder \ --add-exports=java.base/sun.util=org.graalvm.nativeimage.builder \ --add-exports=java.management/com.sun.jmx.mbeanserver=org.graalvm.nativeimage.builder \ --add-exports=java.management/sun.management=org.graalvm.nativeimage.builder,org.graalvm.nativeimage.pointsto \ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.aarch64=jdk.graal.compiler,org.graalvm.nativeimage.builder,org.graalvm.nativeimage.objectfile \ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.amd64=jdk.graal.compiler,org.graalvm.nativeimage.builder,org.graalvm.nativeimage.objectfile \ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.code.site=jdk.graal.compiler,org.graalvm.nativeimage.builder \ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.code.stack=jdk.graal.compiler,org.graalvm.nativeimage.builder \ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.code=jdk.graal.compiler,org.graalvm.nativeimage.builder,org.graalvm.nativeimage.objectfile,org.graalvm.nativeimage.pointsto,org.graalvm.truffle.compiler \ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.common=jdk.graal.compiler,org.graalvm.nativeimage.builder,org.graalvm.nativeimage.pointsto \ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.aarch64=jdk.graal.compiler \ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.amd64=jdk.graal.compiler \ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.riscv64=jdk.graal.compiler \ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot=jdk.graal.compiler,org.graalvm.nativeimage.builder \ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.meta=jdk.graal.compiler,org.graalvm.nativeimage.base,org.graalvm.nativeimage.builder,org.graalvm.nativeimage.objectfile,org.graalvm.nativeimage.pointsto,org.graalvm.truffle.compiler \ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.riscv64=jdk.graal.compiler,org.graalvm.nativeimage.builder \ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.runtime=jdk.graal.compiler,org.graalvm.nativeimage.builder,org.graalvm.nativeimage.pointsto \ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.services=jdk.graal.compiler,org.graalvm.nativeimage.builder \ --add-exports=jdk.jfr/jdk.jfr.events=org.graalvm.nativeimage.builder \ --add-exports=jdk.jfr/jdk.jfr.internal.event=org.graalvm.nativeimage.builder \ --add-exports=jdk.jfr/jdk.jfr.internal.jfc=org.graalvm.nativeimage.builder \ --add-exports=jdk.jfr/jdk.jfr.internal=org.graalvm.nativeimage.builder \ --add-exports=jdk.management/com.sun.management.internal=org.graalvm.nativeimage.builder \ -XX:+UseJVMCINativeLibrary \ -Xss10m \ -XX:MaxRAMPercentage=85.0 \ -XX:GCTimeRatio=9 \ -XX:+ExitOnOutOfMemoryError \ -Djava.awt.headless=true \ '-Dorg.graalvm.vendor=GraalVM Community' \ -Dorg.graalvm.vendorurl=https://www.graalvm.org/ \ '-Dorg.graalvm.vendorversion=GraalVM CE 22.0.2+9.1' \ -Dorg.graalvm.version=24.0.2 \ -Dcom.oracle.graalvm.isaot=true \ -Djava.system.class.loader=com.oracle.svm.hosted.NativeImageSystemClassLoader \ -Xshare:off \ -Djdk.reflect.useOldSerializableConstructor=true \ -Djdk.internal.lambda.disableEagerInitialization=true \ -Djdk.internal.lambda.eagerlyInitialize=false \ -Djava.lang.invoke.InnerClassLambdaMetafactory.initializeLambdas=false \ -Djava.lang.invoke.MethodHandle.DONT_INLINE_THRESHOLD=-1 \ -Djava.lang.invoke.MethodHandle.PROFILE_GWT=false \ --add-modules=ALL-DEFAULT \ --module-path \ /usr/lib/jvm/graalvm/lib/svm/builder/svm.jar:/usr/lib/jvm/graalvm/lib/svm/builder/native-image-base.jar:/usr/lib/jvm/graalvm/lib/svm/builder/objectfile.jar:/usr/lib/jvm/graalvm/lib/svm/builder/svm-foreign.jar:/usr/lib/jvm/graalvm/lib/svm/builder/pointsto.jar \ --module \ org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner \ -keepalive \ /proc/58570/comm \ -imagecp \ /home/mc36 \ -imagemp \ /usr/lib/jvm/graalvm/lib/svm/library-support.jar \ -H:CLibraryPath=/usr/lib/jvm/graalvm/lib/svm/clibraries/linux-amd64 \ -H:Path@driver=/home/mc36 \ '-H:Class@explicit main-class=zzz' \ '-H:Name@main-class lower case as image name=zzz' \ -H:ImageBuildID@driver=64bd2c97-024f-ee7e-7f01-2b5fc538223e \ '-H:Features@jar:file:///usr/lib/jvm/graalvm/lib/svm/library-support.jar!/META-INF/native-image/com.oracle.svm/thirdparty/native-image.properties+api=com.oracle.svm.thirdparty.gson.GsonFeature' \ '-H:Features@jar:file:///usr/lib/jvm/graalvm/lib/svm/library-support.jar!/META-INF/native-image/com.oracle.svm/polyglot/native-image.properties+api=com.oracle.svm.polyglot.groovy.GroovyIndyInterfaceFeature,com.oracle.svm.polyglot.scala.ScalaFeature' \ -H:Color@driver=always \ -H:+BuildOutputProgress@driver \ -H:+BuildOutputLinks@driver ]
GraalVM Native Image: Generating 'zzz' (executable)...
[1/8] Initializing... (2.7s @ 0.07GB) Java version: 22.0.2+9, vendor version: GraalVM CE 22.0.2+9.1 Graal compiler: optimization level: 2, target machine: x86-64-v3 C compiler: gcc (linux, x86_64, 14.1.0) Garbage collector: Serial GC (max heap size: 80% of RAM) 1 user-specific feature(s):
com.oracle.svm.thirdparty.gson.GsonFeature
Build resources:
Fatal error: jdk.graal.compiler.debug.GraalError: too many iterations at loop 0 depth 1 header:6|LoopBegin at method: void zzz.main(String[]) [Direct call from int JavaMainWrapper.runCore0()] at jdk.graal.compiler/jdk.graal.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:519) at jdk.graal.compiler/jdk.graal.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:75) at jdk.graal.compiler/jdk.graal.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:241) at jdk.graal.compiler/jdk.graal.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:167) at jdk.graal.compiler/jdk.graal.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:128) at jdk.graal.compiler/jdk.graal.compiler.virtual.phases.ea.EffectsPhase.runAnalysis(EffectsPhase.java:115) at jdk.graal.compiler/jdk.graal.compiler.virtual.phases.ea.PartialEscapePhase.run(PartialEscapePhase.java:141) at jdk.graal.compiler/jdk.graal.compiler.virtual.phases.ea.FinalPartialEscapePhase.run(FinalPartialEscapePhase.java:64) at jdk.graal.compiler/jdk.graal.compiler.virtual.phases.ea.FinalPartialEscapePhase.run(FinalPartialEscapePhase.java:42) at jdk.graal.compiler/jdk.graal.compiler.phases.BasePhase.apply(BasePhase.java:435) at jdk.graal.compiler/jdk.graal.compiler.phases.BasePhase.apply(BasePhase.java:323) at jdk.graal.compiler/jdk.graal.compiler.core.phases.BaseTier.run(BaseTier.java:58) at jdk.graal.compiler/jdk.graal.compiler.phases.BasePhase.apply(BasePhase.java:435) at jdk.graal.compiler/jdk.graal.compiler.phases.BasePhase.apply(BasePhase.java:323) at jdk.graal.compiler/jdk.graal.compiler.core.GraalCompiler.emitFrontEnd(GraalCompiler.java:294) at jdk.graal.compiler/jdk.graal.compiler.core.GraalCompiler.compile(GraalCompiler.java:169) at jdk.graal.compiler/jdk.graal.compiler.core.GraalCompiler.compileGraph(GraalCompiler.java:137) at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.code.CompileQueue.defaultCompileFunction(CompileQueue.java:1214) at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.code.CompileQueue.doCompile(CompileQueue.java:1162) at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.code.CompileQueue$CompileTask.run(CompileQueue.java:294) at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.executeCommand(CompletionExecutor.java:169) at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.lambda$executeService$0(CompletionExecutor.java:154) at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.compute(ForkJoinTask.java:1726) at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.compute(ForkJoinTask.java:1717) at java.base/java.util.concurrent.ForkJoinTask$InterruptibleTask.exec(ForkJoinTask.java:1641) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1489) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:2071) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2033) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:187)
======================================================================================================================= Failed generating 'zzz' after 29.7s. com.oracle.svm.driver.NativeImage$NativeImageError at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.showError(NativeImage.java:2258) at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.build(NativeImage.java:1871) at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.performBuild(NativeImage.java:1830) at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.main(NativeImage.java:1812) at java.base@22.0.2/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)