Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot build native executable with Epsilon GC (graalvmce-s2i, 22.3.0) #216

Closed
turbolocust opened this issue Nov 4, 2022 · 12 comments
Closed
Assignees

Comments

@turbolocust
Copy link

An exception is thrown and the build aborts, when building a native executable using the latest version of the ubi-quarkus-graalvmce-s2i image for the amd64 architecture, which currently is 22.3.0. Using version 22.2.0 of the image, the build succeeds.

The exact error message is:
Error: ImageSingletons do not contain key com.oracle.svm.core.heap.Heap

I specify the following parameter when building the executable via Gradle:
-Dquarkus.native.additional-build-args="--gc=epsilon"

And here is the stack trace:

07:37:32  [1/7] Initializing...                                                                                    (0.0s @ 0.27GB)
07:37:32  ------------------------------------------------------------------------------------------------------------------------
07:37:32  Error: ImageSingletons do not contain key com.oracle.svm.core.heap.Heap
07:37:32  com.oracle.svm.core.util.UserError$UserException: ImageSingletons do not contain key com.oracle.svm.core.heap.Heap
07:37:32  	at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.UserError.abort(UserError.java:73)
07:37:32  	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.ImageSingletonsSupportImpl$HostedManagement.doLookup(ImageSingletonsSupportImpl.java:117)
07:37:32  	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.ImageSingletonsSupportImpl.lookup(ImageSingletonsSupportImpl.java:44)
07:37:32                           0.6s (7.8% of total time) in 8 GCs | Peak RSS: 0.64GB | CPU load: 1.74
07:37:32  ========================================================================================================================
07:37:32  Failed generating 'runner' after 7.3s.
07:37:32  	at org.graalvm.sdk/org.graalvm.nativeimage.ImageSingletons.lookup(ImageSingletons.java:86)
07:37:32  	at org.graalvm.nativeimage.builder/com.oracle.svm.core.heap.Heap.getHeap(Heap.java:51)
07:37:32  	at org.graalvm.nativeimage.builder/com.oracle.svm.core.genscavenge.SerialGCOptions.serialGCOnly(SerialGCOptions.java:113)
07:37:32  	at org.graalvm.nativeimage.builder/com.oracle.svm.core.option.HostedOptionKey.validate(HostedOptionKey.java:103)
07:37:32  	at org.graalvm.nativeimage.builder/com.oracle.svm.core.option.ValidateImageBuildOptionsFeature.validate(ValidateImageBuildOptionsFeature.java:52)
07:37:32  	at org.graalvm.nativeimage.builder/com.oracle.svm.core.option.ValidateImageBuildOptionsFeature.afterRegistration(ValidateImageBuildOptionsFeature.java:44)
07:37:32  	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.lambda$setupNativeImage$14(NativeImageGenerator.java:854)
07:37:32  	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:85)
07:37:32  	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.setupNativeImage(NativeImageGenerator.java:854)
07:37:32  	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:575)
07:37:32  	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:535)
07:37:32  	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:403)
07:37:32  	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:580)
07:37:32  	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:128)
07:37:32  Error: Image build request failed with exit status 1
07:37:32  
07:37:32  
07:37:32  FAILURE: Build failed with an exception.
07:37:32  
07:37:32  * What went wrong:
07:37:32  Execution failed for task ':quarkusBuild'.
07:37:32  > io.quarkus.builder.BuildException: Build failure: Build failed due to errors
07:37:32    	[error]: Build step io.quarkus.deployment.pkg.steps.NativeImageBuildStep#build threw an exception: io.quarkus.deployment.pkg.steps.NativeImageBuildStep$ImageGenerationFailureException: Image generation failed. Exit code: 1
07:37:32    	at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.imageGenerationFailed(NativeImageBuildStep.java:417)
07:37:32    	at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:258)
07:37:32    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
07:37:32    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
07:37:32    	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
07:37:32    	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
07:37:32    	at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:909)
07:37:32    	at io.quarkus.builder.BuildContext.run(BuildContext.java:281)
07:37:32    	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
07:37:32    	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
07:37:32    	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
07:37:32    	at java.base/java.lang.Thread.run(Thread.java:833)
07:37:32    	at org.jboss.threads.JBossThread.run(JBossThread.java:501)
@zakkak
Copy link
Collaborator

zakkak commented Nov 4, 2022

@turbolocust can you please provide more info?

Is this reproducible with a simple HelloWorld?
If so, have you tried using GraalVM with epsilongc outside of Quarkus to see if the issue is present there as well?

Thanks

@galderz
Copy link
Member

galderz commented Nov 7, 2022

