ADDITIONAL SYSTEM INFORMATION :
wsl2-ubuntu 22.04
Linux 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
java version "1.8.0_451"
Java(TM) SE Runtime Environment (build 1.8.0_451-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.451-b10, mixed mode)
java version "11.0.27" 2025-04-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.27+8-LTS-232)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.27+8-LTS-232, mixed mode)
java version "17.0.15" 2025-04-15 LTS
Java(TM) SE Runtime Environment (build 17.0.15+9-LTS-241)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.15+9-LTS-241, mixed mode, sharing)
java version "21.0.7" 2025-04-15 LTS
Java(TM) SE Runtime Environment (build 21.0.7+8-LTS-245)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.7+8-LTS-245, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
The following test program will crash Java Runtime Environment in JDK 21. It also crashes in JDK 8, 11, 17.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Using JDK 21, run the following command:
```
javac Test.java
java Test
```
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The program should throw an exception.
ACTUAL -
The program will crash Java Runtime Environment.
```
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007fc185e470b5, pid=6244, tid=6245
#
# JRE version: Java(TM) SE Runtime Environment (21.0.7+8) (build 21.0.7+8-LTS-245)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (21.0.7+8-LTS-245, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V [libjvm.so+0xecf0b5] Unsafe_AllocateInstance+0x95
...
```
---------- BEGIN SOURCE ----------
class Test {
public static void main(String[] args) {
try {
java.lang.reflect.Field unsafeField = sun.misc.Unsafe.class.getDeclaredField("theUnsafe");
unsafeField.setAccessible(true);
Object unsafeInstance = unsafeField.get(null);
java.lang.Class<?> abstractClass = null;
java.lang.Object instance = sun.misc.Unsafe.class.getMethod("allocateInstance", java.lang.Class.class).invoke(unsafeInstance, abstractClass);
} catch (Exception e) {
e.printStackTrace();
}
}
}
---------- END SOURCE ----------
wsl2-ubuntu 22.04
Linux 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
java version "1.8.0_451"
Java(TM) SE Runtime Environment (build 1.8.0_451-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.451-b10, mixed mode)
java version "11.0.27" 2025-04-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.27+8-LTS-232)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.27+8-LTS-232, mixed mode)
java version "17.0.15" 2025-04-15 LTS
Java(TM) SE Runtime Environment (build 17.0.15+9-LTS-241)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.15+9-LTS-241, mixed mode, sharing)
java version "21.0.7" 2025-04-15 LTS
Java(TM) SE Runtime Environment (build 21.0.7+8-LTS-245)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.7+8-LTS-245, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
The following test program will crash Java Runtime Environment in JDK 21. It also crashes in JDK 8, 11, 17.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Using JDK 21, run the following command:
```
javac Test.java
java Test
```
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The program should throw an exception.
ACTUAL -
The program will crash Java Runtime Environment.
```
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007fc185e470b5, pid=6244, tid=6245
#
# JRE version: Java(TM) SE Runtime Environment (21.0.7+8) (build 21.0.7+8-LTS-245)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (21.0.7+8-LTS-245, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V [libjvm.so+0xecf0b5] Unsafe_AllocateInstance+0x95
...
```
---------- BEGIN SOURCE ----------
class Test {
public static void main(String[] args) {
try {
java.lang.reflect.Field unsafeField = sun.misc.Unsafe.class.getDeclaredField("theUnsafe");
unsafeField.setAccessible(true);
Object unsafeInstance = unsafeField.get(null);
java.lang.Class<?> abstractClass = null;
java.lang.Object instance = sun.misc.Unsafe.class.getMethod("allocateInstance", java.lang.Class.class).invoke(unsafeInstance, abstractClass);
} catch (Exception e) {
e.printStackTrace();
}
}
}
---------- END SOURCE ----------
- relates to
-
JDK-8360137 Segmentation fault in JDK 8/11 when using Unsafe.allocateInstance() in loops
-
- Open
-