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

Eagerly initialized Random in various extensions #2664

Closed
ppalaga opened this issue May 25, 2021 · 0 comments · Fixed by #2663
Closed

Eagerly initialized Random in various extensions #2664

ppalaga opened this issue May 25, 2021 · 0 comments · Fixed by #2663
Assignees
Milestone

Comments

@ppalaga
Copy link
Contributor

ppalaga commented May 25, 2021

GraalVM 21.1 is picky about Randoms being initialized at build time. Here an example of the error message in camel-quarkus-integration-test-xmlsecurity:

[INFO] --- quarkus-maven-plugin:2.0.0.Alpha3:build (quarkus-build) @ camel-quarkus-integration-test-xmlsecurity ---
Warning:  [io.quarkus.deployment] Producing values from constructors and fields is no longer supported and will be removed in a future release: io.quarkus.deployment.annotations.BuildProducer org.apache.camel.quarkus.component.validator.deployment.ValidatorProcessor.resource
Warning:  [io.quarkus.deployment] Producing values from constructors and fields is no longer supported and will be removed in a future release: io.quarkus.deployment.annotations.BuildProducer org.apache.camel.quarkus.component.validator.deployment.ValidatorProcessor.resourceBundle
[INFO] [org.jboss.threads] JBoss Threads version 3.2.0.Final
[INFO] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Building native image source jar: /home/runner/work/camel-quarkus/camel-quarkus/integration-tests/xmlsecurity/target/camel-quarkus-integration-test-xmlsecurity-2.0.0-M1-SNAPSHOT-native-image-source-jar/camel-quarkus-integration-test-xmlsecurity-2.0.0-M1-SNAPSHOT-runner.jar
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Building native image from /home/runner/work/camel-quarkus/camel-quarkus/integration-tests/xmlsecurity/target/camel-quarkus-integration-test-xmlsecurity-2.0.0-M1-SNAPSHOT-native-image-source-jar/camel-quarkus-integration-test-xmlsecurity-2.0.0-M1-SNAPSHOT-runner.jar
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildContainerRunner] Using docker to run the native image builder
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildContainerRunner] Checking image status quay.io/quarkus/ubi-quarkus-native-image:21.1-java11
21.1-java11: Pulling from quarkus/ubi-quarkus-native-image
Digest: sha256:ede61901888c977191d71fb3b83532c2e0bc1b6a863c82bb20c0969fe9aab503
Status: Image is up to date for quay.io/quarkus/ubi-quarkus-native-image:21.1-java11
quay.io/quarkus/ubi-quarkus-native-image:21.1-java11
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Running Quarkus native-image plugin on GraalVM 21.1.0 Java 11 CE (Java Version 11.0.11+8-jvmci-21.1-b05)
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildRunner] docker run --env LANG=C --rm --user 1001:121 -v /home/runner/work/camel-quarkus/camel-quarkus/integration-tests/xmlsecurity/target/camel-quarkus-integration-test-xmlsecurity-2.0.0-M1-SNAPSHOT-native-image-source-jar:/project:z quay.io/quarkus/ubi-quarkus-native-image:21.1-java11 -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegateFactory -J-Dvertx.disableDnsResolver=true -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=3 -J-Duser.language=en -J-Duser.country=US -J-Dfile.encoding=UTF-8 --initialize-at-build-time= -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy\$BySpaceAndTime -H:+JNI -H:+AllowFoldMethods -jar camel-quarkus-integration-test-xmlsecurity-2.0.0-M1-SNAPSHOT-runner.jar -H:FallbackThreshold=0 -H:+ReportExceptionStackTraces -H:-AddAllCharsets -H:EnableURLProtocols=http,https -H:-UseServiceLoaderFeature -H:+StackTrace camel-quarkus-integration-test-xmlsecurity-2.0.0-M1-SNAPSHOT-runner
[camel-quarkus-integration-test-xmlsecurity-2.0.0-M1-SNAPSHOT-runner:25]    classlist:   8,296.87 ms,  1.19 GB
[camel-quarkus-integration-test-xmlsecurity-2.0.0-M1-SNAPSHOT-runner:25]        (cap):     804.42 ms,  1.19 GB
[camel-quarkus-integration-test-xmlsecurity-2.0.0-M1-SNAPSHOT-runner:25]        setup:   3,650.18 ms,  1.19 GB
11:24:38,936 WARN  [io.qua.config] Unrecognized configuration key "quarkus.home" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
11:25:29,884 INFO  [org.jbo.threads] JBoss Threads version 3.2.0.Final
[camel-quarkus-integration-test-xmlsecurity-2.0.0-M1-SNAPSHOT-runner:25]     (clinit):   1,176.73 ms,  2.74 GB
[camel-quarkus-integration-test-xmlsecurity-2.0.0-M1-SNAPSHOT-runner:25]   (typeflow):  51,411.86 ms,  2.74 GB
[camel-quarkus-integration-test-xmlsecurity-2.0.0-M1-SNAPSHOT-runner:25]    (objects):  67,679.64 ms,  2.74 GB
[camel-quarkus-integration-test-xmlsecurity-2.0.0-M1-SNAPSHOT-runner:25]   (features):   1,662.74 ms,  2.74 GB
[camel-quarkus-integration-test-xmlsecurity-2.0.0-M1-SNAPSHOT-runner:25]     analysis: 124,319.20 ms,  2.74 GB
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.
[INFO] ------------------------------------------------------------------------
Detailed message:
Trace: 
	at parsing org.apache.xml.security.stax.ext.XMLSecurityConstants.generateBytes(XMLSecurityConstants.java:82)
