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.24k stars 1.62k forks source link

[GR-51287] Nasty error while building with user-provided PGO #8138

Open sgammon opened 8 months ago

sgammon commented 8 months ago

Describe the issue I've generated a PGO profile for a Micronaut/Kotlin app which runs fine without PGO. After applying this profile (with --pgo=profile.iprof), I get the stacktrace enclosed (well, like 1000x of the stacktrace enclosed, this is just one sample).

Steps to reproduce the issue If the stacktrace is helpful and this is not a known issue, I can try to isolate it.

Describe GraalVM and your environment:

More details

[1/8] Initializing...                                                                                   (12.8s @ 1.52GB)
 Java version: 21.0.1+12, vendor version: Oracle GraalVM 21.0.1+12.1
 Graal compiler: optimization level: 3, target machine: compatibility, PGO: user-provided
 C compiler: gcc (linux, x86_64, 9.4.0)
 Garbage collector: G1 GC (max heap size: 2.00GB)
 10 user-specific feature(s):
 - com.google.api.gax.grpc.nativeimage.GrpcNettyFeature
 - com.google.api.gax.nativeimage.GoogleJsonClientFeature
 - com.google.api.gax.nativeimage.OpenCensusFeature
 - com.oracle.svm.thirdparty.gson.GsonFeature
 - com.planetscale.PlanetscaleFeature
 - io.micronaut.cache.caffeine.graal.CaffeineFeature
 - io.micronaut.core.io.service.ServiceLoaderFeature
 - io.micronaut.jackson.JacksonDatabindFeature
 - org.eclipse.angus.activation.nativeimage.AngusActivationFeature
 - org.graalvm.home.HomeFinderFeature: Finds GraalVM paths and its version number
------------------------------------------------------------------------------------------------------------------------
 4 experimental option(s) unlocked:
 - '-H:CStandard' (origin(s): command line)
 - '-H:+StaticExecutableWithDynamicLibC' (origin(s): command line)
 - '-H:+LocalizationOptimizedMode' (origin(s): command line)
 - '-H:ReflectionConfigurationResources' (origin(s): 'META-INF/native-image/org.projectnessie.cel/cel-core/main/native-image.properties' in 'file:///home/dev/.gradle/caches/modules-2/files-2.1/org.projectnessie.cel/cel-core/0.4.3/ac8d857338264593c34f59bd2fb5423957bae597/cel-core-0.4.3.jar', 'META-INF/native-image/org.projectnessie.cel/cel-generated-pb/main/native-image.properties' in 'file:///home/dev/.gradle/caches/modules-2/files-2.1/org.projectnessie.cel/cel-generated-pb/0.4.3/171634232060585ce1ebd484043b309dde9799f9/cel-generated-pb-0.4.3.jar', 'META-INF/native-image/io.micrometer/micrometer-core/native-image.properties' in 'file:///home/dev/.gradle/caches/modules-2/files-2.1/io.micrometer/micrometer-core/1.11.5/d87189697cd35a09bcd8666c56b58ba39e9a5a3/micrometer-core-1.11.5.jar')
------------------------------------------------------------------------------------------------------------------------
Build resources:
 - 28.44GB of memory (45.3% of 62.78GB system memory, set via '-Xmx32G')
 - 16 thread(s) (100.0% of 16 available processor(s), determined at start)
Info: The percentage of matched entries from profile file(s): 95.67%.
[2/8] Performing analysis...  [*****]                                                                  (99.5s @ 11.30GB)
   69,004 reachable types   (93.3% of   73,994 total)
  111,672 reachable fields  (65.3% of  170,947 total)
  423,312 reachable methods (66.5% of  636,785 total)
   22,900 types, 4,255 fields, and 62,013 methods registered for reflection
      188 types,   235 fields, and   203 methods registered for JNI access
       0 foreign downcalls registered
        9 native libraries: dl, g1gc-musl-cr, m, pthread, rt, stdc++, z
[3/8] Building universe...                                                                             (15.2s @ 11.59GB)
[4/8] Parsing methods...      [***]                                                                      (6.0s @ 7.05GB)

Stacktrace

