Skip to content

8304996: Add missing HandleMarks #13215

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

dholmes-ora
Copy link
Member

@dholmes-ora dholmes-ora commented Mar 28, 2023

The review for JDK-8304147 pointed out that the top-level HandleMark in dump_for_exit (added to replace the previous coverage from a HandleMarkCleaner in JVM_ENTRY) was not in the right place as no Handles were being used there. Removing that HM and fixing up the ensuing failures led to a set of fixes where HM's were missing at the place of Handle usage.

Testing: tiers 1-4

Thanks.


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

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 13215

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 28, 2023

👋 Welcome back dholmes! 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 Mar 28, 2023

@dholmes-ora 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 Mar 28, 2023
@dholmes-ora
Copy link
Member Author

/label add hotspot-runtime
/label remove hotspot

@openjdk openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Mar 28, 2023
@openjdk
Copy link

openjdk bot commented Mar 28, 2023

@dholmes-ora
The hotspot-runtime label was successfully added.

@openjdk openjdk bot removed the hotspot hotspot-dev@openjdk.org label Mar 28, 2023
@openjdk
Copy link

openjdk bot commented Mar 28, 2023

@dholmes-ora
The hotspot label was successfully removed.

@dholmes-ora dholmes-ora changed the title Fix up HandleMarks 8304996: Add missing Handlemarks Mar 28, 2023
@openjdk openjdk bot changed the title 8304996: Add missing Handlemarks 8304996: Add missing Handlemarks Mar 28, 2023
@dholmes-ora dholmes-ora marked this pull request as ready for review March 28, 2023 22:05
@openjdk openjdk bot added the rfr Pull request is ready for review label Mar 28, 2023
@mlbridge
Copy link

mlbridge bot commented Mar 28, 2023

Webrevs

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.

Looks good! thank you for fixing these.

@openjdk
Copy link

openjdk bot commented Mar 28, 2023

@dholmes-ora 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:

8304996: Add missing HandleMarks

Reviewed-by: coleenp, shade, iklam

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

  • b062b1b: 8304743: Compile_lock and SystemDictionary updates
  • df819cf: 8304945: StringBuilder and StringBuffer should implement Appendable explicitly
  • 312bbe7: 8305485: Problemlist runtime/Thread/TestAlwaysPreTouchStacks.java
  • 50e31e0: 8305442: (bf) Direct and view implementations of CharBuffer.toString(int, int) do not need to catch SIOBE
  • 85e3974: 8304014: Convert test/jdk/java/util/zip/ZipFile/CorruptedZipFiles.java to junit
  • 40aea04: 8278268: (ch) InputStream returned by Channels.newInputStream should have fast path for FileChannel targets
  • 9b9b5a7: 8302323: Add repeat methods to StringBuilder/StringBuffer
  • dd7ca75: 8305478: [REDO] disable gtest/NMTGtests.java sub-tests failing due to JDK-8305414
  • f9827ad: 8288109: HttpExchangeImpl.setAttribute does not allow null value after JDK-8266897
  • 6010de0: 8305417: disable gtest/NMTGtests.java sub-tests failing due to JDK-8305414
  • ... and 81 more: https://git.openjdk.org/jdk/compare/6aec6f3a842ead30b26cd31dc57a2ab268f67875...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 28, 2023
@dholmes-ora
Copy link
Member Author

Thanks @coleenp !

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.

I think the issue synopsis should be capitalized: "Add missing HandleMarks". Also, does it cover the cases that were not covered by dump_at_exit HandleMark before? If not, then it is not adding "missing" HMs.

@@ -1174,6 +1175,7 @@ void klassItable::initialize_itable(GrowableArray<Method*>* supers) {
void klassItable::check_constraints(GrowableArray<Method*>* supers, TRAPS) {

assert(_size_method_table == supers->length(), "wrong size");
HandleMark hm(THREAD);
Copy link
Member

Choose a reason for hiding this comment

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

Question: Would this make the handles area grow up to _size_method_table in the worst case? I thought we want to have HandleMark-s closer to actual handle creation/last-use to keep the footprint at bay.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was optimising for runtime performance rather than footprint, but you are right this could grow in a way we don't want. So I reverted this change and made a similar change to klassVtable::check_constraints.

Thanks for looking at this @shipilev .

@dholmes-ora dholmes-ora changed the title 8304996: Add missing Handlemarks 8304996: Add missing HandleMarks Mar 29, 2023
@dholmes-ora
Copy link
Member Author

I think the issue synopsis should be capitalized: "Add missing HandleMarks". Also, does it cover the cases that were not covered by dump_at_exit HandleMark before? If not, then it is not adding "missing" HMs.

Fixed capitalization in HandleMark.

Not sure what your issue is with "missing" - the HM's were not present where the Handles were used and hence were missing. Some cases were directly detected by removing the old HM in dump_for_exit but I also checked those files for other cases and added them.

@dholmes-ora dholmes-ora requested a review from shipilev March 29, 2023 22:06
@iklam
Copy link
Member

iklam commented Mar 30, 2023

What are the rules for using HandleMarks? In the HotSpot code, there are plenty of cases where we create a HandleMark without creating any Handles in the immediately following code. There are also plenty of cases where Handles are created in functions that do not have any HandleMarks.

@dholmes-ora
Copy link
Member Author

What are the rules for using HandleMarks? In the HotSpot code, there are plenty of cases where we create a HandleMark without creating any Handles in the immediately following code. There are also plenty of cases where Handles are created in functions that do not have any HandleMarks.

@coleenp has a lot to say on this but basically HM's should appear along-side the code that creates the Handles. Unless you return a Handle from a function, there should generally be a HM in the function. There is a lot of code that doesn't follow this. Partly I think this is because we have some high-on-the-stack HMs or HandleMarkCleaners that hide the creation of Handles without a local HandleMark. Conversely if new code uses existing code that doesn't have a HM and gets an error, then the typical response is to put a HM in the new code - especially because that only affects the new change, whereas putting a HM lower-down could be seen as disruptive etc.

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 fine to me. (I'd probably put HandleMark after the comment, closer to the code in check_constraints, but no need to do that if there are no other changes pending.)

@shipilev
Copy link
Member

Not sure what your issue is with "missing" - the HM's were not present where the Handles were used and hence were missing. Some cases were directly detected by removing the old HM in dump_for_exit but I also checked those files for other cases and added them.

When I read a synopsis "Add missing HMs", that means to me there are code paths that allocate Handles without HMs -- meaning there is a memory leak. If we just dropped an "umbrella" HM in dump_for_exit and only added the HMs that were needed after that removal, that just rebalances the ways we cut and slice the HMs, and that does not affect memory leaks. This distinction is important to gauge how serious the issue is, and whether it should be backported, for example. This is why I wanted to understand the meaning of "missing" here :)

@dholmes-ora
Copy link
Member Author

Thanks @shipilev !

@dholmes-ora
Copy link
Member Author

Any other comments? @iklam or @coleenp ?

Copy link
Member

@iklam iklam left a comment

Choose a reason for hiding this comment

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

LGTM

@dholmes-ora
Copy link
Member Author

Thanks @iklam !

/integrate

@openjdk
Copy link

openjdk bot commented Apr 4, 2023

Going to push as commit a7546b3.
Since your change was applied there have been 96 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 Apr 4, 2023
@openjdk openjdk bot closed this Apr 4, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Apr 4, 2023
@openjdk
Copy link

openjdk bot commented Apr 4, 2023

@dholmes-ora Pushed as commit a7546b3.

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

@dholmes-ora dholmes-ora deleted the handlemark branch April 4, 2023 02:33
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