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

Native image build failures on latest GraalVM with Random/SplittableRandom initialized at build time #14904

Closed
zakkak opened this issue Feb 8, 2021 · 49 comments
Labels
area/native-image kind/bug Something isn't working
Milestone

Comments

@zakkak
Copy link
Contributor

zakkak commented Feb 8, 2021

Describe the bug
Quarkus TS fail with latest Graal (see https://github.com/oracle/graal/actions/runs/546718036)

In the upcoming release of GraalVM (21.1) instances of Random/SplittableRandom class won't be allowed in the native image heap. The corresponding patch can be seen here.

As a result, moving forward Quarkus needs to ensure that its core and extensions reinitialize any classes holding instances of Random/SplittableRandom class.

In order to find out which classes to reinitialize one needs to run:

./mvnw verify \
  -Dnative \
  -Dquarkus.native.additional-build-args="--trace-object-instantiation=java.security.SecureRandom" \
  -pl integration-tests/main

This will print out something like this:

Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Detected an instance of Random/SplittableRandom class in the image heap. Instances created during image generation have cached seed values and don't behave as expected.  Object has been initialized by the org.apache.http.impl.auth.NTLMEngineImpl class initializer with a trace: 
        at java.security.SecureRandom.<init>(SecureRandom.java:323)
        at java.security.SecureRandom.getInstance(SecureRandom.java:383)
        at org.apache.http.impl.auth.NTLMEngineImpl.<clinit>(NTLMEngineImpl.java:103)
. Try avoiding to initialize the class that caused initialization of the object. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image runtime by using the option --initialize-at-run-time=<class-name>. Or you can write your own initialization methods and call them explicitly from your main entry point.
Detailed message:
Trace: 
        at parsing org.apache.http.impl.auth.NTLMEngineImpl.access$000(NTLMEngineImpl.java:51)
Call path from entry point to org.apache.http.impl.auth.NTLMEngineImpl.access$000(): 
        at org.apache.http.impl.auth.NTLMEngineImpl.access$000(NTLMEngineImpl.java:51)
        at org.apache.http.impl.auth.NTLMEngineImpl$Type3Message.<init>(NTLMEngineImpl.java:1505)
        at org.apache.http.impl.auth.NTLMEngineImpl$Type3Message.<init>(NTLMEngineImpl.java:1474)
        at org.apache.http.impl.auth.NTLMEngineImpl.getType3Message(NTLMEngineImpl.java:181)
        at org.apache.http.impl.auth.NTLMEngineImpl.generateType3Msg(NTLMEngineImpl.java:2097)
        at org.apache.http.impl.auth.NTLMScheme.authenticate(NTLMScheme.java:142)
        at org.apache.http.impl.auth.AuthSchemeBase.authenticate(AuthSchemeBase.java:136)
        at org.apache.http.impl.auth.HttpAuthenticator.doAuth(HttpAuthenticator.java:233)
        at org.apache.http.impl.auth.HttpAuthenticator.generateAuthResponse(HttpAuthenticator.java:213)
        at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:262)
        at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
        at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
        at org.jboss.resteasy.client.jaxrs.engines.ManualClosingApacheHttpClient43Engine.invoke(ManualClosingApacheHttpClient43Engine.java:268)
        at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.invoke(ClientInvocation.java:488)
        at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.lambda$executorSubmit$11(ClientInvocation.java:770)
        at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation$$Lambda$2014/0x00000007c4cd7840.get(Unknown Source)
        at com.oracle.svm.core.jdk.SystemPropertiesSupport.initializeLazyValue(SystemPropertiesSupport.java:211)
        at com.oracle.svm.core.jdk.SystemPropertiesSupport.getProperty(SystemPropertiesSupport.java:164)
        at com.oracle.svm.core.jdk.Target_java_lang_System.getProperty(JavaLangSubstitutions.java:293)
        at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_VA_LIST:Ljava_lang_System_2_0002egetProperty_00028Ljava_lang_String_2_00029Ljava_lang_String_2(generated:0)

Which indicates that Quarkus should reinitialize NTLMEngineImpl at runtime.

Expected behavior
Tests should pass (at least most of them)