Fatal error: org.graalvm.compiler.debug.GraalError: java.lang.NullPointerException: Cannot invoke "org.graalvm.compiler.graph.NodeSourcePosition.spliterator()" because "<parameter1>" is null
        at method: void com.google.pubsub.v1.CloudStorageConfig$AvroConfig.writeTo(CodedOutputStream)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.code.CompileQueue.defaultParseFunction(CompileQueue.java:1081)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.code.CompileQueue.doParse(CompileQueue.java:991)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.code.CompileQueue$ParseTask.run(CompileQueue.java:354)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.executeCommand(CompletionExecutor.java:187)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.lambda$executeService$0(CompletionExecutor.java:171)
        at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1423)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
Caused by: java.lang.NullPointerException: Cannot invoke "org.graalvm.compiler.graph.NodeSourcePosition.spliterator()" because "<parameter1>" is null
        at com.oracle.svm.svm_enterprise/com.oracle.svm.enterprise.hosted.pgo.phases.PGOApplyProfilesPhase.a(stripped:196)
        at com.oracle.svm.svm_enterprise/com.oracle.svm.enterprise.hosted.pgo.phases.PGOApplyProfilesPhase.a(stripped:186)
        at com.oracle.svm.svm_enterprise/com.oracle.svm.enterprise.hosted.pgo.phases.PGOApplyProfilesPhase.c(stripped:109)
        at com.oracle.svm.svm_enterprise/com.oracle.svm.enterprise.hosted.pgo.phases.PGOApplyProfilesPhase.a(stripped:83)
        at com.oracle.svm.svm_enterprise/com.oracle.svm.enterprise.hosted.pgo.phases.PGOApplyProfilesPhase.a(stripped:90)
        at com.oracle.svm.svm_enterprise/com.oracle.svm.enterprise.hosted.pgo.phases.PGOApplyProfilesPhase.g(stripped:79)
        at com.oracle.svm.svm_enterprise/com.oracle.svm.enterprise.hosted.pgo.phases.PGOApplyProfilesPhase.a(stripped:71)
        at com.oracle.svm.svm_enterprise/com.oracle.svm.enterprise.hosted.pgo.phases.PGOApplyProfilesPhase.run(stripped:44)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:434)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:322)
        at com.oracle.svm.svm_enterprise/com.oracle.svm.enterprise.hosted.code.a.beforeEncode(stripped:241)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.code.CompileQueue.defaultParseFunction(CompileQueue.java:1072)
        ... 10 more
Fatal error: org.graalvm.compiler.debug.GraalError: java.lang.UnsupportedOperationException: null not supported as key!
        at method: CloudStorageConfig$Builder com.google.pubsub.v1.CloudStorageConfig$Builder.clearAvroConfig()
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.code.CompileQueue.defaultParseFunction(CompileQueue.java:1081)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.code.CompileQueue.doParse(CompileQueue.java:991)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.code.CompileQueue$ParseTask.run(CompileQueue.java:354)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.executeCommand(CompletionExecutor.java:187)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.lambda$executeService$0(CompletionExecutor.java:171)
        at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1423)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
Caused by: java.lang.UnsupportedOperationException: null not supported as key!
        at org.graalvm.collections/org.graalvm.collections.EconomicMapImpl.checkKeyNonNull(EconomicMapImpl.java:640)
        at org.graalvm.collections/org.graalvm.collections.EconomicMapImpl.put(EconomicMapImpl.java:422)
        at com.oracle.svm.svm_enterprise/com.oracle.svm.enterprise.hosted.profiling.phases.ProfilingInstrumentationPhase.a(stripped:154)
        at java.base/java.lang.Iterable.forEach(Iterable.java:75)
        at com.oracle.svm.svm_enterprise/com.oracle.svm.enterprise.hosted.profiling.phases.ProfilingInstrumentationPhase.c(stripped:146)
        at com.oracle.svm.svm_enterprise/com.oracle.svm.enterprise.hosted.profiling.phases.ProfilingInstrumentationPhase.o(stripped:109)
        at com.oracle.svm.svm_enterprise/com.oracle.svm.enterprise.hosted.pgo.phases.PGOApplyProfilesPhase.h(stripped:120)
        at com.oracle.svm.svm_enterprise/com.oracle.svm.enterprise.hosted.pgo.phases.PGOApplyProfilesPhase.a(stripped:72)
        at com.oracle.svm.svm_enterprise/com.oracle.svm.enterprise.hosted.pgo.phases.PGOApplyProfilesPhase.run(stripped:44)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:434)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:322)
        at com.oracle.svm.svm_enterprise/com.oracle.svm.enterprise.hosted.code.a.beforeEncode(stripped:241)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.code.CompileQueue.defaultParseFunction(CompileQueue.java:1072)
        ... 10 more
