JDK-8319690 : [AArch64] C2 compilation hits offset_ok_for_immed: assert "c2 compiler bug"
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 15,17,21,22
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • CPU: aarch64
  • Submitted: 2023-11-08
  • Updated: 2025-04-28
  • Resolved: 2024-03-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 17 JDK 21 JDK 23
17.0.16Fixed 21.0.8Fixed 23 b13Fixed
Related Reports
Blocks :  
Description
Fails only with debug, in product we simply "legitimize_address", which inserts a LEA instruction to handle the offset that seems to require more bits than expected.

I reproduced it like this:

/scratch/empeter/jdk-22/fastdebug/bin/java --add-modules java.base --add-exports java.base/jdk.internal.misc=ALL-UNNAMED --add-exports java.base/jdk.internal.util=ALL-UNNAMED -Xcomp -XX:-TieredCompilation -XX:MaxHeapSize=805306368 -XX:MaxRAMPercentage=6.250000 "-XX:CompileCommand=compileonly,Test*::<clinit>" -XX:CompileCommand=printcompilation,Test*::* Test.java


CompileCommand: compileonly Test*.<clinit> bool compileonly = true
CompileCommand: PrintCompilation Test*.* bool PrintCompilation = true
2676  105    b        Test::<clinit> (7 bytes)
2681  107    b        Test$A::<clinit> (44 bytes)
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/opt/mach5/mesos/work_dir/slaves/afbc6042-3a24-4198-9369-18c663a3f74c-S45433/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/10db9974-e79d-49fb-b2a8-fc7dc441748b/runs/b6e6453a-891d-4130-a6a2-b2df8c26912c/workspace/open/src/hotspot/cpu/aarch64/aarch64.ad:2741), pid=134414, tid=134428
#  assert(Address::offset_ok_for_immed(addr.offset(), exact_log2(size_in_memory))) failed: c2 compiler bug
#
# JRE version: Java(TM) SE Runtime Environment (22.0+22) (fastdebug build 22-ea+22-1754)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 22-ea+22-1754, compiled mode, sharing, compressed oops, compressed class ptrs, g1 gc, linux-aarch64)
# Problematic frame:
# V  [libjvm.so+0x424248]  loadStore(C2_MacroAssembler, void (MacroAssembler::*)(Register, Address const&), Register, int, Register, int, int, int, int) [clone .constprop.1]+0x1f8
#
# Core dump will be written. Default location: /scratch/empeter/jdk-fork1/build/linux-aarch64-slowdebug/jdk/bin/core.134414
#
# An error report file with more information is saved as:
# /scratch/empeter/jdk-fork1/build/linux-aarch64-slowdebug/jdk/bin/hs_err_pid134414.log
#
# Compiler replay data is saved as:
# /scratch/empeter/jdk-fork1/build/linux-aarch64-slowdebug/jdk/bin/replay_pid134414.log
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
#
Aborted (core dumped)

Comments
[jdk21u-fix-request] Approval Request from Satyen Subramaniam for backport. Addresses bug by removing an assert and adding test. Risk: Low. Tip change was merged in March 2024 and adds a test to confirm correct functionality. Only relevant to fastdebug builds. Testing: * GHA Sanity Checks * Tier 1 and 2 tests locally
25-04-2025

[jdk17u-fix-request] Approval Request from Satyen Subramaniam for backport. Addresses bug by removing an assert and adding test. Risk: Low. Tip change was merged in March 2024 and adds a test to confirm correct functionality. Only relevant to fastdebug builds. Testing: * GHA Sanity Checks * Tier 1 and 2 tests locally
25-04-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk21u-dev/pull/1715 Date: 2025-04-25 16:41:16 +0000
25-04-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk17u-dev/pull/3532 Date: 2025-04-25 16:41:22 +0000
25-04-2025

Changeset: 98f0b866 Author: Emanuel Peter <epeter@openjdk.org> Date: 2024-03-05 13:37:08 +0000 URL: https://git.openjdk.org/jdk/commit/98f0b86641d84048949ed3da1cb14f3820b01c12
05-03-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/18103 Date: 2024-03-04 09:46:56 +0000
04-03-2024

In JDK-8318446 I create unaligned/mismatched stores that are bigger than the underlying arrays element type. But we can do the same with Unsafe, and reproduce the bug in mainline.
08-11-2023

ILW = C2 compilation hits assert (debug builds only), single test with Unsafe, no workaround but disable compilation of affected method = MLM = P4
08-11-2023