Skip to content

Conversation

@jerboaa
Copy link
Collaborator

@jerboaa jerboaa commented Sep 22, 2023

When building with an unpatched JDK 21, there is an initialization cycle in the native image code. The details are explained in this issue:
graalvm#556

This isn't easily reproducible with a LabsJDK 21 based build. However, I think it would be good to not be dependent on the patch in the base JDK. We have been using this patch in Mandrel as we are using unpatched OpenJDK 21 as a base.

Details of the patch:

First, we use a separate accessor for page-alignedness as it doesn't need the more sophisticated initialization of the directMemory field.

Next, ensure PhysicalMemory initialization is serialized and when it is, set directMemory to a static value so that the container code can finish initialization without introducing a cyle. The final directMemory value based on the heap size is then published to JDK code by setting the VM init level to 1. Therefore, application code would use the non-static value as the upper bound.

Closes: graalvm#556

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Sep 22, 2023
First, we use a separate accessor for page-alignedness as it doesn't
need the more sophisticated initialization of the directMemory field.

Next, ensure PhysicalMemory initialization is serialized and when it is,
set directMemory to a static value so that the container code can finish
initialization without introducing a cyle. The final directMemory value
based on the heap size is then published to JDK code by setting the VM
init level to 1. Therefore, application code would use the non-static
value as the upper bound.

Closes: oracle#556
@jerboaa
Copy link
Collaborator Author

jerboaa commented Sep 28, 2023

This is an alternative fix to:
graalvm/labs-openjdk-21@db1723c

@jerboaa
Copy link
Collaborator Author

jerboaa commented Oct 3, 2023

@adinn @roberttoyonaga Could you perhaps review this, please?

@jerboaa
Copy link
Collaborator Author

jerboaa commented Oct 4, 2023

Thanks for the review, @roberttoyonaga!

Copy link
Collaborator

@roberttoyonaga roberttoyonaga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Member

@christianhaeubl christianhaeubl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get the idea of the PR but I think it is too complex and at the same time not thread-safe enough. I implemented an alternative, see #7553. Please let me know if that simpler approach is good enough.

@jerboaa
Copy link
Collaborator Author

jerboaa commented Oct 5, 2023

I get the idea of the PR but I think it is too complex and at the same time not thread-safe enough. I implemented an alternative, see #7553. Please let me know if that simpler approach is good enough.

Thanks. I'll take a look later today and let you know.

@jerboaa
Copy link
Collaborator Author

jerboaa commented Oct 5, 2023

Please let me know if that simpler approach is good enough.

It's good enough to unbreak us. Thanks! Closing as the replacement PR is #7553.

@jerboaa jerboaa closed this Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement. redhat-interest

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GraalVM 24.0+ breaks the native-image driver (in native mode)

3 participants