Fatal error: org.graalvm.compiler.debug.GraalError: java.lang.UnsupportedOperationException: null not supported as key!
        at method: CloudStorageConfig$Builder com.google.pubsub.v1.CloudStorageConfig$Builder.clear()
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.code.CompileQueue.defaultParseFunction(CompileQueue.java:1081)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.code.CompileQueue.doParse(CompileQueue.java:991)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.code.CompileQueue$ParseTask.run(CompileQueue.java:354)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.executeCommand(CompletionExecutor.java:187)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.lambda$executeService$0(CompletionExecutor.java:171)
        at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1423)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
Caused by: java.lang.UnsupportedOperationException: null not supported as key!
        at org.graalvm.collections/org.graalvm.collections.EconomicMapImpl.checkKeyNonNull(EconomicMapImpl.java:640)
        at org.graalvm.collections/org.graalvm.collections.EconomicMapImpl.put(EconomicMapImpl.java:422)
        at com.oracle.svm.svm_enterprise/com.oracle.svm.enterprise.hosted.profiling.phases.ProfilingInstrumentationPhase.a(stripped:154)
        at java.base/java.lang.Iterable.forEach(Iterable.java:75)
        at com.oracle.svm.svm_enterprise/com.oracle.svm.enterprise.hosted.profiling.phases.ProfilingInstrumentationPhase.c(stripped:146)
        at com.oracle.svm.svm_enterprise/com.oracle.svm.enterprise.hosted.profiling.phases.ProfilingInstrumentationPhase.o(stripped:109)
        at com.oracle.svm.svm_enterprise/com.oracle.svm.enterprise.hosted.pgo.phases.PGOApplyProfilesPhase.h(stripped:120)
        at com.oracle.svm.svm_enterprise/com.oracle.svm.enterprise.hosted.pgo.phases.PGOApplyProfilesPhase.a(stripped:72)
        at com.oracle.svm.svm_enterprise/com.oracle.svm.enterprise.hosted.pgo.phases.PGOApplyProfilesPhase.run(stripped:44)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:434)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:322)
        at com.oracle.svm.svm_enterprise/com.oracle.svm.enterprise.hosted.code.a.beforeEncode(stripped:241)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.code.CompileQueue.defaultParseFunction(CompileQueue.java:1072)
        ... 10 more
Fatal error: org.graalvm.compiler.debug.GraalError: java.lang.UnsupportedOperationException: null not supported as key!
        at method: CloudStorageConfig$Builder com.google.pubsub.v1.CloudStorageConfig$Builder.clearMaxDuration()
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.code.CompileQueue.defaultParseFunction(CompileQueue.java:1081)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.code.CompileQueue.doParse(CompileQueue.java:991)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.code.CompileQueue$ParseTask.run(CompileQueue.java:354)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.executeCommand(CompletionExecutor.java:187)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.lambda$executeService$0(CompletionExecutor.java:171)
        at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1423)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
Caused by: java.lang.UnsupportedOperationException: null not supported as key!
        at org.graalvm.collections/org.graalvm.collections.EconomicMapImpl.checkKeyNonNull(EconomicMapImpl.java:640)
        at org.graalvm.collections/org.graalvm.collections.EconomicMapImpl.put(EconomicMapImpl.java:422)
   ^C
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.lambda$executeService$0(CompletionExecutor.java:171)
        at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1423)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
fernando-valdez commented 8 months ago

Hello @sgammon, can you please share a reproducer so we can closely examine the issue?

kgonia commented 7 months ago

I got the same error when I manually set up the -O3 option (which is used by default with --pgo). Without explicitly setting -O3, everything works fine.