quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.73k stars 2.67k forks source link

Native image build fails with `VMError$HostedError: Boolean option value can be only + or -` #36684

Closed brunobat closed 11 months ago

brunobat commented 12 months ago

Describe the bug

Build fails with cryptic message and not allowing further actions from the user: https://github.com/quarkiverse/quarkus-opentelemetry-exporter/actions/runs/6629170891/job/18007855740?pr=104

Fatal error: org.graalvm.compiler.debug.GraalError: com.oracle.svm.core.util.VMError$HostedError: Boolean option value can be only + or -
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.AnalysisFuture.setException(AnalysisFuture.java:49)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:322)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.AnalysisFuture.ensureDone(AnalysisFuture.java:63)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.heap.ImageHeapInstance.readFieldValue(ImageHeapInstance.java:110)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.heap.ImageHeapScanner.onObjectReachable(ImageHeapScanner.java:472)
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.heap.SVMImageHeapScanner.onObjectReachable(SVMImageHeapScanner.java:156)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.heap.ImageHeapScanner.lambda$markReachable$5(ImageHeapScanner.java:452)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.heap.ImageHeapScanner.lambda$postTask$14(ImageHeapScanner.java:695)
    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: com.oracle.svm.core.util.VMError$HostedError: Boolean option value can be only + or -
    at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:78)

Also discussed here: https://quarkusio.zulipchat.com/#narrow/stream/187038-dev/topic/GraalVM.20error/near/398318139

Expected behavior

According to @zakkak the message should be:

If you are seeing this message after enabling %s, this means that some objects ended up in the image heap without their type being marked with --initialize-at-build-time.
                                To fix this, include %s in your configuration. If the classes do not originate from your code, it is advised to update all library or framework dependencies to the latest version before addressing this error.
                                Please address this problem to be prepared for future releases of GraalVM.

Actual behavior

build fails with cryptic message

How to Reproduce?

Build this PR with graalvm 21

Output of uname -a or ver

No response

Output of java -version

Java version: 21+35-LTS, vendor version: Mandrel-23.1.0.0-Final

Quarkus version or git rev

At least Quarkus 3.5.0

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

See Quarkiverse CI: https://github.com/quarkiverse/quarkus-opentelemetry-exporter/actions/runs/6639560552/job/18038172666?pr=104

quarkus-bot[bot] commented 12 months ago

You added a link to a Zulip discussion, please make sure the description of the issue is comprehensive and doesn't require accessing Zulip

This message is automatically generated by a bot.

quarkus-bot[bot] commented 12 months ago

/cc @Karm (mandrel), @galderz (mandrel), @zakkak (mandrel)

zakkak commented 12 months ago

This is fixed upstream with https://github.com/oracle/graal/commit/a28e62958997968f92bc07b4e7a72a4992ce20d1, the fix is included in GraalVM for 21.0.1 (GraalVM 23.1.1) and will be part of Mandrel 23.1.1.0-Final which is expected to land in the following days.

Leaving the issue open till the Mandrel release becomes available and the quarkus-images get updated.

Thanks for the report @brunobat

brunobat commented 12 months ago

Good to hear we will get the fix soon. Thanks @zakkak !

zakkak commented 11 months ago

@brunobat the aforementioned releases are now available and the updated Mandrel images are now available in quay.io, could you please try and see if they resolve the issue?

Please make sure to pull the latest jdk-21 image (Quarkus should automatically do it for you).

brunobat commented 11 months ago

Thanks @zakkak. Now with Java version: 21.0.1+12-LTS, vendor version: Mandrel-23.1.1.0-Final I get a different error: https://github.com/quarkiverse/quarkus-opentelemetry-exporter/actions/runs/6639560552/job/18176638457 Not sure if it's best than before.

zakkak commented 11 months ago

@brunobat that's a known upstream GraalVM bug. You should upgrade to a newer (>= 2.25.0) gax-grpc version which includes https://github.com/googleapis/sdk-platform-java/pull/1892.

brunobat commented 11 months ago

Still no luck after upgrading. A strange thing is happening, though.

I get different errors depending on the graallvm being used. Locally, with Java version: 21.0.1+12, vendor version: Oracle GraalVM 21.0.1+12.1I get:

com.oracle.svm.core.util.VMError$HostedError: InternalFeature defined by com.oracle.svm.hosted.ReachabilityHandlerFeature unexpectedly failed with a(n) java.lang.NullPointerException

In the CI, with 21.0.1+12-LTS, vendor version: Mandrel-23.1.1.0-Final I get:

...
If it is intended that objects of type 'io.grpc.netty.shaded.io.grpc.netty.UdsNameResolverProvider' are persisted in the image heap, add

    '--initialize-at-build-time=io.grpc.netty.shaded.io.grpc.netty.UdsNameResolverProvider'
...

FYI, I added I've added this code to one of the processors:

  NativeImageConfigBuildItem.Builder builder = NativeImageConfigBuildItem.builder()
...
                .addRuntimeReinitializedClass("io.grpc.netty.shaded.io.grpc.netty.UdsNameResolverProvider");
...
zakkak commented 11 months ago

Locally, with Java version: 21.0.1+12, vendor version: Oracle GraalVM 21.0.1+12.1I get:

Do you get the same error with GraalVM CE 21.0.1? If not, it might be an Oracle GraalVM specific issue.

Still no luck after upgrading.

I suggest closing this issues as fixed (since the initial error no longer appears with the latest GraalVM and Mandrel) and opening a new issue for the new error including the full log, I guess the reproducer is the same?

brunobat commented 11 months ago

Looks good to me.