My jasm fuzzer found a dead-loop.
Attached you can find the full fuzzer test X.jasm as well as a reduced version X3.jasm.
Since the error is a bit intermittent, we require:
-XX:RepeatCompilation=1000 -XX:+StressIGVN
java -jar ~/Documents/asmtools-7.0-build/release/lib/asmtools.jar jasm X.jasm
java -XX:+UnlockExperimentalVMOptions -Xcomp -XX:CompileCommand=compileonly,X::test* -XX:-TieredCompilation -XX:RepeatCompilation=1000 -XX:+StressIGVN X
java -jar ~/Documents/asmtools-7.0-build/release/lib/asmtools.jar jasm X3.jasm
java -XX:+UnlockExperimentalVMOptions -Xcomp -XX:CompileCommand=compileonly,X3::test* -XX:-TieredCompilation -XX:RepeatCompilation=1000 -XX:+StressIGVN X3
Result is this:
dist dump
---------------------------------------------
2 0 Root === 0 2 3 4 33 34 1 1 20 1 32 [[ 0 1 256 338 125 222 104 388 393 395 510 138 331 689 129 111 169 109 170 442 443 115 214 726 155 208 199 352 495 157 463 576 246 110 131 132 136 851 855 1148 ]]
1 1 Con === 0 [[ ]] #top
0 149 OrI === _ 149 1 [[ 149 40 51 52 218 47 761 ]] !orig=181,[2909] !jvms: X::test @ bci:2727
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (/.../src/hotspot/share/opto/phaseX.cpp:956), pid=4189197, tid=4189210
# assert(no_dead_loop) failed: dead loop detected
Current CompileTask:
C2: 107 6 4 X::test (3794 bytes)
Stack: [0x00007f3061264000,0x00007f3061365000], sp=0x00007f306135f630, free space=1005k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x177ac78] PhaseGVN::dead_loop_check(Node*) [clone .part.0]+0x158 (phaseX.cpp:943)
V [libjvm.so+0x17897e9] PhaseIterGVN::transform_old(Node*)+0x4e9
V [libjvm.so+0x17817ee] PhaseIterGVN::optimize()+0x6e
V [libjvm.so+0xaef32a] PhaseIdealLoop::optimize(PhaseIterGVN&, LoopOptsMode)+0x6aa
V [libjvm.so+0xae8640] Compile::Optimize()+0x4c0
V [libjvm.so+0xaed10e] Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x18ce
V [libjvm.so+0x8fec67] C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x4e7
V [libjvm.so+0xafa22c] CompileBroker::invoke_compiler_on_method(CompileTask*)+0xa7c
V [libjvm.so+0xafafe8] CompileBroker::compiler_thread_loop()+0x5d8
V [libjvm.so+0x1067896] JavaThread::thread_main_inner()+0x206
V [libjvm.so+0x1a6a8b0] Thread::call_run()+0x100
V [libjvm.so+0x16ff053] thread_native_entry(Thread*)+0x103
Different failure mode with JDK 8u and 17u:
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (.../hotspot/src/share/vm/opto/loopnode.cpp:3133), pid=3446922, tid=0x00007f058a92a700
# assert(!in->is_CFG()) failed: CFG Node with no controlling input?
V [libjvm.so+0x119823d] VMError::report_and_die()+0x2fd
V [libjvm.so+0x793e11] report_vm_error(char const*, int, char const*, char const*)+0x61
V [libjvm.so+0xd10227] PhaseIdealLoop::build_loop_early(VectorSet&, Node_List&, Node_Stack&)+0x587
V [libjvm.so+0xd16ef3] PhaseIdealLoop::build_and_optimize(bool, bool)+0x7e3
V [libjvm.so+0x6f7ba3] Compile::Optimize()+0x453
V [libjvm.so+0x6f9375] Compile::Compile(ciEnv*, C2Compiler*, ciMethod*, int, bool, bool, bool)+0xe05
V [libjvm.so+0x58db18] C2Compiler::compile_method(ciEnv*, ciMethod*, int)+0xe8
V [libjvm.so+0x708442] CompileBroker::invoke_compiler_on_method(CompileTask*)+0x942
V [libjvm.so+0x709a28] CompileBroker::compiler_thread_loop()+0x858
V [libjvm.so+0x1109b28] JavaThread::thread_main_inner()+0x198
V [libjvm.so+0x1109e30] JavaThread::run()+0x2c0
V [libjvm.so+0xea1902] java_start(Thread*)+0x102
C [libpthread.so.0+0x8609] start_thread+0xd9