JDK-8324517 : C2: crash in compiled code because of dependency on removed range check CastIIs
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 17,21,22,23
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2024-01-23
  • Updated: 2025-04-24
  • Resolved: 2024-05-16
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 23
23 b24Fixed
Related Reports
Causes :  
Cloners :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
$ java -XX:-TieredCompilation -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,TestArrayAccessAboveRCAfterRCCastIIEliminated::notInlined TestArrayAccessAboveRCAfterRCCastIIEliminated
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f084cb56650, pid=1861816, tid=1861817
#
# JRE version: OpenJDK Runtime Environment (23.0) (slowdebug build 23-internal-adhoc.roland.jdk-jdk2)
# Java VM: OpenJDK 64-Bit Server VM (slowdebug 23-internal-adhoc.roland.jdk-jdk2, mixed mode, compressed oops, compressed class ptrs, serial gc, linux-amd64)
# Problematic frame:
# J 12 c2 TestArrayAccessAboveRCAfterRCCastIIEliminated.test(IIIZ)V (104 bytes) @ 0x00007f084cb56650 [0x00007f084cb56580+0x00000000000000d0]

A range check in the test case is optimized out thanks to a type narrowed down by a dominating range check. The load that depends on the removed range check is kept below the dominating range check by a range check CastII. The range check CastII is removed after loop opts are over. As a consequence, the load can float above the dominating range check.
Comments
[21u-fix-no] I don't think we should backport this. It was backed out.
24-04-2025

[jdk21u-fix-request] Approval Request from Satyen Subramaniam for backport. Fix adjusts code to retain range check CastII nodes after loop opts until the end of optimizations, removing them at the end of all optimizations to avoid performance regressions. Risk: Medium. Tip change was merged in May 2024, but adjusting compilation logic. Adds test to help mitigate risk. Testing: * GHA Sanity Checks * Tier 1 and 2 tests locally
22-04-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk21u-dev/pull/1691 Date: 2025-04-22 16:43:00 +0000
22-04-2025

Changeset: ab8d7b0c Author: Roland Westrelin <roland@openjdk.org> Date: 2024-05-16 07:25:11 +0000 URL: https://git.openjdk.org/jdk/commit/ab8d7b0cedfaae124262325cd1d4b59cef996d85
16-05-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/18377 Date: 2024-03-19 13:21:49 +0000
19-03-2024