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 build failed after upgrade graalVM jdk 22 on linux but success on macOS #8862

Open
GrapeBaBa opened this issue Apr 30, 2024 · 4 comments
Assignees

Comments

@GrapeBaBa
Copy link

Describe the issue
After upgrade graalVM jdk 22, native build failed.

Steps to reproduce the issue
Please include both build steps as well as run steps

git clone --single-branch --branch jdk22 git@github.com:optimism-java/hildr.git
//if local is linux
./gradlew buildBinary

//if local is non linux
cd docker
COMPOSE_PROFILES=hildr-node-native,op-geth,metrics docker compose up -d

Describe GraalVM and your environment:

  • GraalVM version (latest snapshot builds can be found here), or commit id if built from source: [e.g. EE 19.3, CE 20.0, CE 20.1.0-dev-20200304_0848]
  • JDK major version: 22
  • OS: ubuntu latest
  • Architecture: AMD64

More details
Consider adding the --native-image-info and --verbose flags when building your native image and paste output below.

Add any other information about the problem here. Especially important are stack traces or log output. Feel free to link to gists or to screenshots if necessary.

398.0 Error: Detected a FileDescriptor in the image heap. File descriptors opened during image generation are no longer open at image runtime, and the files might not even be present anymore at image runtime. Try avoiding to initialize the class that caused initialization of the FileDescriptor.
398.0 The culprit object has been instantiated by the 'sun.security.provider.SunEntries' class initializer with the following trace:
398.0   at java.io.FileDescriptor.<init>(FileDescriptor.java:127)
398.0   at java.io.FileInputStream.<init>(FileInputStream.java:149)
398.0   at sun.security.provider.FileInputStreamPool.getInputStream(FileInputStreamPool.java:110)
398.0   at sun.security.provider.NativePRNG$RandomIO.<init>(NativePRNG.java:390)
398.0   at sun.security.provider.NativePRNG$1.run(NativePRNG.java:192)
398.0   at sun.security.provider.NativePRNG$1.run(NativePRNG.java:132)
398.0   at java.security.AccessController.executePrivileged(AccessController.java:778)
398.0   at java.security.AccessController.doPrivileged(AccessController.java:319)
398.0   at sun.security.provider.NativePRNG.initIO(NativePRNG.java:131)
398.0   at sun.security.provider.NativePRNG.<clinit>(NativePRNG.java:93)
398.0   at sun.security.provider.SunEntries.<clinit>(SunEntries.java:362)
398.0 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.
398.0 Trace: Object was reached by
398.0   reading field java.io.FileInputStream.fd of constant 
398.0     java.io.FileInputStream@4f24c58e: java.io.FileInputStream@4f24c58e
398.0   reading field java.io.FilterInputStream.in of constant 
398.0     sun.security.provider.FileInputStreamPool$UnclosableInputStream@7a7afc35: sun.security.provider.FileInputStreamPool$UnclosableInputStream@7a7afc35
398.0   reading field sun.security.provider.NativePRNG$RandomIO.seedIn of constant 
398.0     sun.security.provider.NativePRNG$RandomIO@fefb164: sun.security.provider.NativePRNG$RandomIO@fefb164
398.0   reading static field sun.security.provider.NativePRNG$Blocking.INSTANCE
398.0     at <unknown-location>
398.0   registered as read because: null
398.0 Error: Detected a FileDescriptor in the image heap. File descriptors opened during image generation are no longer open at image runtime, and the files might not even be present anymore at image runtime. Try avoiding to initialize the class that caused initialization of the FileDescriptor.
398.0 The culprit object has been instantiated by the 'sun.security.provider.SunEntries' class initializer with the following trace:
398.0   at java.io.FileDescriptor.<init>(FileDescriptor.java:127)
398.0   at java.io.FileInputStream.<init>(FileInputStream.java:149)
398.0   at sun.security.provider.FileInputStreamPool.getInputStream(FileInputStreamPool.java:110)
398.0   at sun.security.provider.NativePRNG$RandomIO.<init>(NativePRNG.java:391)
398.0   at sun.security.provider.NativePRNG$1.run(NativePRNG.java:192)
398.0   at sun.security.provider.NativePRNG$1.run(NativePRNG.java:132)
398.0   at java.security.AccessController.executePrivileged(AccessController.java:778)
398.0   at java.security.AccessController.doPrivileged(AccessController.java:319)
398.0   at sun.security.provider.NativePRNG.initIO(NativePRNG.java:131)
398.0   at sun.security.provider.NativePRNG.<clinit>(NativePRNG.java:93)
398.0   at sun.security.provider.SunEntries.<clinit>(SunEntries.java:362)
398.0 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.
398.0 Trace: Object was reached by
398.0   reading field java.io.FileInputStream.fd of constant 
398.0     java.io.FileInputStream@22ab7cdd: java.io.FileInputStream@22ab7cdd
398.0   reading field java.io.FilterInputStream.in of constant 
398.0     sun.security.provider.FileInputStreamPool$UnclosableInputStream@20043089: sun.security.provider.FileInputStreamPool$UnclosableInputStream@20043089
398.0   reading field sun.security.provider.NativePRNG$RandomIO.seedIn of constant 
398.0     sun.security.provider.NativePRNG$RandomIO@58db6c3d: sun.security.provider.NativePRNG$RandomIO@58db6c3d
398.0   reading static field sun.security.provider.NativePRNG$NonBlocking.INSTANCE
398.0     at <unknown-location>
398.0   registered as read because: null
398.0 
398.0 com.oracle.svm.driver.NativeImage$NativeImageError
398.0   at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.showError(NativeImage.java:2258)
398.0   at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.build(NativeImage.java:1871)
398.0   at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.performBuild(NativeImage.java:1830)
398.0   at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.main(NativeImage.java:1812)
398.0   at java.base@22.0.1/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
398.1 
398.1 FAILURE: Build failed with an exception.
398.1 
398.1 * Where:
398.1 Build file '/root/hildr/hildr-node/build.gradle' line: 348
398.1 
@GrapeBaBa GrapeBaBa changed the title Native build failed after upgrade graalVM jdk 22 Native build failed after upgrade graalVM jdk 22 on linux but success on macOS Apr 30, 2024
@fernando-valdez fernando-valdez self-assigned this May 1, 2024
@fernando-valdez
Copy link
Member

Hi, can you please share which version was working before? was that version working on iOS and Linux too?

Finally, the error is showing this message:
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.

did you try that?

@GrapeBaBa
Copy link
Author

Hi, can you please share which version was working before? was that version working on iOS and Linux too?

Finally, the error is showing this message: 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.

did you try that?

My laptop is macOS, it can build successfully. The build error happened on Linux, the version is latest graalvm here https://github.com/optimism-java/hildr/blob/jdk22/docker/Dockerfile#L3 .

I have added all the classes in the trace, however still not works.

@fernando-valdez
Copy link
Member

fernando-valdez commented May 2, 2024

Can you try to add this flag -H:ThrowMissingRegistrationErrors and share your results?
Also, just to be sure, you are getting this error when building the native image, right?

@GrapeBaBa
Copy link
Author

Can you try to add this flag -H:ThrowMissingRegistrationErrors and share your results? Also, just to be sure, you are getting this error when building the native image, right?

Got error when added this flag Error: Invalid native-image hosted-option -H:ThrowMissingRegistrationErrors at user.

Yes, only build native image on ubuntu, macOS is OK.

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

No branches or pull requests

2 participants