Call path from entry point to org.apache.xml.security.stax.ext.XMLSecurityConstants.generateBytes(int): 
	at org.apache.xml.security.stax.ext.XMLSecurityConstants.generateBytes(XMLSecurityConstants.java:81)
	at org.apache.xml.security.encryption.XMLCipher.encryptData(XMLCipher.java:1132)
	at org.apache.xml.security.encryption.XMLCipher.encryptData(XMLCipher.java:1084)
	at org.apache.xml.security.encryption.XMLCipher.encryptElement(XMLCipher.java:829)
	at org.apache.xml.security.encryption.XMLCipher.doFinal(XMLCipher.java:941)
	at org.apache.camel.dataformat.xmlsecurity.XMLSecurityDataFormat.decode(XMLSecurityDataFormat.java:551)
	at com.oracle.svm.reflect.XMLSecurityDataFormat_decode_31e4f2781b4935a1526b50a05ea6d2956fe32283_971.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Method.java:566)
	at org.apache.xml.dtm.DTMException.printStackTrace(DTMException.java:365)
	at org.apache.xml.dtm.DTMException.printStackTrace(DTMException.java:289)
	at com.oracle.svm.jni.functions.JNIFunctions.ExceptionDescribe(JNIFunctions.java:778)
	at com.oracle.svm.core.code.IsolateEnterStub.JNIFunctions_ExceptionDescribe_b5412f7570bccae90b000bc37855f00408b2ad73(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.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.
Detailed message:
Trace: 
	at parsing org.apache.xml.security.stax.ext.XMLSecurityConstants.generateBytes(XMLSecurityConstants.java:82)
Call path from entry point to org.apache.xml.security.stax.ext.XMLSecurityConstants.generateBytes(int): 
	at org.apache.xml.security.stax.ext.XMLSecurityConstants.generateBytes(XMLSecurityConstants.java:81)
	at org.apache.xml.security.encryption.XMLCipher.encryptData(XMLCipher.java:1132)
	at org.apache.xml.security.encryption.XMLCipher.encryptData(XMLCipher.java:1084)
	at org.apache.xml.security.encryption.XMLCipher.encryptElement(XMLCipher.java:829)
	at org.apache.xml.security.encryption.XMLCipher.doFinal(XMLCipher.java:941)
	at org.apache.camel.dataformat.xmlsecurity.XMLSecurityDataFormat.decode(XMLSecurityDataFormat.java:551)
	at com.oracle.svm.reflect.XMLSecurityDataFormat_decode_31e4f2781b4935a1526b50a05ea6d2956fe32283_971.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Method.java:566)
	at org.apache.xml.dtm.DTMException.printStackTrace(DTMException.java:365)
	at org.apache.xml.dtm.DTMException.printStackTrace(DTMException.java:289)
	at com.oracle.svm.jni.functions.JNIFunctions.ExceptionDescribe(JNIFunctions.java:778)
	at com.oracle.svm.core.code.IsolateEnterStub.JNIFunctions_ExceptionDescribe_b5412f7570bccae90b000bc37855f00408b2ad73(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 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)
	... 5 more
Error: Image build request failed with exit status 1
@ppalaga ppalaga added this to the 2.0.0-M1 milestone May 25, 2021
@ppalaga ppalaga self-assigned this May 25, 2021
@ppalaga ppalaga changed the title Eagerly initialized Random in 3c7328937c11d3c480091db4319e5d393d290c2c in XML Security Eagerly initialized Random in XMLSecurityConstants May 25, 2021
@ppalaga ppalaga changed the title Eagerly initialized Random in XMLSecurityConstants Eagerly initialized Random in various extensions May 25, 2021
ppalaga added a commit to ppalaga/camel-quarkus that referenced this issue May 25, 2021
ppalaga added a commit to ppalaga/camel-quarkus that referenced this issue May 25, 2021
ppalaga added a commit to ppalaga/camel-quarkus that referenced this issue May 26, 2021
ppalaga added a commit to ppalaga/camel-quarkus that referenced this issue May 26, 2021
ppalaga added a commit to ppalaga/camel-quarkus that referenced this issue May 26, 2021
ppalaga added a commit to ppalaga/camel-quarkus that referenced this issue May 26, 2021
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

Successfully merging a pull request may close this issue.

1 participant