Actual behavior
Multiple integration tests fail.

  • Main
  • Hibernate Tenancy
  • Flyway
  • Redis Client
  • Hibernate Search ORM + Elasticsearch
  • Elasticsearch REST client
  • Elasticsearch REST high level client
  • Bouncy Castle
  • Bouncy Castle FIPS
  • Bouncy Castle JSSE
  • Elytron Security LDAP
  • more...
    fail with:
Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Detected an instance of Random/SplittableRandom class in the image heap. Instances created during image generation have cached seed values and don't behave as expected.  To see how this object got instantiated use --trace-object-instantiation=java.security.SecureRandom. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image runtime by using the option --initialize-at-run-time=<class-name>. Or you can write your own initialization methods and call them explicitly from your main entry point.

To Reproduce

  1. Build GraalVM master with:
    mx --primary-suite-path substratevm --components='Native Image' build
  2. export GRAALVM_HOME=/path/to/graal/sdk/latest_graalvm_home
  3. ./mvnw clean verify -Dnative -Dnative.surefire.skip -pl integration-tests/main

Environment (please complete the following information):

  • Output of uname -a or ver: Linux 5.10.10-200.fc33.x86_64
  • Output of java -version: 11.0.9+10-jvmci-21.0-b03
  • GraalVM version (if different from Java): Graal master ca436f5a8d260027da4218761ee1b83a4d0b4a0f
  • Quarkus version or git rev: Quarkus master dac8d8b
  • Build tool (ie. output of mvnw --version or gradlew --version): Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
@jerboaa
Copy link
Contributor

jerboaa commented Mar 18, 2021

For reference, instead of building Graal VM master from source, one could also use 21.1 dev builds from:
https://github.com/graalvm/graalvm-ce-dev-builds/releases in order to reproduce those failures.

@jerboaa
Copy link
Contributor

jerboaa commented Mar 18, 2021

PR for solving the runtime-init problem for modules using http-client (includes integration-test/main): #15856

@jerboaa
Copy link
Contributor

jerboaa commented Mar 18, 2021

PR for integration-tests/redis-client: #15864

@jerboaa
Copy link
Contributor

jerboaa commented Mar 19, 2021

PR for integration-tests/reactive-messaging-kafka: #15879

@galderz
Copy link
Member

galderz commented Mar 19, 2021

I've created #15889 to track the quarkus-integration-test-bouncycastle-fips failures. It needs some consideration and agreement on the solution.

@jerboaa
Copy link
Contributor

jerboaa commented Mar 19, 2021

Elytron Security LDAP is actually a Graal issue:
oracle/graal#3297

@jerboaa
Copy link
Contributor

jerboaa commented Mar 19, 2021

PR for integration-tests/amazon-services: #15897

@jerboaa
Copy link
Contributor

jerboaa commented Mar 23, 2021

PR for integration-tests/artemis-core and integration-tests/artemis-jms: #15952

@jerboaa
Copy link
Contributor

jerboaa commented Mar 23, 2021

At this point most of the Random/SplittableRandom related failures should be fixed. I haven't done a full run, but it would be good to get one done with quarkus master to see what's still left. @zakkak could you help with that?

@zakkak
Copy link
Contributor Author

zakkak commented Mar 23, 2021

@zakkak could you help with that?

Sure, I started https://github.com/zakkak/graalvm-quarkus-ci/actions/runs/681073992 to test latest Quarkus with latest GraalVM.

@jerboaa
Copy link
Contributor

jerboaa commented Mar 24, 2021

@zakkak Thanks. In the spirit of teach a man to fish, what would be the steps to do this myself? Anyway, most issues are now #15962 which is unfortunate since we still have lots of noise :(

@zakkak
Copy link
Contributor Author

zakkak commented Mar 24, 2021

@zakkak Thanks. In the spirit of teach a man to fish, what would be the steps to do this myself?

In that case I just copied the GH workflow from oracle/graal to a new repo (zakkak/graalvm-quarkus-ci) and slightly edited it to use the latest dev branch of both graalvm and quarkus (the original workflow is using the latest release of quarkus with the latest dev branch of graalvm).

I also made it possible to trigger the workflow on demand with different combinations of versions and repos as well. It would be nice to have the option to use forked repos as well to try out PRs as well.
image
I probably need to give you (and anyone interested in running this kind of tests) some access rights to the repo.

Anyway, most issues are now #15962 which is unfortunate since we still have lots of noise :(

True, #15962 seems to be something new though , so I'll try to schedule a run with an older version to see how far we have gone with the Random/SplittableRandom related failures. I started a new workflow to test @geoand 's fix for #15962 with latest graalvm: https://github.com/zakkak/graalvm-quarkus-ci/actions/runs/683208450

@jerboaa
Copy link
Contributor

jerboaa commented Mar 24, 2021

@zakkak Thanks for the info!

@zakkak
Copy link
Contributor Author

zakkak commented Mar 24, 2021

Job for latest Quarkus vs latest Graal now that #15962 is fixed:
https://github.com/zakkak/graalvm-quarkus-ci/actions/runs/683707199

@geoand
Copy link
Contributor

geoand commented Mar 24, 2021

👍🏼

@jerboaa
Copy link
Contributor

jerboaa commented Mar 24, 2021

Job for latest Quarkus vs latest Graal now that #15962 is fixed:
https://github.com/zakkak/graalvm-quarkus-ci/actions/runs/683707199

Now that looks a lot better already! Thank you.

@zakkak
Copy link
Contributor Author

zakkak commented Mar 24, 2021

I list below the ITs that are still failing (based on https://github.com/zakkak/graalvm-quarkus-ci/actions/runs/683707199)

Random/SplitRandom related

  1. Bouncy Castle FIPS
  2. Elytron Security LDAP
  3. JGit
  4. Spring Data JPA
  5. gRPC - TLS
  6. gRPC - Plain Text with gzip compression
  7. gRPC - Plain Text with Mutiny
  8. gRPC - TLS with mutual auth
  9. gRPC - Interceptors
  10. gRPC - Proto v2

Other

  1. Bouncy Castle JSEE
    Compiles but fails with:
java.lang.NoSuchMethodException: org.bouncycastle.jcajce.provider.drbg.DRBG$Default.<init>(java.security.SecureRandomParameters)
  1. Kafka with Snappy
    Compiles but fails with:
 ERROR: Failed to start application (with profile prod)
org.xerial.snappy.SnappyError: [FAILED_TO_LOAD_NATIVE_LIBRARY] no native library is found for os.name=Linux and os.arch=x86_64
	at io.quarkus.kafka.client.runtime.KafkaRecorder.loadSnappy(KafkaRecorder.java:39)
	at io.quarkus.deployment.steps.KafkaProcessor$loadSnappyIfEnabled1534179476.deploy_0(KafkaProcessor$loadSnappyIfEnabled1534179476.zig:67)
	at io.quarkus.deployment.steps.KafkaProcessor$loadSnappyIfEnabled1534179476.deploy(KafkaProcessor$loadSnappyIfEnabled1534179476.zig:40)
	at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:400)
	at io.quarkus.runtime.Application.start(Application.java:90)
	at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:100)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:66)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:42)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:119)
	at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29)

@zakkak
Copy link
Contributor Author

zakkak commented Mar 25, 2021

PR for gRPC* tests #16008

Sgitario added a commit to Sgitario/quarkus-startstop that referenced this issue May 5, 2021
Backport of quarkus-qe#75.
Won't run Native as it's not working on 1.11 due to quarkusio/quarkus#14904
Sgitario added a commit to Sgitario/quarkus-startstop that referenced this issue May 10, 2021
Backport of quarkus-qe#75.
Won't run Native as it's not working on 1.11 due to quarkusio/quarkus#14904
rsvoboda pushed a commit to quarkus-qe/quarkus-startstop that referenced this issue May 11, 2021
Backport of #75.
Won't run Native as it's not working on 1.11 due to quarkusio/quarkus#14904
@akuzni2
Copy link

akuzni2 commented May 29, 2021

I'm getting this error when converting one of my applications to Quarkus to build a native-image using GraalVM 21.1.0. From this thread I can't really tell what I need to do to get around it.

I'm building my quarkus project with Quarkus 1.13.4.Final

@galderz
Copy link
Member

galderz commented Jun 14, 2021

@akuzni2 I might be wrong but I think 21.1 is only supported in Quarkus 2.x onwards...

@zakkak
Copy link
Contributor Author

zakkak commented Jun 14, 2021

@akuzni2 I might be wrong but I think 21.1 is only supported in Quarkus 2.x onwards...

That's correct,

Quarkus version Compatible GraalVM/Mandrel version
1.12.x 21.0.x.x
1.13.x 20.3.x.x
21.0.x.x
2.0.x 20.3.x.x
21.1.x.x

source: https://github.com/graalvm/mandrel/wiki

@dufoli
Copy link
Contributor

dufoli commented Jun 24, 2021

hello,

I have same issue on cxf extension.
quarkiverse/quarkus-cxf#253
it failed with exception.
Can you help with that because I am not sure.
Do I need to switch to runtime initialization for some class :
org.apache.cxf.endpoint.ClientImpl

Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Detected an instance of Random/SplittableRandom class in the image heap. Instances created during image generation have cached seed values and don't behave as expected. To see how this object got instantiated use --trace-object-instantiation=java.util.Random. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image runtime by using the option --initialize-at-run-time=. Or you can write your own initialization methods and call them explicitly from your main entry point.
Detailed message:
Trace:
at parsing org.apache.cxf.attachment.AttachmentUtil.getUniqueBoundaryValue(AttachmentUtil.java:255)
Call path from entry point to org.apache.cxf.attachment.AttachmentUtil.getUniqueBoundaryValue():
at org.apache.cxf.attachment.AttachmentUtil.getUniqueBoundaryValue(AttachmentUtil.java:255)
at org.apache.cxf.attachment.AttachmentSerializer.writeProlog(AttachmentSerializer.java:82)
at org.apache.cxf.interceptor.AttachmentOutInterceptor.handleMessage(AttachmentOutInterceptor.java:91)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:831)
at org.apache.cxf.endpoint.ClientImpl$3$1.run(ClientImpl.java:923)
at java.lang.Thread.run(Thread.java:829)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:553)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
at com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(generated:0)

com.oracle.svm.core.util.UserError$UserException: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Detected an instance of Random/SplittableRandom class in the image heap. Instances created during image generation have cached seed values and don't behave as expected. To see how this object got instantiated use --trace-object-instantiation=java.util.Random. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image runtime by using the option --initialize-at-run-time=. Or you can write your own initialization methods and call them explicitly from your main entry point.
Detailed message:
Trace:
at parsing org.apache.cxf.attachment.AttachmentUtil.getUniqueBoundaryValue(AttachmentUtil.java:255)
Call path from entry point to org.apache.cxf.attachment.AttachmentUtil.getUniqueBoundaryValue():
at org.apache.cxf.attachment.AttachmentUtil.getUniqueBoundaryValue(AttachmentUtil.java:255)
at org.apache.cxf.attachment.AttachmentSerializer.writeProlog(AttachmentSerializer.java:82)
at org.apache.cxf.interceptor.AttachmentOutInterceptor.handleMessage(AttachmentOutInterceptor.java:91)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:831)
at org.apache.cxf.endpoint.ClientImpl$3$1.run(ClientImpl.java:923)
at java.lang.Thread.run(Thread.java:829)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:553)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
at com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(generated:0)

at com.oracle.svm.core.util.UserError.abort(UserError.java:82)
at com.oracle.svm.hosted.FallbackFeature.reportAsFallback(FallbackFeature.java:233)
at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:798)
at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:582)
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)
Caused by: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Detected an instance of Random/SplittableRandom class in the image heap. Instances created during image generation have cached seed values and don't behave as expected. To see how this object got instantiated use --trace-object-instantiation=java.util.Random. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image runtime by using the option --initialize-at-run-time=. Or you can write your own initialization methods and call them explicitly from your main entry point.
Detailed message:
Trace:
at parsing org.apache.cxf.attachment.AttachmentUtil.getUniqueBoundaryValue(AttachmentUtil.java:255)
Call path from entry point to org.apache.cxf.attachment.AttachmentUtil.getUniqueBoundaryValue():
at org.apache.cxf.attachment.AttachmentUtil.getUniqueBoundaryValue(AttachmentUtil.java:255)
at org.apache.cxf.attachment.AttachmentSerializer.writeProlog(AttachmentSerializer.java:82)
at org.apache.cxf.interceptor.AttachmentOutInterceptor.handleMessage(AttachmentOutInterceptor.java:91)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:831)
at org.apache.cxf.endpoint.ClientImpl$3$1.run(ClientImpl.java:923)
at java.lang.Thread.run(Thread.java:829)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:553)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
at com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(generated:0)

at com.oracle.graal.pointsto.constraints.UnsupportedFeatures.report(UnsupportedFeatures.java:126)
at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:795)
... 8 more
Caused by: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Detected an instance of Random/SplittableRandom class in the image heap. Instances created during image generation have cached seed values and don't behave as expected. To see how this object got instantiated use --trace-object-instantiation=java.util.Random. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image runtime by using the option --initialize-at-run-time=. Or you can write your own initialization methods and call them explicitly from your main entry point.
at com.oracle.svm.hosted.image.DisallowedImageHeapObjectFeature.error(DisallowedImageHeapObjectFeature.java:163)
at com.oracle.svm.core.image.DisallowedImageHeapObjects.check(DisallowedImageHeapObjects.java:65)
at com.oracle.svm.hosted.image.DisallowedImageHeapObjectFeature.replacer(DisallowedImageHeapObjectFeature.java:139)
at com.oracle.graal.pointsto.meta.AnalysisUniverse.replaceObject(AnalysisUniverse.java:565)
at com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider.replaceObject(AnalysisConstantReflectionProvider.java:213)
at com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider.interceptValue(AnalysisConstantReflectionProvider.java:184)
at com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider.readValue(AnalysisConstantReflectionProvider.java:98)
at com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider.readFieldValue(AnalysisConstantReflectionProvider.java:77)
at jdk.internal.vm.compiler/org.graalvm.compiler.nodes.util.ConstantFoldUtil$1.readValue(ConstantFoldUtil.java:51)
at jdk.internal.vm.compiler/org.graalvm.compiler.core.common.spi.JavaConstantFieldProvider.readConstantField(JavaConstantFieldProvider.java:84)
at com.oracle.svm.hosted.ameta.AnalysisConstantFieldProvider.readConstantField(AnalysisConstantFieldProvider.java:70)
at jdk.internal.vm.compiler/org.graalvm.compiler.nodes.util.ConstantFoldUtil.tryConstantFold(ConstantFoldUtil.java:47)
at com.oracle.svm.hosted.phases.ConstantFoldLoadFieldPlugin.tryConstantFold(ConstantFoldLoadFieldPlugin.java:61)
at com.oracle.svm.hosted.phases.ConstantFoldLoadFieldPlugin.handleLoadStaticField(ConstantFoldLoadFieldPlugin.java:57)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genGetStatic(BytecodeParser.java:4972)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genGetStatic(BytecodeParser.java:4939)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBytecode(BytecodeParser.java:5442)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3451)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:3258)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.build(BytecodeParser.java:1125)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.buildRootMethod(BytecodeParser.java:1019)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.GraphBuilderPhase$Instance.run(GraphBuilderPhase.java:84)
at com.oracle.svm.hosted.phases.SharedGraphBuilderPhase.run(SharedGraphBuilderPhase.java:76)
at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.run(Phase.java:49)
at jdk.internal.vm.compiler/org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:212)
at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:42)
at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:38)
at com.oracle.graal.pointsto.flow.AnalysisParsedGraph.parseBytecode(AnalysisParsedGraph.java:113)
at com.oracle.svm.hosted.SVMHost.parseBytecode(SVMHost.java:647)
at com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsed(AnalysisMethod.java:592)
at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:163)
at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:304)
at com.oracle.graal.pointsto.flow.MethodTypeFlow.createTypeFlow(MethodTypeFlow.java:313)
at com.oracle.graal.pointsto.flow.MethodTypeFlow.ensureTypeFlowCreated(MethodTypeFlow.java:302)
at com.oracle.graal.pointsto.flow.MethodTypeFlow.addContext(MethodTypeFlow.java:103)
at com.oracle.graal.pointsto.flow.StaticInvokeTypeFlow.update(InvokeTypeFlow.java:420)
at com.oracle.graal.pointsto.BigBang$2.run(BigBang.java:547)
at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$execute$0(CompletionExecutor.java:173)
at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)

@zakkak
Copy link
Contributor Author

zakkak commented Jun 28, 2021

Hi @dufoli, my understanding is that quarkiverse/quarkus-cxf@8804dda fixed the above issue, is that right?

@dufoli
Copy link
Contributor

dufoli commented Jun 28, 2021

@zakkak yes

@akuzni2
Copy link

akuzni2 commented Jun 28, 2021

HI @zakkak @dufoli thanks for commenting back. I've upgraded to Quarkus 2.0.0 and I still see the same issue cause by some AWS dependencies.

Error: Detected an instance of Random/SplittableRandom class in the image heap. Instances created during image generation have cached seed values and don't behave as expected.  To see how this object got instantiated use --trace-object-instantiation=java.util.Random. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image runtime by using the option --initialize-at-run-time=<class-name>. Or you can write your own initialization methods and call them explicitly from your main entry point.
Trace: Object was reached by 
        reading field com.amazonaws.retry.PredefinedBackoffStrategies$EqualJitterBackoffStrategy.random of
                constant com.amazonaws.retry.PredefinedBackoffStrategies$EqualJitterBackoffStrategy@546fe072 reached by 
        reading field com.amazonaws.retry.PredefinedBackoffStrategies$SDKDefaultBackoffStrategy.equalJitterBackoffStrategy of
                constant com.amazonaws.retry.PredefinedBackoffStrategies$SDKDefaultBackoffStrategy@4d11ec9e reached by 
        reading field com.amazonaws.retry.RetryPolicy.backoffStrategy of
                constant com.amazonaws.retry.RetryPolicy@28b37dae reached by 
        scanning method com.amazonaws.ClientConfiguration.<init>(ClientConfiguration.java:155)
Call path from entry point to com.amazonaws.ClientConfiguration.<init>(ClientConfiguration): 
        at com.amazonaws.ClientConfiguration.<init>(ClientConfiguration.java:378)
        at com.amazonaws.client.builder.AwsClientBuilder.resolveClientConfiguration(AwsClientBuilder.java:169)
        at com.amazonaws.client.builder.AwsClientBuilder.access$000(AwsClientBuilder.java:54)
        at com.amazonaws.client.builder.AwsClientBuilder$SyncBuilderParams.<init>(AwsClientBuilder.java:505)
        at com.amazonaws.client.builder.AwsClientBuilder.getSyncClientParams(AwsClientBuilder.java:441)
        at com.amazonaws.client.builder.AwsSyncClientBuilder.build(AwsSyncClientBuilder.java:46)
        at com.mycompany.service.ApiServiceImpl.<init>(ApiServiceImpl.java:23)
        at com.mycompany.service.ProcessingService.<init>(ProcessingService.java:22)
        at com.mycompany.service.ProcessingService_Bean.create(ProcessingService_Bean.zig:140)
        at com.mycompany.service.ProcessingService_Bean.create(ProcessingService_Bean.zig:155)
        at io.quarkus.arc.impl.AbstractSharedContext.createInstanceHandle(AbstractSharedContext.java:96)
        at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:29)
        at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:26)
        at com.oracle.svm.core.jdk.SystemPropertiesSupport.initializeLazyValue(SystemPropertiesSupport.java:216)
        at com.oracle.svm.core.jdk.SystemPropertiesSupport.getProperty(SystemPropertiesSupport.java:169)
        at com.oracle.svm.core.jdk.Target_java_lang_System.getProperty(JavaLangSubstitutions.java:291)
        at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_VA_LIST:Ljava_lang_System_2_0002egetProperty_00028Ljava_lang_String_2_00029Ljava_lang_String_2(generated:0)

I'm not really sure how to perform the recommendation by the error message

Or you can write your own initialization methods and call them explicitly from your main entry point.

If you have any ideas please let me know.

@dufoli
Copy link
Contributor

dufoli commented Jun 29, 2021

@akuzni2 what aws extension are you using ?
do you add the corresponding quarkus extension ?
s3, lambda, SNS, SQS, ... ?

@wsy89
Copy link

wsy89 commented Jul 5, 2021

@dufoli I am getting exactly the same issue as @akuzni2 is getting when I try to invoke another lamba using

