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

JDK-8302595: use-after-free related to GraphKit::clone_map #12578

Closed
wants to merge 4 commits into from

Conversation

jcking
Copy link
Contributor

@jcking jcking commented Feb 15, 2023

GraphKit::clone_map duplicates SafePointNode and calls Compile::record_for_igvn. In some cases SafePointNode is not used so Node::destruct is called to cleanup. The Unique_Node_List returned by Compile::for_igvn still references the node which resides in freed memory which may or may not have been reused. We additionally need to remove the node from Unique_Node_List as well to prevent this from happening.

I introduced GraphKit::destruct_map_clone which undoes GraphKit::clone_map. It even clears the type, though I am not sure if this is necessary so feel free to suggest otherwise. Additionally it calls delete on JVMState, which is a noop, but it seems like the correct thing to do in case its ever changed.


Progress

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

Issue

  • JDK-8302595: use-after-free related to GraphKit::clone_map

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 12578

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

Using diff file

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

Signed-off-by: Justin King <jcking@google.com>
@bridgekeeper
Copy link

bridgekeeper bot commented Feb 15, 2023

👋 Welcome back jcking! 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 the rfr Pull request is ready for review label Feb 15, 2023
@openjdk
Copy link

openjdk bot commented Feb 15, 2023

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

  • hotspot-compiler

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-compiler hotspot-compiler-dev@openjdk.org label Feb 15, 2023
@mlbridge
Copy link

mlbridge bot commented Feb 15, 2023

Webrevs

Signed-off-by: Justin King <jcking@google.com>
@vnkozlov
Copy link
Contributor

Looks like there is issue with build - GHA testing build failed.

Signed-off-by: Justin King <jcking@google.com>
@jcking
Copy link
Contributor Author

jcking commented Feb 15, 2023

Looks like there is issue with build - GHA testing build failed.

Looks like it doesn't like setting memory or jvms to nullptr. So I'll just avoid clearing them.

@vnkozlov
Copy link
Contributor

/reviewers 2

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

Good. I will test it.

@openjdk
Copy link

openjdk bot commented Feb 16, 2023

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

8302595: use-after-free related to GraphKit::clone_map

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

  • 2e3cea0: 8302594: use-after-free in Node::destruct
  • 9b911b4: 8301959: Compile command in compiler.loopopts.TestRemoveEmptyCountedLoop does not work
  • c29a136: 8291735: methods_do() always run at exit
  • 687a461: 8302464: Parallel: Remove unreachable code in callers of numa_has_static_binding
  • 84c058b: 8300549: JFileChooser Approve button tooltip is null in Aqua L&F in CUSTOM_DIALOG mode
  • e045af4: 8297031: IGV: Copy extracted nodes and layout for cloned graph
  • 53ae4c0: 8300645: Handle julong values in logging of GET_CONTAINER_INFO macros
  • c77f644: 8302625: Bad copyright line after JDK-8302385
  • 519229d: 8302385: Remove MetaspaceReclaimPolicy=none
  • 6e2d3c6: 8302455: VM.classloader_stats memory size values are wrong
  • ... and 5 more: https://git.openjdk.org/jdk/compare/28f5250fa5cfd7938bb0899a2c17847b7458536c...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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@vnkozlov, @TobiHartmann) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Feb 16, 2023
@openjdk
Copy link

openjdk bot commented Feb 16, 2023

@vnkozlov
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Reviewer, 1 Author).

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Feb 16, 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.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Feb 16, 2023
Co-authored-by: Tobias Hartmann <tobias.hartmann@oracle.com>
@jcking
Copy link
Contributor Author

jcking commented Feb 16, 2023

Will wait for @vnkozlov testing before requesting integration.

@TobiHartmann
Copy link
Member

@vnkozlov's testing all passed.

@jcking
Copy link
Contributor Author

jcking commented Feb 16, 2023

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Feb 16, 2023
@openjdk
Copy link

openjdk bot commented Feb 16, 2023

@jcking
Your change (at version 8003f7a) is now ready to be sponsored by a Committer.

@TobiHartmann
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented Feb 16, 2023

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

  • 2e3cea0: 8302594: use-after-free in Node::destruct
  • 9b911b4: 8301959: Compile command in compiler.loopopts.TestRemoveEmptyCountedLoop does not work
  • c29a136: 8291735: methods_do() always run at exit
  • 687a461: 8302464: Parallel: Remove unreachable code in callers of numa_has_static_binding
  • 84c058b: 8300549: JFileChooser Approve button tooltip is null in Aqua L&F in CUSTOM_DIALOG mode
  • e045af4: 8297031: IGV: Copy extracted nodes and layout for cloned graph
  • 53ae4c0: 8300645: Handle julong values in logging of GET_CONTAINER_INFO macros
  • c77f644: 8302625: Bad copyright line after JDK-8302385
  • 519229d: 8302385: Remove MetaspaceReclaimPolicy=none
  • 6e2d3c6: 8302455: VM.classloader_stats memory size values are wrong
  • ... and 5 more: https://git.openjdk.org/jdk/compare/28f5250fa5cfd7938bb0899a2c17847b7458536c...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Feb 16, 2023

@TobiHartmann @jcking Pushed as commit 3cc459b.

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

@jcking jcking deleted the c2-clone-map branch February 16, 2023 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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