-
-
Notifications
You must be signed in to change notification settings - Fork 14
Description
Please provide a brief summary of the bug
I encountered a JVM crash (SIGFPE) when running a specific Java program using OpenJDK 8 (Temurin build).
The crash occurs in the C2 (Server) compiler thread while executing the Test::mainTest method. The error signal SIGFPE suggests an Integer Division by Zero issue in the JIT-generated code, although the loop variable i11 in the source code (70 down to 2) does not appear to reach 0.
The issue does not reproduce on OpenJ9 (which runs successfully).
Did you test with the latest update version?
- Yes
Please provide steps to reproduce where possible
public class Test {
public static final int N = 400;
public static int iArrFld[][] = new int[N][N];
public static void vMeth(int i3) {}
public static float fMeth() {
((java.util.function.Function<Object[], Object>) (args) -> {
try {
ClassLoader cl = new _Fuzz_Loader();
Class<?> cls = cl.loadClass("Test");
java.lang.reflect.Method m = cls.getMethod("vMeth", new Class[]{int.class});
return m.invoke(null, args);
} catch (Throwable e) {
throw new RuntimeException(e);
}
}).apply(new Object[]{45370});
return ((float) (1));
}
public void mainTest(String[] strArr1) {
for (int i = 5; i < 367; ++i) {
fMeth();
for (int i11 = 70; i11 > 1; i11 -= 2) {
Test.iArrFld[i][i] = 35494 % i11;
for (int i13 = 3; i13 > 1; i13--) {
switch ((i11 % 10) + 81) {
case 83 :
Test.iArrFld[i11 + 1][i - 1] += 1;
break;
}
}
}
}
}
public static void main(String[] strArr) {
Test _instance = new Test();
for (int i = 0; i < 10; i++) {
_instance.mainTest(strArr);
}
}
private static class _Fuzz_Loader extends ClassLoader {
public Class loadClass(String name) throws ClassNotFoundException {
if (!name.startsWith("java.") && name.startsWith("")) {
try {
String path = "/" + name.replace('.', '/') + ".class";
java.io.InputStream is = getClass().getResourceAsStream(path);
if (is == null) return super.loadClass(name);
java.io.ByteArrayOutputStream buffer = new java.io.ByteArrayOutputStream();
int nRead; byte[] data = new byte[1024];
while ((nRead = is.read(data, 0, data.length)) != -1)
buffer.write(data, 0, nRead);
buffer.flush(); byte[] b = buffer.toByteArray();
return defineClass(name, b, 0, b.length);
} catch (Exception e) {
throw new ClassNotFoundException(name, e);
}
} return super.loadClass(name);
}
}
}
Steps to Reproduce
- Save the provided source code as Test.java.
- Compile: javac Test.java
- Run: java Test
Expected Results
The program should execute the loops and exit silently (or print output if added), without crashing the JVM.
Actual Results
The JVM crashes with SIGFPE.
Crash Log Snippet (hs_err_pid.log header):
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGFPE (0x8) at pc=0x00007f2bd9498949, pid=9309, tid=0x00007f2bef7ff640
#
# JRE version: OpenJDK Runtime Environment (8.0_472-b08) (build 1.8.0_472-b08)
# Java VM: OpenJDK 64-Bit Server VM (25.472-b08 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# J 544 C2 Test.mainTest([Ljava/lang/String;)V (107 bytes) @ 0x00007f2bd9498949 [0x00007f2bd9498640+0x309]
What Java Version are you using?
openjdk version "1.8.0_472"
OpenJDK Runtime Environment (Temurin)(build 1.8.0_472-b08)
OpenJDK 64-Bit Server VM (Temurin)(build 25.472-b08, mixed mode)
What is your operating system and platform?
System Version: Ubuntu 22.04.4 LTS
Kernel Version: 4.15.0-45-generic
Chip: Intel(R) Xeon(R) CPU E5-2640 v4 @ 2.40GHz
Total Number of Cores: 40 (10 physical x 2 logical)
Memory: 125Gi
How did you install Java?
I used a binary archive (tar.gz)