Skip to content

8302795: Shared archive failed on old version class with jsr bytecode #12752

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

Conversation

calvinccheung
Copy link
Member

@calvinccheung calvinccheung commented Feb 24, 2023

Please review this simple fix for avoid writing in to CDS archive during runtime while loading a shared old class (major_version < 50) with methods containg the jsr byte code.
Otherwise, JVM crashes with the following message in the hs err log:
Error accessing class data sharing archive. Mapped file inaccessible during execution, possible disk/network problem.

Passed tiers 1 - 4 testing.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8302795: Shared archive failed on old version class with jsr bytecode

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/12752/head:pull/12752
$ git checkout pull/12752

Update a local copy of the PR:
$ git checkout pull/12752
$ git pull https://git.openjdk.org/jdk pull/12752/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 12752

View PR using the GUI difftool:
$ git pr show -t 12752

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/12752.diff

@calvinccheung
Copy link
Member Author

/label add hotspot-runtime

@calvinccheung calvinccheung marked this pull request as ready for review February 24, 2023 23:28
@bridgekeeper
Copy link

bridgekeeper bot commented Feb 24, 2023

👋 Welcome back ccheung! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added rfr Pull request is ready for review hotspot-runtime hotspot-runtime-dev@openjdk.org labels Feb 24, 2023
@openjdk
Copy link

openjdk bot commented Feb 24, 2023

@calvinccheung
The hotspot-runtime label was successfully added.

@mlbridge
Copy link

mlbridge bot commented Feb 24, 2023

Webrevs

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

Sorry I'm having a little trouble following the problem and solution here. The problem IIUC:

  • If we load a class with JSR bytecodes then we have to rewrite those to avoid the use of JSR.
  • If we dumped such a class into the shared archive it is in the RO part of the archive.
  • If we attempt to rewrite a class in the RO section then we crash.

The solution would seem to be a choice of:
a) don't rewrite the class; or
b) don't archive it

The solution presented here seems to be (a) but I thought we had to rewrite classes with JSR bytecodes ???

@calvinccheung
Copy link
Member Author

The solution would seem to be a choice of: a) don't rewrite the class; or b) don't archive it

The solution presented here seems to be (a) but I thought we had to rewrite classes with JSR bytecodes ???

Option b is harder to do because we currently cannot link old classes during dump time. So we can't simply do the following check to see is a jsr bytecode is present during dump time.
m->has_jsrs()

In order to do the above check during dump time, for an "old" class, we'll need to check all the methods and for each method check all the byte codes and see if a jsr bytecode is present.

I'll try to implement the above.

@calvinccheung
Copy link
Member Author

I have pushed a commit. The fix is make the _methods array writable during dump time for "old" classes with the jsr byte code.
Ran tiers 1 - 3 testing successfully.

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

I'm not familiar enough with CDS to review this in detail sorry. The approach sounds reasonable.

Thanks

Copy link
Contributor

@yminqi yminqi left a comment

Choose a reason for hiding this comment

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

LGTM. We know after 49.0 (java 5), jsr will not be generated, so this should not be a problem for dynamic dumping too.

@openjdk
Copy link

openjdk bot commented Mar 7, 2023

@calvinccheung This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8302795: Shared archive failed on old version class with jsr bytecode

Reviewed-by: minqi, matsaave

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 254 new commits pushed to the master branch:

  • c466cdf: 8299546: C2: MulLNode::mul_ring() wrongly returns bottom type due to casting errors with large numbers
  • 55aa122: 8304059: Use InstanceKlass in dependencies
  • ec1eb00: 8303415: Add VM_Version::is_intrinsic_supported(id)
  • 31680b2: 8303410: Remove ContentSigner APIs and jarsigner -altsigner and -altsignerpath options
  • 0cc0f06: 8304015: G1: Metaspace-induced GCs should not trigger maximal compaction
  • 43eca1d: 8303910: jdk/classfile/CorpusTest.java failed 1 of 6754 tests
  • b6d70f2: 8303973: Library detection in runtime/ErrorHandling/TestDwarf.java fails on ppc64le RHEL8.5 for libpthread-2.28.so
  • 2bb990e: 8301244: Tidy up compiler specific warnings files
  • c073ef2: 8303482: Update LCMS to 2.15
  • 49181b8: 8303955: RISC-V: Factor out the tmp parameter from copy_memory and copy_memory_v
  • ... and 244 more: https://git.openjdk.org/jdk/compare/07e976ac26fe3ff6a94713013114dc38c95950b8...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Mar 7, 2023
Copy link
Contributor

@matias9927 matias9927 left a comment

Choose a reason for hiding this comment

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

This makes sense, rewriting the method should rewrite the JSR bytecodes and any matching RET bytecodes. LGTM!

@calvinccheung
Copy link
Member Author

Thanks @yminqi and @matias9927 for the review.

/integrate

@openjdk
Copy link

openjdk bot commented Mar 14, 2023

Going to push as commit 830fd41.
Since your change was applied there have been 259 commits pushed to the master branch:

  • 4e631fa: 8298966: Deprecate JMX Subject Delegation and the method JMXConnector.getMBeanServerConnection(Subject) for removal.
  • 10f1674: 8303809: Dispose context in SPNEGO NegotiatorImpl
  • 9f9ab02: 8303895: Simplify and clean up LinkFactory code
  • a00f5d2: 8303861: Error handling step timeouts should never be blocked by OnError and others
  • da044dd: 8300939: sun/security/provider/certpath/OCSP/OCSPNoContentLength.java fails due to network errors
  • c466cdf: 8299546: C2: MulLNode::mul_ring() wrongly returns bottom type due to casting errors with large numbers
  • 55aa122: 8304059: Use InstanceKlass in dependencies
  • ec1eb00: 8303415: Add VM_Version::is_intrinsic_supported(id)
  • 31680b2: 8303410: Remove ContentSigner APIs and jarsigner -altsigner and -altsignerpath options
  • 0cc0f06: 8304015: G1: Metaspace-induced GCs should not trigger maximal compaction
  • ... and 249 more: https://git.openjdk.org/jdk/compare/07e976ac26fe3ff6a94713013114dc38c95950b8...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Mar 14, 2023
@openjdk openjdk bot closed this Mar 14, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Mar 14, 2023
@openjdk
Copy link

openjdk bot commented Mar 14, 2023

@calvinccheung Pushed as commit 830fd41.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@calvinccheung calvinccheung deleted the 8302795-archive-old-class-with-jsr branch March 14, 2023 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-runtime hotspot-runtime-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

4 participants