Skip to content

8362276: NMT tests should have locks for the entire tests #26324

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

Closed
wants to merge 2 commits into from

Conversation

gerard-ziemski
Copy link

@gerard-ziemski gerard-ziemski commented Jul 15, 2025

We restructure the code to make sure we cover the code that uses the global tree instance (but nothing else that uses the same lock internally) as needed:

  • we move MemoryReserver::reserve() to the top to do as the first thing
  • we grab the MemTracker::NmtVirtualMemoryLocker nvml
  • do all the usual test stuff, including checking, which grabs the global instance of the tree
  • we move remove_all() to the very bottom to do as the last thing

Testing: passes Mach5 tier1-4


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-8362276: NMT tests should have locks for the entire tests (Bug - P2)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 26324

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 15, 2025

👋 Welcome back gziemski! 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 Jul 15, 2025

@gerard-ziemski 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:

8362276: NMT tests should have locks for the entire tests

Reviewed-by: shade, 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 33 new commits pushed to the master branch:

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
Copy link

openjdk bot commented Jul 15, 2025

@gerard-ziemski 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.

@gerard-ziemski gerard-ziemski marked this pull request as ready for review July 15, 2025 16:19
@openjdk openjdk bot added the rfr Pull request is ready for review label Jul 15, 2025
@mlbridge
Copy link

mlbridge bot commented Jul 15, 2025

Webrevs

Copy link
Member

@shipilev shipilev left a comment

Choose a reason for hiding this comment

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

Looks good, but synopsis even more confusing than the original one. Suggestion: "8362276: NMT tests should have locks for the entire tests" or something.

@shipilev
Copy link
Member

Well, GHA thinks this does not work:

# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/Users/runner/work/jdk/jdk/src/hotspot/share/runtime/mutex.cpp:143), pid=5569, tid=259
#  assert(owner() != self) failed: invariant

@gerard-ziemski gerard-ziemski marked this pull request as draft July 15, 2025 19:48
@gerard-ziemski
Copy link
Author

Well, GHA thinks this does not work:

# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/Users/runner/work/jdk/jdk/src/hotspot/share/runtime/mutex.cpp:143), pid=5569, tid=259
#  assert(owner() != self) failed: invariant

Yes, this is probably why Afshin went with his fix, investigating ....

@openjdk openjdk bot removed the rfr Pull request is ready for review label Jul 15, 2025
@coleenp
Copy link
Contributor

coleenp commented Jul 15, 2025

Looks good, but synopsis even more confusing than the original one. Suggestion: "8362276: NMT tests should have locks for the entire tests" or something.

Yes, please change the name to that. We changed the synopsis of the bug today to remove CLONE (simple fix), so you should change both the PR and the bug title.

@gerard-ziemski gerard-ziemski changed the title 8362276: CLONE (simple fix) - NMT crash in gtest/NMTGtests.java: fatal error: NMT corruption: Block at 0x0000017748307120: header canary broken 8362276: NMT tests should have locks for the entire tests Jul 15, 2025
@gerard-ziemski gerard-ziemski marked this pull request as ready for review July 15, 2025 22:43
@openjdk openjdk bot added the rfr Pull request is ready for review label Jul 15, 2025
Copy link
Member

@shipilev shipilev left a comment

Choose a reason for hiding this comment

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

All right, this looks reasonable.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jul 16, 2025
size_t size = 0x01000000;
ReservedSpace rs = MemoryReserver::reserve(size, mtTest);

RegionsTree* rtree = VirtualMemoryTracker::Instance::tree();
Copy link
Contributor

Choose a reason for hiding this comment

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

I have to confess to not paying attention to this change, but shouldn't you fetch the tree under the lock also?

Copy link
Member

Choose a reason for hiding this comment

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

I wondered the same, but this just returns an (unchanging) pointer. We are not in this locking game to ensure memory ordering, we only need mutual exclusion here. So IMO it does not matter for correctness whether we pull this under the lock or not.

Would be cleaner to do everything under the lock, but this seems fine as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, I see that too. The code just made me wonder but it's okay.

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 looks good. Thank you for fixing the crash Gerard, and thank you for your attention to this bug Aleksey.

size_t size = 0x01000000;
ReservedSpace rs = MemoryReserver::reserve(size, mtTest);

RegionsTree* rtree = VirtualMemoryTracker::Instance::tree();
Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, I see that too. The code just made me wonder but it's okay.

@gerard-ziemski
Copy link
Author

Thank you for the feedback and reviews!

@gerard-ziemski
Copy link
Author

/integrate

@openjdk
Copy link

openjdk bot commented Jul 16, 2025

Going to push as commit 10ae602.
Since your change was applied there have been 33 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Jul 16, 2025

@gerard-ziemski Pushed as commit 10ae602.

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

@gerard-ziemski
Copy link
Author

slash-backport :jdk25

@gerard-ziemski
Copy link
Author

/backport :jdk25

@gerard-ziemski
Copy link
Author

/backport:jdk25

@openjdk
Copy link

openjdk bot commented Jul 17, 2025

@gerard-ziemski Could not automatically backport 10ae6029 to openjdk/jdk due to conflicts in the following files:

  • test/hotspot/gtest/runtime/test_virtualMemoryTracker.cpp

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk.git jdk25:jdk25

# Check out the target branch and create your own branch to backport
$ git checkout jdk25
$ git checkout -b backport-gerard-ziemski-10ae6029-jdk25

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk.git 10ae6029444c1381f7b1b3dcb6b6f32a4ae57efa

# Backport the commit
$ git cherry-pick --no-commit 10ae6029444c1381f7b1b3dcb6b6f32a4ae57efa
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 10ae6029444c1381f7b1b3dcb6b6f32a4ae57efa'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk with the title Backport 10ae6029444c1381f7b1b3dcb6b6f32a4ae57efa.

Below you can find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 10ae6029 from the openjdk/jdk repository.

The commit being backported was authored by Gerard Ziemski on 16 Jul 2025 and was reviewed by Aleksey Shipilev and Coleen Phillimore.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-runtime [email protected] integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants