-
Bug
-
Resolution: Fixed
-
P3
-
21, 22
-
b14
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8323359 | 21.0.3-oracle | Aleksey Shipilev | P3 | Resolved | Fixed | b01 |
JDK-8319723 | 21.0.2 | Aleksey Shipilev | P3 | Resolved | Fixed | b07 |
This code crashes the JVM:
public class CrashExample {
private static final VarHandle byteHandle = MethodHandles.memorySegmentViewVarHandle(ValueLayout.JAVA_BYTE);
private static final long len = 100;
private static final byte CR = (byte) '\r';
private static final byte LF = (byte) '\n';
public static void main(String[] args) {
for(int round = 0; round < 1000; round++) {
try(Arena arena = Arena.ofConfined()) {
MemorySegment memorySegment = arena.allocateArray(ValueLayout.JAVA_BYTE, len);
for(int i = 0; i < 100000; i++) {
int index = i % 99;
byteHandle.set(memorySegment, index, CR);
byteHandle.set(memorySegment, index + 1, LF);
byte[] bytes = readUntil(memorySegment, CR, LF);
}
}
}
}
private static byte[] readUntil(MemorySegment segment, byte... separators) {
for(long cur = 0; cur <= segment.byteSize() - separators.length; cur++) {
if(matches(segment, cur, separators)) {
return segment.asSlice(0, cur).toArray(ValueLayout.JAVA_BYTE);
}
}
return null;
}
public static boolean matches(MemorySegment m, long offset, byte[] bytes) {
for(int index = 0; index < bytes.length; index++) {
if ((byte) byteHandle.get(m, offset + index) != bytes[index]) {
return false;
}
}
return true;
}
}
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (/oracle/jdk/open/src/hotspot/share/opto/loopnode.cpp:1269), pid=1045773, tid=1045790
# assert(ok) failed: inconsistent: was tested before
#
# JRE version: Java(TM) SE Runtime Environment (22.0) (fastdebug build 22-internal-2023-08-07-1346088.tobias...)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 22-internal-2023-08-07-1346088.tobias..., mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V [libjvm.so+0x1292fe2] PhaseIdealLoop::transform_long_range_checks(int, Node_List const&, Node*, Node*, Node*, Node*, LoopNode*)+0x1272
Current CompileTask:
C2: 752 589 % ! 4 CrashExample::main @ 29 (136 bytes)
Stack: [0x00007f072267e000,0x00007f072277f000], sp=0x00007f0722779b20, free space=1006k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x1292fe2] PhaseIdealLoop::transform_long_range_checks(int, Node_List const&, Node*, Node*, Node*, Node*, LoopNode*)+0x1272 (loopnode.cpp:1269)
V [libjvm.so+0x129862e] PhaseIdealLoop::create_loop_nest(IdealLoopTree*, Node_List&)+0xf4e (loopnode.cpp:1047)
V [libjvm.so+0x126f388] IdealLoopTree::iteration_split_impl(PhaseIdealLoop*, Node_List&)+0x318 (loopTransform.cpp:3602)
V [libjvm.so+0x126f6b7] IdealLoopTree::iteration_split(PhaseIdealLoop*, Node_List&)+0x117 (loopTransform.cpp:3726)
V [libjvm.so+0x126f5d3] IdealLoopTree::iteration_split(PhaseIdealLoop*, Node_List&)+0x33 (loopTransform.cpp:3710)
V [libjvm.so+0x129d6d7] PhaseIdealLoop::build_and_optimize()+0xca7 (loopnode.cpp:4604)
V [libjvm.so+0x9eff5e] PhaseIdealLoop::optimize(PhaseIterGVN&, LoopOptsMode)+0x3ce (loopnode.hpp:1114)
V [libjvm.so+0x9ec9ef] Compile::Optimize()+0xdaf (compile.cpp:2166)
V [libjvm.so+0x9eed10] Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x1b60 (compile.cpp:850)
V [libjvm.so+0x84a5db] C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x13b (c2compiler.cpp:119)
V [libjvm.so+0x9fac37] CompileBroker::invoke_compiler_on_method(CompileTask*)+0x977 (compileBroker.cpp:2276)
V [libjvm.so+0x9fb978] CompileBroker::compiler_thread_loop()+0x5f8 (compileBroker.cpp:1944)
V [libjvm.so+0xeb883c] JavaThread::thread_main_inner()+0xcc (javaThread.cpp:720)
V [libjvm.so+0x179b04a] Thread::call_run()+0xba (thread.cpp:217)
V [libjvm.so+0x1499d01] thread_native_entry(Thread*)+0x121 (os_linux.cpp:783)
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f3f941154b7, pid=1045889, tid=1045906
#
# JRE version: Java(TM) SE Runtime Environment (22.0) (build 22-internal-2023-08-09-1155514.tobias...)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (22-internal-2023-08-09-1155514.tobias..., mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V [libjvm.so+0x4084b7] AddNode::IdealIL(PhaseGVN*, bool, BasicType)+0x37
Current CompileTask:
C2: 405 632 % ! 4 CrashExample::main @ 29 (136 bytes)
Stack: [0x00007f3f65eff000,0x00007f3f66000000], sp=0x00007f3f65ffb7e0, free space=1009k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x4084b7] AddNode::IdealIL(PhaseGVN*, bool, BasicType)+0x37 (addnode.cpp:265)
V [libjvm.so+0xd11bde] PhaseIterGVN::transform_old(Node*)+0x9e (phaseX.cpp:667)
V [libjvm.so+0xd0db09] PhaseIterGVN::optimize()+0xf9 (phaseX.cpp:1045)
V [libjvm.so+0x6445af] Compile::Optimize()+0x151f (loopnode.hpp:1199)
V [libjvm.so+0x6456c2] Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0xed2 (compile.cpp:850)
V [libjvm.so+0x574079] C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x159 (c2compiler.cpp:119)
V [libjvm.so+0x64b2fe] CompileBroker::invoke_compiler_on_method(CompileTask*)+0xa9e (compileBroker.cpp:2276)
V [libjvm.so+0x64e558] CompileBroker::compiler_thread_loop()+0x698 (compileBroker.cpp:1944)
V [libjvm.so+0x8f8038] JavaThread::thread_main_inner() [clone .part.0]+0xb8 (javaThread.cpp:720)
V [libjvm.so+0xe9aa18] Thread::call_run()+0xa8 (thread.cpp:217)
V [libjvm.so+0xcbfaaa] thread_native_entry(Thread*)+0xda (os_linux.cpp:783)
public class CrashExample {
private static final VarHandle byteHandle = MethodHandles.memorySegmentViewVarHandle(ValueLayout.JAVA_BYTE);
private static final long len = 100;
private static final byte CR = (byte) '\r';
private static final byte LF = (byte) '\n';
public static void main(String[] args) {
for(int round = 0; round < 1000; round++) {
try(Arena arena = Arena.ofConfined()) {
MemorySegment memorySegment = arena.allocateArray(ValueLayout.JAVA_BYTE, len);
for(int i = 0; i < 100000; i++) {
int index = i % 99;
byteHandle.set(memorySegment, index, CR);
byteHandle.set(memorySegment, index + 1, LF);
byte[] bytes = readUntil(memorySegment, CR, LF);
}
}
}
}
private static byte[] readUntil(MemorySegment segment, byte... separators) {
for(long cur = 0; cur <= segment.byteSize() - separators.length; cur++) {
if(matches(segment, cur, separators)) {
return segment.asSlice(0, cur).toArray(ValueLayout.JAVA_BYTE);
}
}
return null;
}
public static boolean matches(MemorySegment m, long offset, byte[] bytes) {
for(int index = 0; index < bytes.length; index++) {
if ((byte) byteHandle.get(m, offset + index) != bytes[index]) {
return false;
}
}
return true;
}
}
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (/oracle/jdk/open/src/hotspot/share/opto/loopnode.cpp:1269), pid=1045773, tid=1045790
# assert(ok) failed: inconsistent: was tested before
#
# JRE version: Java(TM) SE Runtime Environment (22.0) (fastdebug build 22-internal-2023-08-07-1346088.tobias...)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 22-internal-2023-08-07-1346088.tobias..., mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V [libjvm.so+0x1292fe2] PhaseIdealLoop::transform_long_range_checks(int, Node_List const&, Node*, Node*, Node*, Node*, LoopNode*)+0x1272
Current CompileTask:
C2: 752 589 % ! 4 CrashExample::main @ 29 (136 bytes)
Stack: [0x00007f072267e000,0x00007f072277f000], sp=0x00007f0722779b20, free space=1006k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x1292fe2] PhaseIdealLoop::transform_long_range_checks(int, Node_List const&, Node*, Node*, Node*, Node*, LoopNode*)+0x1272 (loopnode.cpp:1269)
V [libjvm.so+0x129862e] PhaseIdealLoop::create_loop_nest(IdealLoopTree*, Node_List&)+0xf4e (loopnode.cpp:1047)
V [libjvm.so+0x126f388] IdealLoopTree::iteration_split_impl(PhaseIdealLoop*, Node_List&)+0x318 (loopTransform.cpp:3602)
V [libjvm.so+0x126f6b7] IdealLoopTree::iteration_split(PhaseIdealLoop*, Node_List&)+0x117 (loopTransform.cpp:3726)
V [libjvm.so+0x126f5d3] IdealLoopTree::iteration_split(PhaseIdealLoop*, Node_List&)+0x33 (loopTransform.cpp:3710)
V [libjvm.so+0x129d6d7] PhaseIdealLoop::build_and_optimize()+0xca7 (loopnode.cpp:4604)
V [libjvm.so+0x9eff5e] PhaseIdealLoop::optimize(PhaseIterGVN&, LoopOptsMode)+0x3ce (loopnode.hpp:1114)
V [libjvm.so+0x9ec9ef] Compile::Optimize()+0xdaf (compile.cpp:2166)
V [libjvm.so+0x9eed10] Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x1b60 (compile.cpp:850)
V [libjvm.so+0x84a5db] C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x13b (c2compiler.cpp:119)
V [libjvm.so+0x9fac37] CompileBroker::invoke_compiler_on_method(CompileTask*)+0x977 (compileBroker.cpp:2276)
V [libjvm.so+0x9fb978] CompileBroker::compiler_thread_loop()+0x5f8 (compileBroker.cpp:1944)
V [libjvm.so+0xeb883c] JavaThread::thread_main_inner()+0xcc (javaThread.cpp:720)
V [libjvm.so+0x179b04a] Thread::call_run()+0xba (thread.cpp:217)
V [libjvm.so+0x1499d01] thread_native_entry(Thread*)+0x121 (os_linux.cpp:783)
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f3f941154b7, pid=1045889, tid=1045906
#
# JRE version: Java(TM) SE Runtime Environment (22.0) (build 22-internal-2023-08-09-1155514.tobias...)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (22-internal-2023-08-09-1155514.tobias..., mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V [libjvm.so+0x4084b7] AddNode::IdealIL(PhaseGVN*, bool, BasicType)+0x37
Current CompileTask:
C2: 405 632 % ! 4 CrashExample::main @ 29 (136 bytes)
Stack: [0x00007f3f65eff000,0x00007f3f66000000], sp=0x00007f3f65ffb7e0, free space=1009k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x4084b7] AddNode::IdealIL(PhaseGVN*, bool, BasicType)+0x37 (addnode.cpp:265)
V [libjvm.so+0xd11bde] PhaseIterGVN::transform_old(Node*)+0x9e (phaseX.cpp:667)
V [libjvm.so+0xd0db09] PhaseIterGVN::optimize()+0xf9 (phaseX.cpp:1045)
V [libjvm.so+0x6445af] Compile::Optimize()+0x151f (loopnode.hpp:1199)
V [libjvm.so+0x6456c2] Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0xed2 (compile.cpp:850)
V [libjvm.so+0x574079] C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x159 (c2compiler.cpp:119)
V [libjvm.so+0x64b2fe] CompileBroker::invoke_compiler_on_method(CompileTask*)+0xa9e (compileBroker.cpp:2276)
V [libjvm.so+0x64e558] CompileBroker::compiler_thread_loop()+0x698 (compileBroker.cpp:1944)
V [libjvm.so+0x8f8038] JavaThread::thread_main_inner() [clone .part.0]+0xb8 (javaThread.cpp:720)
V [libjvm.so+0xe9aa18] Thread::call_run()+0xa8 (thread.cpp:217)
V [libjvm.so+0xcbfaaa] thread_native_entry(Thread*)+0xda (os_linux.cpp:783)
- backported by
-
JDK-8319723 PhaseIdealLoop::transform_long_range_checks fails with assert "was tested before"
- Resolved
-
JDK-8323359 PhaseIdealLoop::transform_long_range_checks fails with assert "was tested before"
- Resolved
- relates to
-
JDK-8259609 C2: optimize long range checks in long counted loops
- Resolved
- links to
-
Commit openjdk/jdk21u/243142cf
-
Commit openjdk/jdk/9def4538
-
Review openjdk/jdk21u/316
-
Review openjdk/jdk/15411
(2 links to)