@Produces
@ApplicationScoped
public AWSLambda awsLambda() {
    return AWSLambdaAsyncClient.builder().build();
}
<dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-lambda</artifactId>
    <version>1.12.15</version>
</dependency>

@EdwinKorsten
Copy link

I have the same problem as @wsy89 and @akuzni2 with an AWS SDK library.

Error: Detected an instance of Random/SplittableRandom class in the image heap. Instances created during image generation have cached seed values and don't behave as expected. To see how this object got instantiated use --trace-object-instantiation=java.util.Random. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image runtime by using the option --initialize-at-run-time=. Or you can write your own initialization methods and call them explicitly from your main entry point.
Trace: Object was reached by
reading field com.amazonaws.retry.PredefinedBackoffStrategies$EqualJitterBackoffStrategy.random of
constant com.amazonaws.retry.PredefinedBackoffStrategies$EqualJitterBackoffStrategy@5c3fa02c reached by
reading field com.amazonaws.retry.PredefinedBackoffStrategies$SDKDefaultBackoffStrategy.equalJitterBackoffStrategy of
constant com.amazonaws.retry.PredefinedBackoffStrategies$SDKDefaultBackoffStrategy@42c1d66e reached by
reading field com.amazonaws.retry.RetryPolicy.backoffStrategy of
constant com.amazonaws.retry.RetryPolicy@35cbe86 reached by
scanning method com.amazonaws.ClientConfiguration.(ClientConfiguration.java:74)
Call path from entry point to com.amazonaws.ClientConfiguration.():
no path found from entry point to target method

Adding this to maven does not help:
<quarkus.native.additional-build-args>--initialize-at-run-time=com.amazonaws.ClientConfiguration,com.amazonaws.retry.PredefinedBackoffStrategies</quarkus.native.additional-build-args>

@wsy89
Copy link

wsy89 commented Jul 5, 2021

@EdwinKorsten @akuzni2
I was able to fix this by adding

--initialize-at-run-time=org.apache.http.impl.auth.NTLMEngineImpl

in additional build arg.
Also I had to use aws sdk v2 instead of v1

@antonwiens
Copy link

@gsmet I am running also into the issue with org.apache.http.impl.auth.NTLMEngineImpl using aws s3 extension and apache client. Can we get a fix for that?

@jerboaa
Copy link
Contributor

jerboaa commented Jul 7, 2021

@antonwiens Are you also using the HTTP client extension as a dependency as described here?

https://quarkus.io/guides/amazon-s3#configuring-s3-clients

@antonwiens
Copy link

@jerboaa No, i didn't. I pulled up the versions and didn`t know i had to add this, thats a nice hint, thanks and sorry for pulling this issue up again.

Maybe a build error from the quarkus plugin would be nice, if the apache client dependency was added and the quarkus-apache-client extension was missing. Just as a hint for ppl upgrading or not reading the documentation properly :)

@jmgtan
Copy link

jmgtan commented Mar 3, 2022

I've been getting the same Random/SplittableRandom error. I'm currently following the Quarkus Lambda guide (https://quarkus.io/guides/amazon-lambda) using the Quarkus 2.7.3.Final with GraalVM 21.3.1. I'm using the DynamoDB client from Java SDK v2.

Update: managed to get it to work by following the sample code found here: https://github.com/quarkusio/quarkus-quickstarts/blob/main/amazon-dynamodb-quickstart/pom.xml. Specifically by the use of the quarkus-amazon-dynamodb dependency instead of including the AWS SDK directly. I don't see this mentioned in any of the guides. Working now and man is the Lambda function fast! Great work.

@galderz
Copy link
Member

galderz commented Mar 4, 2022

@jmgtan Maybe you could improve the amazon-lambda guide? OSS FTW

@MarkusKramer
Copy link

@jmgtan I've also started hitting the Random/SplittableRandom error with the latest AWS SDK. It is possible to workaround it by using --initialize-at-run-time=software.amazon.awssdk.utils.cache.CachedSupplier. see aws/aws-sdk-java-v2#3323

@gsmet
Copy link
Member

gsmet commented Jul 25, 2022

@MarkusKramer I created quarkiverse/quarkus-amazon-services#220 to fix the issue in our extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/native-image kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests