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

8320310: CompiledMethod::has_monitors flag can be incorrect #16799

Closed
wants to merge 47 commits into from

Conversation

JornVernee
Copy link
Member

@JornVernee JornVernee commented Nov 23, 2023

Currently, the CompiledMethod::has_monitors flag is set when either a monitorenter is parsed by C1, and monitorexit is parsed by C1 or C2 during method compilation. However, not necessarily every bytecode of a method is parsed, which means that we could miss all monitorenter/monitorexit byte codes in a method, while it actually does use monitors. This can lead to situations where a thread holds a monitor, but has_monitors for all frames is set to false, leading to an assertion failure in 'freeze_internal' in continuationFreezeThaw.cpp:

assert(monitors_on_stack(current) == ((current->held_monitor_count() - current->jni_monitor_count()) > 0),
     "Held monitor count and locks on stack invariant: " INT64_FORMAT " JNI: " INT64_FORMAT, (int64_t)current->held_monitor_count(), (int64_t)current->jni_monitor_count());

The proposed fix is to rely on Method::has_monitor_bytecodes to set the has_monitors flag when compiling, which is immune to issues where not all byte codes of a method are parsed during compilation. We can follow the pattern established for has_reserved_stack_access, which is similar.

Note that this PR is based on: #16416 which disables the assertion. The goal of this PR is to fix the issue, and then re-enable the assertion.

Testing: Tier 1-4, java/lang/Thread/virtual/stress/PinALot.java


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-8320310: CompiledMethod::has_monitors flag can be incorrect (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 16799

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 23, 2023

👋 Welcome back jvernee! A progress list of the required criteria for merging this PR into pr/16416 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 Nov 23, 2023

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

  • hotspot

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 hotspot-dev@openjdk.org label Nov 23, 2023
@JornVernee JornVernee marked this pull request as ready for review November 24, 2023 07:56
@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 24, 2023
@mlbridge
Copy link

mlbridge bot commented Nov 24, 2023

Webrevs

@openjdk-notifier openjdk-notifier bot changed the base branch from pr/16416 to master November 28, 2023 10:23
@openjdk-notifier
Copy link

The parent pull request that this pull request depends on has now been integrated and the target branch of this pull request has been updated. This means that changes from the dependent pull request can start to show up as belonging to this pull request, which may be confusing for reviewers. To remedy this situation, simply merge the latest changes from the new target branch into this pull request by running commands similar to these in the local repository for your personal fork:

git checkout Has_Monitors
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# if there are conflicts, follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk
Copy link

openjdk bot commented Nov 28, 2023

@JornVernee this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout Has_Monitors
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label Nov 28, 2023
@openjdk openjdk bot removed the merge-conflict Pull request has merge conflict with target branch label Nov 28, 2023
@JornVernee
Copy link
Member Author

/label add hotspot-compiler

@openjdk openjdk bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Dec 11, 2023
@openjdk
Copy link

openjdk bot commented Dec 11, 2023

@JornVernee
The hotspot-compiler label was successfully added.

Copy link
Contributor

@iwanowww iwanowww 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.

@openjdk
Copy link

openjdk bot commented Dec 12, 2023

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

8320310: CompiledMethod::has_monitors flag can be incorrect

Reviewed-by: vlivanov, thartmann

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

  • f0e2e43: 8323021: Shenandoah: Encountered reference count always attributed to first worker thread
  • 3dc4bd8: 8322989: New test serviceability/HeapDump/FullGCHeapDumpLimitTest.java fails
  • 1d1cd32: 8321812: Update GC tests to use execute[Limited]TestJava
  • 868f874: 8322920: Some ProcessTools.execute* functions are declared to throw Throwable
  • 2a9c358: 8322725: (tz) Update Timezone Data to 2023d
  • 5235cc9: 8322583: RISC-V: Enable fast class initialization checks
  • 3b1e56a: 8322322: Support archived full module graph when -Xbootclasspath/a is used
  • 3fbccb0: 8322978: Remove debug agent debugMonitorTimedWait() function. It is no longer used.
  • ad31ec5: 8322647: Short name for the Europe/Lisbon time zone is incorrect
  • 15cf8f8: 8319626: Override toString() for ZipFile
  • ... and 377 more: https://git.openjdk.org/jdk/compare/4bcda602668835c35e2ac6ff6702d15cd249bc2a...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 Dec 12, 2023
Copy link
Member

@TobiHartmann TobiHartmann 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 to me.

@JornVernee
Copy link
Member Author

Thanks for the reviews!

@JornVernee
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Jan 8, 2024

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

  • 57a65fe: 8322003: JShell - Incorrect type inference in lists of records implementing interfaces
  • c90768c: 8318444: Write details about compilation bailouts into crash reports
  • 29397d2: 8320317: ObjectMonitor NotRunnable is not really an optimization
  • fc04750: 8321371: SpinPause() not implemented for bsd_aarch64/macOS
  • 458e563: 8310711: [IR Framework] Remove safepoint while printing handling
  • 71aac7a: 8276809: java/awt/font/JNICheck/FreeTypeScalerJNICheck.java shows JNI warning on Windows
  • 09c6c4f: 8322489: 22-b27: Up to 7% regression in all Footprint3-*-G1/ZGC
  • eb9e754: 8323065: Unneccesary CodeBlob lookup in CompiledIC::internal_set_ic_destination
  • a40d397: 8323110: Eliminate -Wparentheses warnings in ppc code
  • 7edd10e: 8321786: SegmentAllocator:allocateFrom(ValueLayout, MemorySegment,ValueLayout,long,long) spec mismatch in exception scenario
  • ... and 401 more: https://git.openjdk.org/jdk/compare/4bcda602668835c35e2ac6ff6702d15cd249bc2a...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Jan 8, 2024

@JornVernee Pushed as commit c8fa3e2.

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

@JornVernee JornVernee deleted the Has_Monitors branch January 8, 2024 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot hotspot-dev@openjdk.org hotspot-compiler hotspot-compiler-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants