Skip to content

8374783: C2 compilation asserts with "slice of address and input slice don't match"#31500

Open
robcasloz wants to merge 10 commits into
openjdk:masterfrom
robcasloz:JDK-8374783-slices-do-not-match-selective-cleanup
Open

8374783: C2 compilation asserts with "slice of address and input slice don't match"#31500
robcasloz wants to merge 10 commits into
openjdk:masterfrom
robcasloz:JDK-8374783-slices-do-not-match-selective-cleanup

Conversation

@robcasloz

@robcasloz robcasloz commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

This changeset forces an incremental inlining cleanup whenever an incrementally inlined call exposes an address where the offset becomes constant. This is necessary to prevent slice mismatches when parsing subsequent accesses to the address due to outdated IGVN-recorded address type information, see more details in the JBS issue. If not prevented, such mismatches can lead to e.g. incorrect memory graphs, as illustrated in the included test file.

This solution is the most effective and least intrusive one among a few evaluated options, see JBS issue.

Testing

  • tier1-4, stress test
  • original test (applications/ctw/modules/jdk_jpackage.java)
  • LLM-guided fuzzing (linux-x64 only)

Thanks to @iwanowww for useful discussions and suggestions!



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-8374783: C2 compilation asserts with "slice of address and input slice don't match" (Bug - P3)(⚠️ The fixVersion in this issue is [27] but the fixVersion in .jcheck/conf is 28, a new backport will be created when this pr is integrated.)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 31500

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper

bridgekeeper Bot commented Jun 12, 2026

Copy link
Copy Markdown

👋 Welcome back rcastanedalo! 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 commented Jun 12, 2026

Copy link
Copy Markdown

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk

openjdk Bot commented Jun 12, 2026

Copy link
Copy Markdown

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

  • core-libs
  • hotspot

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 commented Jun 12, 2026

Copy link
Copy Markdown

The total number of required reviews for this PR has been set to 2 based on the presence of this label: hotspot. This can be overridden with the /reviewers command.

@robcasloz robcasloz force-pushed the JDK-8374783-slices-do-not-match-selective-cleanup branch from 52ad24a to aca441c Compare June 12, 2026 12:25
@robcasloz

Copy link
Copy Markdown
Contributor Author

/label remove core-libs,hotspot

@openjdk

openjdk Bot commented Jun 12, 2026

Copy link
Copy Markdown

@robcasloz
The core-libs label was successfully removed.

The hotspot label was successfully removed.

@robcasloz

Copy link
Copy Markdown
Contributor Author

/label add hotspot-compiler

@openjdk

openjdk Bot commented Jun 12, 2026

Copy link
Copy Markdown

@robcasloz
The hotspot-compiler label was successfully added.

@robcasloz robcasloz marked this pull request as ready for review June 12, 2026 13:56
@openjdk openjdk Bot added the rfr Pull request is ready for review label Jun 12, 2026
@mlbridge

mlbridge Bot commented Jun 12, 2026

Copy link
Copy Markdown

Webrevs

@merykitty

Copy link
Copy Markdown
Member

I think this does not cover all the cases. What if we have an Object + 8, then late inlining reveals that Object here really is an Integer, which means the access is really to Integer.value, will that raise a similar issue?

@robcasloz

Copy link
Copy Markdown
Contributor Author

I think this does not cover all the cases. What if we have an Object + 8, then late inlining reveals that Object here really is an Integer, which means the access is really to Integer.value, will that raise a similar issue?

Thanks Quan, I have not found any case where discovering the base address type after late inlining triggers this issue, because there seems to always be some casting that blocks the reuse of the unsafe load's AddP node by the subsequent memory access. I have added a test case illustrating this scenario (commit e6bde69), here is how the addresses look like when the second memory access (154 LoadI) is parsed:

Screenshot from 2026-06-15 12-12-00

I have done some fuzzing to try to find some variant of this case where both AddP nodes can be unified but could not find any. Let me know if you had a different scenario in mind.

@robcasloz

Copy link
Copy Markdown
Contributor Author

I just added yet another test variant using an array instead of a class instance (commit c605fa2). In this case, no slice mismatch occurs either, because both the offset-known and unknown address types map to the same memory slice. Even thought it is not strictly necessary, the changeset enforces a cleanup between the incremental inlining steps in this case as well.

@iwanowww iwanowww left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overall, looks reasonable, but I'm not persuaded yet the base case is not affected in a similar manner (Object -> A transition during late inlining).

As an alternative way to fix the problem, the result can be wrapped into an Opaque flavor which vanished during the very first IGVN pass. In general, it would provoke fewer cleanup passes and can be applied in broader than strictly required scenarios (if it turns out it's tricky to detect affected cases).

// memory slice corresponding to *any* field of a class K is not the same as
// the slice corresponding to a specific field of K. This mismatch can in
// its turn lead to e.g. incorrect memory graphs.
if (C->inlining_incrementally() &&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is C->inlining_incrementally() == true? It's CallGenerator::do_late_inline_helper() after all.

// the slice corresponding to a specific field of K. This mismatch can in
// its turn lead to e.g. incorrect memory graphs.
if (C->inlining_incrementally() &&
!result->is_top() && result->is_Con() && result->bottom_type()->isa_intptr_t()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

isa_intptr_t() looks fishy. I don't see how it depends on bitness. It originates from byte codes where sizes are explicit and hard-coded (Java int vs long).

What about cases involving int->long casts? Does it catch them?

@@ -729,6 +729,27 @@ void CallGenerator::do_late_inline_helper() {
}
C->set_inlining_progress(true);
C->set_do_cleanup(kit.stopped()); // path is dead; needs cleanup

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I suggest to extract the code into a helper method (e.g., needs_cleanup) and call it from here (C->set_do_cleanup(needs_cleanup(...));)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-compiler [email protected] rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

3 participants