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

8322282: Incorrect LoaderConstraintTable::add_entry after JDK-8298468 #17140

Closed

Conversation

shipilev
Copy link
Member

@shipilev shipilev commented Dec 18, 2023

As reported here:
https://mail.openjdk.org/pipermail/hotspot-compiler-dev/2023-December/071086.html

There is a regression introduced by JDK-8298468, which looks like a simple typo:
10737e1#diff-49d18b7f77db80ff67872c7db1e4c87e98a126e63fff5f63353e4406db332b19R343

Additional testing:

  • Linux x86_64 server fastdebug,tier{1,2,3}
  • Linux AArch64 server fastdebug,tier{1,2,3}

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-8322282: Incorrect LoaderConstraintTable::add_entry after JDK-8298468 (Bug - P2)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 17140

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 18, 2023

👋 Welcome back shade! 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 Dec 18, 2023
@openjdk
Copy link

openjdk bot commented Dec 18, 2023

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

@openjdk openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Dec 18, 2023
@mlbridge
Copy link

mlbridge bot commented Dec 18, 2023

Webrevs

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

I will need to check with the original fix but regardless this is obviously crying out for a regression test.

I and I still can't see any way that this leads to the NPE that was reported.

@shipilev
Copy link
Member Author

I will need to check with the original fix

Look at the change that introduced it: 10737e1?diff=unified&w=0#diff-49d18b7f77db80ff67872c7db1e4c87e98a126e63fff5f63353e4406db332b19R340-R344

...it looks like a typo, isn't it? The logic for that code is also understandable: if one LoaderConstraint is nullptr, we merge into another one.

I and I still can't see any way that this leads to the NPE that was reported.

I see compiler looks up classes from LoaderConstraintTable sometimes: ciEnv::get_klass_by_name_impl -> SystemDictionary::find_constrained_instance_or_array_klass. So it makes some sense to me that if we are reporting wrong result to compiler, it would then foobar the generated code by assuming something about the class that is not true.

@shipilev
Copy link
Member Author

shipilev commented Dec 18, 2023

this is obviously crying out for a regression test.

Yes, maybe. I would prefer to get the trivial fix that is known to affect real-world JDK 21 use without stalling on creating, debugging, reviewing the regression test. From my initial look, this thing would need a proper (fuzzing-like) test that shakes out constraint merging bugs, covering not only this particular path.

@dholmes-ora
Copy link
Member

Problem is without a proper regression test we only know that this change fixes one problem, but we don't know if it has any unexpected side-effects that the bug has been masking. I want a much better understanding of the bug before integrating the fix.

@shipilev
Copy link
Member Author

shipilev commented Dec 19, 2023

Problem is without a proper regression test we only know that this change fixes one problem, but we don't know if it has any unexpected side-effects that the bug has been masking. I want a much better understanding of the bug before integrating the fix.

From the strategical point of view, I understand the desire to understand the compile (mis)behavior better. But I think it is not a great tactical move, as it is not directly relevant to the fix.

Here is how I look at this problem:

  1. JDK-8298468 was supposed to be a cleanup. In other words, it is was supposed to be behavior-preserving.
  2. We have identified the hunk in the original changeset that violates the behavior-preserving property, which looks like a simple mistake.
  3. This fix restores the original behavior before JDK-8298468 in this hunk.

The good questions to ask ourselves at this point are: Would any of these facts change as the result of the deeper understanding of how exactly this mistake breaks the compiler? Would there be a situation where we decide that going with this fix is not a good idea? Would we be deeply investigating the implications of this mistake if it was caught during code review, instead of just fixing it and moving on?

I think the probability of answering "yes" to all these questions is very low. In fact the only way I see that happening if we discover that the whole JDK-8298468 is wrong and needs to be backed out. But if we (I argue, reasonably) answer "no" to these questions, then holding off from integrating this fix before we gain more understanding how exactly it breaks compiler gains us nothing. But it delays fixing JDK 23, 23, 21 sooner, which is even more important when there is an actual customer-visible breakage reported on JDK 21.

In other words, could there be a situation where this mistake exposes some deeper problem in Hotspot? Yes, that might happen, but it changes nothing about the actual behavior-breaking impact of JDK-8298468 this point fix resolves. One can always follow-up deeper on these problems by reverting the fix in mainline and then investigating. I would further suspect that this is a kind of "garbage in, garbage out" scenario, where we report wrong metadata to the compiler, and it breaks in fascinating ways. We know it happens in other funky scenarios like feeding the unverifiable bytecode, for example.

So, I propose we do not quibble over this fix.

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 16, 2024

@shipilev This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@shipilev
Copy link
Member Author

Not now, bot.

Copy link
Member

@simonis simonis left a comment

Choose a reason for hiding this comment

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

Obviously a typo which we should fix as quickly as possible.
Looks good to me.

@simonis
Copy link
Member

simonis commented Jan 17, 2024

@coleenp can you please take a quick look at this fix which is a regression of JDK-8298468.

@openjdk
Copy link

openjdk bot commented Jan 17, 2024

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

8322282: Incorrect LoaderConstraintTable::add_entry after JDK-8298468

Reviewed-by: dholmes, simonis, 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 no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential 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 Jan 17, 2024
Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

We will continue to think about how to produce a regression test for this, but the fix is cleared for integration.

Thanks

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.

Yes, this looks correct. Thanks to Antoine for reporting it and your diagnosis.

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.

You probably should update the copyright to 2024.

@shipilev
Copy link
Member Author

Thank you all! I merged from master, fixed the copyright year, and would integrate as soon as light testing turns green.

@shipilev
Copy link
Member Author

Testing is clean.

/integrate

@openjdk
Copy link

openjdk bot commented Jan 22, 2024

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

  • be943a9: 8321984: IGV: Upgrade to Netbeans Platform 20
  • d3b2ac1: 8314186: runtime/8176717/TestInheritFD.java failed with "Log file was leaked"
  • 72f1990: 8323057: Recoverable errors may be reported before unrecoverable errors when annotation processing is skipped
  • c84af49: 8324129: C2: Remove some ttyLocker usages in preparation for JDK-8306767
  • fd37262: 8323748: RISC-V: Add Zfh probe code
  • 76afa02: 8322572: AllocationMergesTests.java fails with "IRViolationException: There were one or multiple IR rule failures."

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Jan 22, 2024

@shipilev Pushed as commit bde650f.

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

@shipilev shipilev deleted the JDK-8322282-incorrect-load-constraint branch January 31, 2024 16:13
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
4 participants