Skip to content

Fix graalvm compatibility #7160

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

ericdallo
Copy link

This fix a graalvm compatibility with the logger api (only one I tested in my lib), this exports the graalvm config automatically for clients.

Caused by: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: An object of type 'io.opentelemetry.api.common.AttributeType' was found in the image heap. This type, however, is marked for initialization at image run time for the following reason: classes are initialized at run time by default.
This is not allowed for correctness reasons: All objects that are stored in the image heap must be initialized at build time.

You now have two options to resolve this:

1) If it is intended that objects of type 'io.opentelemetry.api.common.AttributeType' are persisted in the image heap, add

    '--initialize-at-build-time=io.opentelemetry.api.common.AttributeType'

to the native-image arguments. Note that initializing new types can store additional objects to the heap. It is advised to check the static fields of 'io.opentelemetry.api.common.AttributeType' to see if they are safe for build-time initialization,  and that they do not contain any sensitive data that should not become part of the image.

2) If these objects should not be stored in the image heap, you can use

    '--trace-object-instantiation=io.opentelemetry.api.common.AttributeType'

to find classes that instantiate these objects. Once you found such a class, you can mark it explicitly for run time initialization with

    '--initialize-at-run-time=<culprit>'

to prevent the instantiation of the object.

If you are seeing this message after upgrading to a new GraalVM release, 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 '--initialize-at-build-time=io.opentelemetry.api.common.AttributeType' 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.

The following detailed trace displays from which field in the code the object was reached.
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.checkImageHeapInstance(ClassInitializationFeature.java:206)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisType.lambda$notifyObjectReachable$12(AnalysisType.java:659)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.ConcurrentLightHashSet.forEach(ConcurrentLightHashSet.java:149)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisType.notifyObjectReachable(AnalysisType.java:659)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.heap.ImageHeapScanner.onObjectReachable(ImageHeapScanner.java:586)
        ... 11 more

@ericdallo ericdallo requested a review from a team as a code owner February 28, 2025 14:26
Copy link

linux-foundation-easycla bot commented Feb 28, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link

codecov bot commented Feb 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.85%. Comparing base (cd1f617) to head (8499295).

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #7160   +/-   ##
=========================================
  Coverage     89.85%   89.85%           
  Complexity     6622     6622           
=========================================
  Files           740      740           
  Lines         20007    20007           
  Branches       1968     1968           
=========================================
  Hits          17978    17978           
  Misses         1439     1439           
  Partials        590      590           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@trask
Copy link
Member

trask commented Feb 28, 2025

cc @jeanbisutti

@jack-berg
Copy link
Member

Hmm.. its not clear to me what the problem is with AttributeType that requires it to be handled with this special case.

Can you provide a repro of the issue? Would good to add it to our graal test suite.

@jeanbisutti
Copy link
Member

@ericdallo Could you please provide the GraalVM version for which the problem appears?

@ericdallo
Copy link
Author

@jeanbisutti

native-image 23.0.1 2024-10-15
GraalVM Runtime Environment GraalVM CE 23.0.1+11.1 (build 23.0.1+11-jvmci-b01)
Substrate VM GraalVM CE 23.0.1+11.1 (build 23.0.1+11, serial gc)

@jack-berg I reproed that using the log appender of timbre here on clojure-lsp, I can't spend more time on this though, so after this PR, I included on clojure-lsp here to fix my case meanwhile

@jeanbisutti
Copy link
Member

@jack-berg The native tests are executed with GraalVM 21:

It may be worth to run them with version 23 as well (the last one).

@jack-berg jack-berg mentioned this pull request Mar 4, 2025
@jack-berg
Copy link
Member

It may be worth to run them with version 23 as well (the last one).

See #7167

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 this pull request may close these issues.

4 participants