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-8318183: C2: VM may crash after hitting node limit #16205

Closed
wants to merge 4 commits into from

Conversation

tstuefe
Copy link
Member

@tstuefe tstuefe commented Oct 16, 2023

When processing the node limit, as well as when bailing out of compilation for other reasons, we run Compiler::record_failure() which sets the root node of Compile to null.

We then should stop any further work that may use Compile::_root. That does not always happen. The results are crashes or asserts when the node limit check hit right at the wrong spot. One example for a follow-up assertion after the node limit hit:

# Internal Error (/shared/projects/openjdk/jdk-jdk/source/src/hotspot/share/opto/loopnode.hpp:623), pid=761308, tid=761322
# assert(_head != nullptr) failed: precond

at

Stack: [0x00007fa068281000,0x00007fa068382000], sp=0x00007fa06837cd40, free space=1007k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x114ad1c] IdealLoopTree::IdealLoopTree(PhaseIdealLoop*, Node*, Node*)+0x14c (loopnode.hpp:623)
V [libjvm.so+0x11412bf] PhaseIdealLoop::build_and_optimize()+0x237 (loopnode.cpp:4325)
V [libjvm.so+0x96e7ac] PhaseIdealLoop::PhaseIdealLoop(PhaseIterGVN&, LoopOptsMode)+0x144 (loopnode.hpp:1112)
V [libjvm.so+0x96e9fa] PhaseIdealLoop::optimize(PhaseIterGVN&, LoopOptsMode)+0x4a (loopnode.hpp:1191)
V [libjvm.so+0x960394] Compile::Optimize()+0x98c (compile.cpp:2357)

I saw this during the development of JDK-8318016, which re-uses the node limit check for memory limit checks, so those code paths are executed more often.

The patch adds several bailouts to the C2 code. I tried to follow and close all paths that call the node limit check. With this patch above assertion and other crashes and assertions disappear.


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-8318183: C2: VM may crash after hitting node limit (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 16205

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 16, 2023

👋 Welcome back stuefe! 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 Oct 16, 2023

@tstuefe The following labels will be automatically applied to this pull request:

  • hotspot
  • shenandoah

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

@openjdk openjdk bot added hotspot hotspot-dev@openjdk.org shenandoah shenandoah-dev@openjdk.org labels Oct 16, 2023
@tstuefe
Copy link
Member Author

tstuefe commented Oct 16, 2023

/label remove hotspot
/label remove shenandoah
/label add hotspot-compiler

@openjdk openjdk bot removed the hotspot hotspot-dev@openjdk.org label Oct 16, 2023
@openjdk
Copy link

openjdk bot commented Oct 16, 2023

@tstuefe
The hotspot label was successfully removed.

@openjdk openjdk bot removed the shenandoah shenandoah-dev@openjdk.org label Oct 16, 2023
@openjdk
Copy link

openjdk bot commented Oct 16, 2023

@tstuefe
The shenandoah label was successfully removed.

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

openjdk bot commented Oct 16, 2023

@tstuefe
The hotspot-compiler label was successfully added.

@tstuefe tstuefe marked this pull request as ready for review October 17, 2023 09:11
@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 17, 2023
@mlbridge
Copy link

mlbridge bot commented Oct 17, 2023

Webrevs

@@ -1575,6 +1575,7 @@ void Parse::do_one_block() {
#endif //ASSERT

do_one_bytecode();
if (C->failing()) return;
Copy link
Member

Choose a reason for hiding this comment

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

I think you can simply call failing() here and potentially at other places as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay. Have not found any other places where that is possible though.

@tstuefe
Copy link
Member Author

tstuefe commented Oct 17, 2023

@TobiHartmann I used GraphKit::failing() as you suggested. One problem I see is that this relies on the local variable C in the Phase super class, and that depends on the phasenumber handed in to the Phase() constructor, and it could theoretically be null. But since all other places that call failing() don't seem to care either, I don't think its an issue, right?

@vnkozlov
Copy link
Contributor

@TobiHartmann I used GraphKit::failing() as you suggested. One problem I see is that this relies on the local variable C in the Phase super class, and that depends on the phasenumber handed in to the Phase() constructor, and it could theoretically be null. But since all other places that call failing() don't seem to care either, I don't think its an issue, right?

It is only nullptr for Compile class where you don't need C.

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.

Looks good.

@openjdk
Copy link

openjdk bot commented Oct 17, 2023

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

8318183: C2: VM may crash after hitting node limit

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 22 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 openjdk bot added the ready Pull request is ready to be integrated label Oct 17, 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 too.

@tstuefe
Copy link
Member Author

tstuefe commented Oct 18, 2023

Thank you @vnkozlov and @TobiHartmann !

/integrate

@openjdk
Copy link

openjdk bot commented Oct 18, 2023

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

openjdk bot commented Oct 18, 2023

@tstuefe Pushed as commit 31ef400.

💡 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-compiler hotspot-compiler-dev@openjdk.org integrated Pull request has been integrated
3 participants