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

8267879: ClassLoaderMetaspace destructor asserts on !_frozen #4286

Conversation

iklam
Copy link
Member

@iklam iklam commented Jun 1, 2021

Summary: The assert was a false negative. Metaspace::freeze() is obsolete and should be removed.

The original reason for the Metaspace::freeze() API was to ensure that the safepoint portion of -Xshare:dump, i.e., VM_PopulateDumpSharedSpace::doit() does not call Metaspace::allocate(), which might cause a GC, resulting in a deadlock.

However, since JDK-8264149, GC would happen only with the TRAPS version of Metaspace::allocate(). Since JDK-8252685, TRAPS must be a JavaThread. This means that you can no longer cause a GC inside safepoint code by calling Metaspace::allocate().

Metaspace::assert_not_frozen() was also called by the ClassLoaderMetaspace allocation/deallocation functions, but none of these would cause GC. Also, anyone calling these function while a safepoint is in progress (such as the ZGC code that triggered this assert) must ensure that they won't affect any code that concurrently traverses metaspace objects inside the safepoint. Such safeguard logic is already done at a higher level, we don't need the low-level asserts inside the ClassLoaderMetaspace allocation/deallocation functions.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8267879: ClassLoaderMetaspace destructor asserts on !_frozen

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/4286/head:pull/4286
$ git checkout pull/4286

Update a local copy of the PR:
$ git checkout pull/4286
$ git pull https://git.openjdk.java.net/jdk pull/4286/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 4286

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/4286.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 1, 2021

👋 Welcome back iklam! 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
Copy link

openjdk bot commented Jun 1, 2021

@iklam The following label will be automatically applied to this pull request:

  • hotspot-runtime

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Jun 1, 2021
@iklam iklam marked this pull request as ready for review June 1, 2021 18:33
@openjdk openjdk bot added the rfr Pull request is ready for review label Jun 1, 2021
@mlbridge
Copy link

mlbridge bot commented Jun 1, 2021

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.

Hi Ioi,

Thanks for the detailed explanation. This seems fine.

David

@openjdk
Copy link

openjdk bot commented Jun 2, 2021

@iklam 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:

8267879: ClassLoaderMetaspace destructor asserts on !_frozen

Reviewed-by: dholmes, coleenp

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 29 new commits pushed to the master branch:

  • 4767758: 8267920: Create separate Events buffer for VMOperations
  • dc19bac: 8268094: Some vmTestbase/nsk tests fail after ACC_STRICT/strictfp changes
  • 2963c9e: 8268103: JNI functions incorrectly return a double after JDK-8265836
  • 6765f90: 8266459: Implement JEP 411: Deprecate the Security Manager for Removal
  • 19450b9: 8266281: Assign Symbols to the package selector expression
  • a223189: 8264774: Implementation of Foreign Function and Memory API (Incubator)
  • 71425dd: 8267118: OutOfMemoryError cannot be caught as a Throwable
  • de6472c: 8267459: Pasting Unicode characters into JShell does not work.
  • 9247630: 8265270: Type.getEnclosingType() may fail with CompletionFailure
  • 2d494bf: 8267836: Separate eager reclaim remembered set threshold from G1RSetSparseRegionEntries
  • ... and 19 more: https://git.openjdk.java.net/jdk/compare/36dc268abea2522596efe830365ba4bbe6e2696c...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 Jun 2, 2021
@coleenp
Copy link
Contributor

coleenp commented Jun 2, 2021

ZGC is doing concurrent class unloading while CDS is dumping the archive but it must be unloading some hidden class loader and not what CDS is trying to archive, right?

Copy link
Contributor

@coleenp coleenp left a comment

Choose a reason for hiding this comment

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

This is good. I have a question on the conversation.

@iklam
Copy link
Member Author

iklam commented Jun 2, 2021

ZGC is doing concurrent class unloading while CDS is dumping the archive but it must be unloading some hidden class loader and not what CDS is trying to archive, right?

Yes, ZGC can be unloading non-alive classes while CDS is dumping. I think that's what happened during the crash in this bug report.

Your question led me to finding this bug: JDK-8268139, where CDS could access classes that have been unloaded. I'll try to fix it in JDK 17, too.

@iklam
Copy link
Member Author

iklam commented Jun 2, 2021

Thanks @coleenp and @dholmes-ora for the review.
/integrate

@openjdk openjdk bot closed this Jun 2, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jun 2, 2021
@openjdk
Copy link

openjdk bot commented Jun 2, 2021

@iklam Since your change was applied there have been 36 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

Pushed as commit a8835b9.

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

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
4 participants