Something's probably not right with the builder image itself. I've been able to replicate it with (full console log here):

./mvnw install -Dnative -DskipTests -Dquarkus.native.container-build=true -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-graalvmce-builder-image:22.3-java17 -Dquarkus.native.additional-build-args=--gc=epsilon
...
com.oracle.svm.core.util.UserError$UserException: ImageSingletons do not contain key com.oracle.svm.core.heap.Heap

@galderz
Copy link
Member

galderz commented Nov 11, 2022

Hmm, the issue is not specific to the container image. It also happens when building native executable (at least Quakus) bare metal:

$ export JAVA_HOME=/opt/graalvm-ce-java17-22.3.0/Contents/Home
$ ./mvnw package -Dnative -DskipTests -Dquarkus.native.additional-build-args=--gc=epsilon

Error: ImageSingletons do not contain key com.oracle.svm.core.heap.Heap
com.oracle.svm.core.util.UserError$UserException: ImageSingletons do not contain key com.oracle.svm.core.heap.Heap
	at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.UserError.abort(UserError.java:73)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.ImageSingletonsSupportImpl$HostedManagement.doLookup(ImageSingletonsSupportImpl.java:117)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.ImageSingletonsSupportImpl.lookup(ImageSingletonsSupportImpl.java:44)
	at org.graalvm.sdk/org.graalvm.nativeimage.ImageSingletons.lookup(ImageSingletons.java:86)
	at org.graalvm.nativeimage.builder/com.oracle.svm.core.heap.Heap.getHeap(Heap.java:51)
	at org.graalvm.nativeimage.builder/com.oracle.svm.core.genscavenge.SerialGCOptions.serialGCOnly(SerialGCOptions.java:113)
	at org.graalvm.nativeimage.builder/com.oracle.svm.core.option.HostedOptionKey.validate(HostedOptionKey.java:103)
	at org.graalvm.nativeimage.builder/com.oracle.svm.core.option.ValidateImageBuildOptionsFeature.validate(ValidateImageBuildOptionsFeature.java:52)
	at org.graalvm.nativeimage.builder/com.oracle.svm.core.option.ValidateImageBuildOptionsFeature.afterRegistration(ValidateImageBuildOptionsFeature.java:44)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.lambda$setupNativeImage$14(NativeImageGenerator.java:854)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:85)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.setupNativeImage(NativeImageGenerator.java:854)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:575)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:535)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:403)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:580)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:128)

Once I figured the exact circumstances I'll close this and open a new issue in either quarkus or oracle/graal, depending who's the culprit.

@galderz
Copy link
Member

galderz commented Nov 11, 2022

@turbolocust Can you try with the latest Quarkus 2.14.0? I cannot reproduce the issue any more with that version. I was able to reproduce it with 2.13.3.

@turbolocust
Copy link
Author

@turbolocust Can you try with the latest Quarkus 2.14.0? I cannot reproduce the issue any more with that version. I was able to reproduce it with 2.13.3.

I can confirm that the issue is gone with 2.14.0.Final.

@zakkak
Copy link
Collaborator

zakkak commented Nov 11, 2022

I can confirm that the issue is gone with 2.14.0.Final.

Now I am curious... (but I also have a hint to why I might have not been able to reproduce :) )

@galderz
Copy link
Member

galderz commented Nov 15, 2022

So let's close this issue @turbolocust @cescoffier?

@zakkak
Copy link
Collaborator

zakkak commented Nov 15, 2022

Please leave this open as it affects 2.13.

The issue is actually caused because 2.13 unconditionally passes -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy$BySpaceAndTime to native-image and this option is only available when using the SerialGC.

In 2.13 it is "fixed" by quarkusio/quarkus#28295.

@zakkak
Copy link
Collaborator

zakkak commented Nov 15, 2022

Please leave this open as it affects 2.13.

On second thought, I am moving this to the Quarkus repository: quarkusio/quarkus#29275

@cescoffier @turbolocust feel free to close this.

@turbolocust
Copy link
Author

@zakkak Thank you for the update. I'll close the issue.

@galderz
Copy link
Member

galderz commented Nov 16, 2022

Nice dig @zakkak. Quarkus had been using space/time for quite a while. Strange that we've only discovered this now. I had not tried epsilon GC previously but I know others that had done and had no issues. So maybe there's an extra rationale why this has popped up now.

@zakkak
Copy link
Collaborator

zakkak commented Nov 16, 2022

Yes, the check that causes the crash (see oracle/graal#5432) is pretty recent (see oracle/graal@5c4daf5#diff-e651863ba7c44a01ff26ffb9cf23c04c08d9f68f21a6c3bcc0d5e026fa74a77d)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants