-
Bug
-
Resolution: Fixed
-
P3
-
8u361, 11, 17, 20, 21
-
b04
-
x86
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8317476 | 21.0.2 | Goetz Lindenmaier | P3 | Resolved | Fixed | b02 |
JDK-8316407 | 17.0.10-oracle | Tobias Hartmann | P3 | Resolved | Fixed | b01 |
JDK-8317650 | 17.0.10 | Goetz Lindenmaier | P3 | Resolved | Fixed | b01 |
The attached code, which is just standard Java code, causes a JVM crash.
It can be reproduced with the code below.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached code in "TestBug" class.
This code loops 10000 times, calling the doSomething() method each time.
The JVM will normally crash after less than 5000 iterations.
Most of the code needed in the doSomething() method needs to be present in order to reproduce the bug. If the if or try-catch or while is removed, the bug will not occur.
I retained the code inside the loop in order that the loop is not empty, to avoid unnecessary optimisations.
ACTUAL -
JVM crashes after less than 5000 iterations.
If I increase the value of the requiredLength argument (e.g. to 4000), then the crash occurs after less iterations.
The content of hs_err_pid16440.log is pasted into the "Confidential Field (hs_err file)" field.
The following was reported:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (c1_LIRAssembler.cpp:867), pid=16440, tid=0x000011dc
# Error: ShouldNotReachHere()
#
# JRE version: Java(TM) SE Runtime Environment (8.0) (build 1.8.0_361-b09)
# Java VM: Java HotSpot(TM) Client VM (25.361-b09 mixed mode, sharing windows-x86 )
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\<filepath>\hs_err_pid16440.log
#
# Compiler replay data is saved as:
# C:\<filepath>\replay_pid16440.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
#
---------- BEGIN SOURCE ----------
public class TestBug {
private static int index = 0;
public static void main(String[] args) {
for (int i = 0; i < 10000; i++) {
doSomething(new byte[] { }, 4);
}
}
private static void doSomething(byte[] source, int requiredLength) {
System.out.println(index++);
if (requiredLength < 0) {
requiredLength = 0;
}
boolean [] returnArray = new boolean[requiredLength];
int index = 0;
try {
for (byte b : source) {
if (index == returnArray.length) {
break;
}
}
}
catch (ArrayIndexOutOfBoundsException e) {
// ignore
}
while (index < returnArray.length) {
returnArray[index++] = false;
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
If I replace the for-each loop with a standard indexed for loop, the issue does not occur.
- backported by
-
JDK-8316407 C1: ShortLoopOptimizer might lift instructions before their inputs
- Resolved
-
JDK-8317476 C1: ShortLoopOptimizer might lift instructions before their inputs
- Resolved
-
JDK-8317650 C1: ShortLoopOptimizer might lift instructions before their inputs
- Resolved
- links to
-
Commit openjdk/jdk17u-dev/273872c7
-
Commit openjdk/jdk21u/48fa33a9
-
Commit openjdk/jdk/73d7aa1d
-
Review openjdk/jdk17u-dev/1826
-
Review openjdk/jdk21u/193
-
Review openjdk/jdk/14492