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

8331194: NPE in ArrayCreationTree.java with -XX:-UseCompressedOops #20087

Closed
wants to merge 9 commits into from

Conversation

JohnTortugo
Copy link
Contributor

@JohnTortugo JohnTortugo commented Jul 9, 2024

Please, review this PR to fix issue in debug information serialization encountered when RAM reduces a Phi for which one of the inputs is an object already scalar replaced.

Details:

Consider class Picture that has two reference fields, first and second of type Point. In a random method in the application an object obj of this class is created, and the fields of this object are initialized such that first is assigned a new object whereas second receives the output of a Phi node merging the object assigned to first and some other allocation. Also, assumes obj is used as debug information in an uncommon_trap and none of these objects escapes. I.e., we have a scenario like this:

Picture obj       = new Picture(); // allocation A
        obj.first = new Point(); // allocation B

Point    p2    = obj.first;
if (<cond>) p2 = new Point(); // allocation C

obj.second = p2;

<trap>

After one iteration of EA+SR, Allocation A will be scalar replaced and debug information in <Trap> adjusted accordingly. The description of field second in the debug information on <Trap> will, however, still involve a Phi node between allocation B and C. In the next iteration of EA+SR the Phi node for field second will be reduced by RAM and debug information will be adjusted accordingly. So far nothing is wrong.

The issue happens because the existing code in Process_OopMap_Node to serialize debug information was missing a check. Simply, the check for setting is_root of an ObjectValue wasn't checking that the ObjectValue might be a description of a field of a scalar replaced object. It was only checking whether ObjectValue was a local, stack or monitor. Consequently, the allocation assigned to obj.first (yes, first) was not being marked as root.

But the issue only manifested if the <trap> was exercised AND the result of <cond> was true. If the result of <cond> was false when the trap was exercised, then no problem would happen. The reason is, when <cond> is true the select method in ObjectMergeValue would flag, correctly, that the allocation inside the if needs to be rematerialized and the other input of the ObjectMergeValue shouldn't be rematerialized because _is_root == false, meaning it's just a candidate for rematerialization.

Fixing the check for setting _is_root solved the problem. The -XX:-UseCompressedOops wasn't directly related to the problem, it just caused DecodeN, EncodeP nodes to not show up in the graph and RAM consider the Phi for reduction.


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-8331194: NPE in ArrayCreationTree.java with -XX:-UseCompressedOops (Bug - P2)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 20087

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 9, 2024

👋 Welcome back cslucas! 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 Jul 9, 2024

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

8331194: NPE in ArrayCreationTree.java with -XX:-UseCompressedOops

Reviewed-by: kvn

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

  • a60608e: 8334169: Long arguments of attach operation are silently truncated on Windows
  • 59bf3d7: 8336080: Fix -Wzero-as-null-pointer-constant warnings in ClassLoaderStats ctor
  • 88eff4c: 8336421: ciMethod() constructor should use ConditionalMutexLocker(Compile_lock)
  • c99be35: 8336474: Problemlist compiler/interpreter/Test6833129 on x86_32
  • 419cc46: 8335533: OutOfMemoryError: Metaspace observed again on AIX in test RedefineLeakThrowable.java after JDK-8294960
  • 8feabc8: 8334057: JLinkReproducibleTest.java support receive test.tool.vm.opts
  • bc7cd42: 8314498: [macos] Transferring File objects to Finder fails
  • c8a95a7: 8072701: resume001 failed due to ERROR: timeout for waiting for a BreakpintEvent
  • 388fcf0: 8336349: Fix more simple -Wzero-as-null-pointer-constant warnings in C2 code
  • ab27aca: 8336297: C2: Fix -Wzero-as-null-pointer-constant warnings in derived Node ctors
  • ... and 127 more: https://git.openjdk.org/jdk/compare/77a7078b82fd0cb3cfa13685072f04fdef33758b...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) 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
Copy link

openjdk bot commented Jul 9, 2024

@JohnTortugo 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 Jul 9, 2024
@JohnTortugo JohnTortugo marked this pull request as ready for review July 9, 2024 21:56
@openjdk openjdk bot added the rfr Pull request is ready for review label Jul 9, 2024
@mlbridge
Copy link

mlbridge bot commented Jul 9, 2024

Webrevs

JohnTortugo and others added 2 commits July 10, 2024 09:15
Co-authored-by: Emanuel Peter <emanuel.peter@oracle.com>
Co-authored-by: Emanuel Peter <emanuel.peter@oracle.com>
@eme64
Copy link
Contributor

eme64 commented Jul 11, 2024

@JohnTortugo

This test is intended to "test" a transformation in C2, it won't fail if run in C1, but it won't actually test what's intended for. The flagless option is to make sure that C2 produce an IR graph that will trigger the optimization, same reasoning for all the "CompileCommand" options. I may remove the "vm.bits" part, I included it because of the "-UseCompressedOops".

The flagless requires will just mean that your test is not run if there are flags. So we still rely on the test configuration having some run without additional flags. So your requires seems pointless, especially because your test does not crash without it. Unless your test takes a lot of time and you are trying to conserve runtime.

About flags: I would just have a second run without any flags.

@vnkozlov
Copy link
Contributor

You can use -XX:+IgnoreUnrecognizedVMOptions flag instead of require "vm.bits".
Yes, do second run without flags.

I also suggest put test into corresponding directory compiler/escapeAnalysis. compiler/c2 is used for legacy or some C2 general tests.

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.

The fix looks fine. I have few comments.

src/hotspot/share/opto/machnode.hpp Outdated Show resolved Hide resolved
src/hotspot/share/opto/output.cpp Show resolved Hide resolved
@JohnTortugo
Copy link
Contributor Author

@vnkozlov @eme64 - I moved all tests related to "RAM" to the suggested folder and modified the test, added in this PR, to remove the flags as you suggested.

Please, let me ask more about configuring the test to run without flags. Without the flags, for instance, the CompileCommands, the IR graph will very likely not be in the shape that trigger the problem. Even with the CompileCommands, if some other flags included in the list of flags to run the test, the IR graph may also not be in the shape that will trigger the problem. Why run the test if it doesn't trigger the problem it was intended for? I'm probably missing something here.

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.

Please, reverse movement of old tests. We need to backport this fix into JDK 23 and for that we need only related test.
You can move them in separate RFE in JDK 24 (current mainline).

@vnkozlov
Copy link
Contributor

Why run the test if it doesn't trigger the problem it was intended for? I'm probably missing something here.

We hope to catch other issues with each new test. We are running with variety of flags combinations set by testing environment and a test may fail for different reason. It is all about code shape variations and flags combinations.

@JohnTortugo
Copy link
Contributor Author

Please, reverse movement of old tests. We need to backport this fix into JDK 23 and for that we need only related test. You can move them in separate RFE in JDK 24 (current mainline).

I reverted the move. I had forgot about the backport.

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.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jul 11, 2024
@vnkozlov
Copy link
Contributor

I will run testing with latest version. Tobias ran with version 0 and all passed. Since then there were only cosmetic changes but we still need to verify it.

@JohnTortugo
Copy link
Contributor Author

Sounds good. Thank you!

@vnkozlov
Copy link
Contributor

My testing passed.

@JohnTortugo, can you check why only 5 tests ran in GHA testing?

@JohnTortugo
Copy link
Contributor Author

@vnkozlov - I'm looking into that and I'll update here.

@JohnTortugo
Copy link
Contributor Author

@vnkozlov - I don't know why some of the checks didn't trigger automatically. It's still under investigation.

I manually triggered them, and they all passed.

@JohnTortugo
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Jul 15, 2024
@openjdk
Copy link

openjdk bot commented Jul 15, 2024

@JohnTortugo
Your change (at version 8486b4a) is now ready to be sponsored by a Committer.

@vnkozlov
Copy link
Contributor

@eme64 I you fine with current version?

continue;
}

ObjectValue* other = (ObjectValue*) sv_for_node_id(objs, n->_idx);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the cast here necessary? I see them generally in the file... but not sure why.

ObjectValue*
PhaseOutput::sv_for_node_id(GrowableArray<ScopeValue*> *objs, int id) {

Copy link
Contributor

Choose a reason for hiding this comment

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

Because objs array may contains 3 types of objects: ScopeValue, ObjectValue and ObjectMergeValue.
I would leave this code as it is for this PR but suggest to file followup RFE to clean this up.
Instead of such casts we should use as_ObjectValue() and as_ObjectMergeValue() which have asserts to check type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you @eme64 , @vnkozlov for reviewing. I created this RFE to remove the unnecessary casts: https://bugs.openjdk.org/browse/JDK-8336495

@eme64
Copy link
Contributor

eme64 commented Jul 16, 2024

@vnkozlov @JohnTortugo I'm not familiar enough with this part of the code, just gave some code style and testing suggestions. I was given something else that has higher priority, so maybe some one else can give the VM changes a review?

…nAndNestedScalarized.java

Co-authored-by: Emanuel Peter <emanuel.peter@oracle.com>
@openjdk openjdk bot removed sponsor Pull request is ready to be sponsored ready Pull request is ready to be integrated labels Jul 16, 2024
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.

Update is good.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jul 16, 2024
@JohnTortugo
Copy link
Contributor Author

/integrate

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

openjdk bot commented Jul 16, 2024

@JohnTortugo
Your change (at version 9726bd7) is now ready to be sponsored by a Committer.

@vnkozlov
Copy link
Contributor

/sponsor

@openjdk
Copy link

openjdk bot commented Jul 16, 2024

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

  • a60608e: 8334169: Long arguments of attach operation are silently truncated on Windows
  • 59bf3d7: 8336080: Fix -Wzero-as-null-pointer-constant warnings in ClassLoaderStats ctor
  • 88eff4c: 8336421: ciMethod() constructor should use ConditionalMutexLocker(Compile_lock)
  • c99be35: 8336474: Problemlist compiler/interpreter/Test6833129 on x86_32
  • 419cc46: 8335533: OutOfMemoryError: Metaspace observed again on AIX in test RedefineLeakThrowable.java after JDK-8294960
  • 8feabc8: 8334057: JLinkReproducibleTest.java support receive test.tool.vm.opts
  • bc7cd42: 8314498: [macos] Transferring File objects to Finder fails
  • c8a95a7: 8072701: resume001 failed due to ERROR: timeout for waiting for a BreakpintEvent
  • 388fcf0: 8336349: Fix more simple -Wzero-as-null-pointer-constant warnings in C2 code
  • ab27aca: 8336297: C2: Fix -Wzero-as-null-pointer-constant warnings in derived Node ctors
  • ... and 127 more: https://git.openjdk.org/jdk/compare/77a7078b82fd0cb3cfa13685072f04fdef33758b...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Jul 16, 2024

@vnkozlov @JohnTortugo Pushed as commit 005fb67.

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

@TobiHartmann
Copy link
Member

/backport :jdk23

@openjdk
Copy link

openjdk bot commented Jul 17, 2024

@TobiHartmann the backport was successfully created on the branch backport-TobiHartmann-005fb67e-jdk23 in my personal fork of openjdk/jdk. To create a pull request with this backport targeting openjdk/jdk:jdk23, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 005fb67e from the openjdk/jdk repository.

The commit being backported was authored by Cesar Soares Lucas on 16 Jul 2024 and was reviewed by Vladimir Kozlov.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk:

$ git fetch https://github.com/openjdk-bots/jdk.git backport-TobiHartmann-005fb67e-jdk23:backport-TobiHartmann-005fb67e-jdk23
$ git checkout backport-TobiHartmann-005fb67e-jdk23
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk.git backport-TobiHartmann-005fb67e-jdk23

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.

4 participants