Skip to content

8384099: C2: assert(_base == Long) failed on 32-bit systems#31076

Open
bulasevich wants to merge 1 commit intoopenjdk:masterfrom
bulasevich:JDK-8384099
Open

8384099: C2: assert(_base == Long) failed on 32-bit systems#31076
bulasevich wants to merge 1 commit intoopenjdk:masterfrom
bulasevich:JDK-8384099

Conversation

@bulasevich
Copy link
Copy Markdown
Contributor

@bulasevich bulasevich commented May 7, 2026

On 32-bit systems, CastP2X returns TypeInt instead of TypeLong, triggering assert(_base == Long) in MulLNode. Added ConvI2LNode (guarded by NOT_LP64) to fix the type mismatch:
MulLNode(CastP2XNode) -> MulLNode(ConvI2LNode(CastP2XNode))



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-8384099: C2: assert(_base == Long) failed on 32-bit systems (Bug - P3)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 31076

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper Bot commented May 7, 2026

👋 Welcome back bulasevich! 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
Copy Markdown

openjdk Bot commented May 7, 2026

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

@openjdk openjdk Bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label May 7, 2026
@openjdk
Copy link
Copy Markdown

openjdk Bot commented May 7, 2026

@bulasevich 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
Copy link
Copy Markdown

openjdk Bot commented May 7, 2026

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

@openjdk openjdk Bot added the rfr Pull request is ready for review label May 7, 2026
@mlbridge
Copy link
Copy Markdown

mlbridge Bot commented May 7, 2026

Webrevs

Copy link
Copy Markdown
Member

@shipilev shipilev left a comment

Choose a reason for hiding this comment

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

I looked around to see how safe it is, and have not been able to prove it.

We do not lose data here with P2X conversion (32bit -> 32bit), and I2L promotion should not hurt here. I do wonder if a X2P (really L2P?) conversion somewhere earlier actually loses the data when casting to 32-bit P...

@@ -1345,6 +1345,12 @@ Node* VPointer::make_pointer_expression(Node* iv_value, Node* ctrl) const {
variable = new CastP2XNode(ctrl, variable);
phase->register_new_node(variable, ctrl);
}
NOT_LP64( // On 32-bit CastP2X produces TypeInt
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

NOT_LP64 is really for single-line use. For multi-line, wrap it in #ifndef _LP64.

@shipilev
Copy link
Copy Markdown
Member

shipilev commented May 7, 2026

I suspect we are encountering "int that pretends to be in long group", because we are missing a case somewhere here:

case Op_CastX2P:
// A CastX2P indicates that we are pointing to native memory, where some long is cast to
// a pointer. In general, we have no guarantees about this long, and just take it as a
// terminal summand. A CastX2P can also be a good candidate for a native-memory "base".
if (!sub_expression_has_native_base_candidate(n->in(1))) {
// General case: take CastX2P as a terminal summand, it is a candidate for the "base".
break;
}
// Fall-through: we can find a more precise native-memory "base". We further decompose
// the CastX2P to find this "base" and any other offsets from it.
case Op_CastII:
case Op_CastLL:
case Op_ConvI2L:
// On 32bit systems we can also look through ConvL2I, since the final result will always
// be truncated back with ConvL2I. On 64bit systems we cannot decompose ConvL2I because
// such int values will eventually be expanded to long with a ConvI2L:
//
// valL = max_jint + 1
// ConvI2L(ConvL2I(valL)) = ConvI2L(min_jint) = min_jint != max_jint + 1 = valL
//
NOT_LP64( case Op_ConvL2I: )
{
// Decompose: look through.
Node* a = n->in(1);
int cast_int_group = int_group;
#ifdef _LP64
if (opc == Op_ConvI2L) {
assert(int_group == 0, "only find ConvI2L once");
// We just discovered a new ConvI2L, and this creates a new "int group".
cast_int_group = _next_int_group++;
}
#endif
_worklist.push(MemPointerRawSummand(a, scaleI, scaleL, cast_int_group));
callback.callback(n);
return;
}

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 rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

2 participants