RFR: 8280799: С2: assert(false) failed: cyclic dependency prevents range check elimination

Roland Westrelin roland at openjdk.java.net
Wed Feb 9 12:55:40 UTC 2022


On Wed, 9 Feb 2022 07:19:37 GMT, Tobias Hartmann <thartmann at openjdk.org> wrote:

>> The loop exit condition of the test method:
>> 
>> if (i == stop) {
>>     break;
>> }
>> 
>> requires insertion of a loop limit predicate when the loop is turned
>> into a counted loop. stop is a LoadI. Next:
>> 
>> array[stop - i + j] = 0;
>> 
>> is transformed to:
>> 
>> array[stop - i] = 0;
>> 
>> and the range check for that array access becomes candidate for
>> predication in a subsequent loop opts pass. stop has control just
>> above the loop limit check when that happens (because it is assigned
>> control as late as possible). But the loop predicate for the bound
>> check needs to be above the loop limit check and that causes the
>> assert failure.
>> 
>> There's already logic in PhaseIdealLoop::build_loop_late_post_work()
>> to assign control to nodes above predicates so this sort of issues
>> doesn't occur. But it only applies to node initially on the entry
>> projection right above the loop head. The fix I propose is to remove
>> that restriction.
>> 
>> That logic was added by JDK-8203197 and looking back at this change I
>> noticed I replaced some existing logic with the current logic but,
>> while the 2 overlap, the current logic is not guaranteed to always
>> cover some cases handled by the old logic. So I resurrected that old
>> logic here.
>> 
>> Finally, when running tests, I hit failures because Opaque nodes for
>> skeleton predicates can now end up above a predicate that is split
>> thru phi. That causes the Opaque nodes to be split up and breaks
>> pattern matching. I'm actually not sure this issue is specific to the
>> change here so I think it's best to treat it as a general issue and
>> fix it by cloning the chain of nodes that lead to the Opaque node
>> down.
>
> I executed some testing and hit the following failure with the `serviceability/sa/ClhsdbCDS*` tests (`-XX:+UseParallelGC -XX:+UseNUMA`:
> 
> # A fatal error has been detected by the Java Runtime Environment:
> #
> #  SIGSEGV (0xb) at pc=0x00007fc8d7407dcf, pid=18320, tid=18366
> #
> # JRE version: Java(TM) SE Runtime Environment (19.0) (fastdebug build 19-internal+0-2022-02-08-1034049.tobias.hartmann.jdk2)
> # Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 19-internal+0-2022-02-08-1034049.tobias.hartmann.jdk2, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, parallel gc, linux-amd64)
> # Problematic frame:
> # V  [libjvm.so+0x135adcf]  PhaseIdealLoop::get_ctrl(Node*)+0x4f
> 
> Current CompileTask:
> C2:   1131  710       4       sun.jvm.hotspot.oops.Symbol::asByteArray (34 bytes)
> 
> Stack: [0x00007fc8aacee000,0x00007fc8aadef000],  sp=0x00007fc8aade8650,  free space=1001k
> Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
> V  [libjvm.so+0x135adcf]  PhaseIdealLoop::get_ctrl(Node*)+0x4f
> V  [libjvm.so+0x17ed176]  PhaseIdealLoop::split_up(Node*, Node*, Node*) [clone .part.0]+0x2f6
> V  [libjvm.so+0x17ecf4a]  PhaseIdealLoop::split_up(Node*, Node*, Node*) [clone .part.0]+0xca
> V  [libjvm.so+0x17ecf4a]  PhaseIdealLoop::split_up(Node*, Node*, Node*) [clone .part.0]+0xca
> V  [libjvm.so+0x17ecf4a]  PhaseIdealLoop::split_up(Node*, Node*, Node*) [clone .part.0]+0xca
> V  [libjvm.so+0x17f26ed]  PhaseIdealLoop::do_split_if(Node*, RegionNode**, RegionNode**)+0x77d
> V  [libjvm.so+0x13b2651]  PhaseIdealLoop::split_if_with_blocks(VectorSet&, Node_Stack&)+0x201
> V  [libjvm.so+0x13a482b]  PhaseIdealLoop::build_and_optimize(LoopOptsMode)+0x12fb
> V  [libjvm.so+0xa9c88a]  PhaseIdealLoop::optimize(PhaseIterGVN&, LoopOptsMode)+0x28a
> V  [libjvm.so+0xa99055]  Compile::Optimize()+0x1035
> V  [libjvm.so+0xa9b295]  Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x1575
> V  [libjvm.so+0x8b1d99]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x669
> V  [libjvm.so+0xaab178]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0xc88
> V  [libjvm.so+0xaabf58]  CompileBroker::compiler_thread_loop()+0x668
> V  [libjvm.so+0x193711a]  JavaThread::thread_main_inner()+0x25a
> V  [libjvm.so+0x193f460]  Thread::call_run()+0x100
> V  [libjvm.so+0x1621fb4]  thread_native_entry(Thread*)+0x104
> 
> 
> 
> # A fatal error has been detected by the Java Runtime Environment:
> #
> #  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ff8c892ad8b, pid=232, tid=41068
> #
> # JRE version: Java(TM) SE Runtime Environment (19.0) (fastdebug build 19-internal+0-2022-02-08-1034049.tobias.hartmann.jdk2)
> # Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 19-internal+0-2022-02-08-1034049.tobias.hartmann.jdk2, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, windows-amd64)
> # Problematic frame:
> # V  [jvm.dll+0xcbad8b]  PhaseIdealLoop::split_up+0x203b
> 
> Current CompileTask:
> C2:   1167  562       4       sun.jvm.hotspot.debugger.DebuggerBase::readCInteger (295 bytes)
> 
> Stack: [0x000000d711500000,0x000000d711600000],  sp=0x000000d7115f9f70,  free space=999k
> Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
> V  [jvm.dll+0xcbad8b]  PhaseIdealLoop::split_up+0x203b  (split_if.cpp:271)
> V  [jvm.dll+0xcb8ec4]  PhaseIdealLoop::split_up+0x174  (split_if.cpp:77)
> V  [jvm.dll+0xcb8ec4]  PhaseIdealLoop::split_up+0x174  (split_if.cpp:77)
> V  [jvm.dll+0xcb8ec4]  PhaseIdealLoop::split_up+0x174  (split_if.cpp:77)
> V  [jvm.dll+0xcb6776]  PhaseIdealLoop::do_split_if+0x346  (split_if.cpp:498)
> V  [jvm.dll+0xa5f851]  PhaseIdealLoop::split_if_with_blocks+0x1a1  (loopopts.cpp:1812)
> V  [jvm.dll+0xa32ec8]  PhaseIdealLoop::build_and_optimize+0xff8  (loopnode.cpp:4366)
> V  [jvm.dll+0x4f3d45]  Compile::Optimize+0x1145  (compile.cpp:2266)
> V  [jvm.dll+0x4f0b87]  Compile::Compile+0x14b7  (compile.cpp:810)
> V  [jvm.dll+0x4138a5]  C2Compiler::compile_method+0x145  (c2compiler.cpp:115)
> V  [jvm.dll+0x50a216]  CompileBroker::invoke_compiler_on_method+0x756  (compileBroker.cpp:2293)
> V  [jvm.dll+0x507a06]  CompileBroker::compiler_thread_loop+0x276  (compileBroker.cpp:1967)
> V  [jvm.dll+0xd8d317]  JavaThread::thread_main_inner+0x297  (thread.cpp:1296)
> V  [jvm.dll+0xd82e64]  Thread::call_run+0x1b4  (thread.cpp:361)
> V  [jvm.dll+0xbcb449]  thread_native_entry+0xb9  (os_windows.cpp:544)
> C  [ucrtbase.dll+0x1fb80]  _o__realloc_base+0x60
> C  [KERNEL32.DLL+0x84d4]  BaseThreadInitThunk+0x14
> C  [ntdll.dll+0x51791]  RtlUserThreadStart+0x21
> ``` 
> 
> And with `tools/javac/annotations/repeatingAnnotations/combo/TargetAnnoCombo.java` on macosx-aarch64:
> 
> # A fatal error has been detected by the Java Runtime Environment:
> #
> #  SIGBUS (0xa) at pc=0x000000010295de98, pid=78752, tid=23555
> #
> # JRE version: Java(TM) SE Runtime Environment (19.0) (build 19-internal+0-2022-02-08-1034049.tobias.hartmann.jdk2)
> # Java VM: Java HotSpot(TM) 64-Bit Server VM (19-internal+0-2022-02-08-1034049.tobias.hartmann.jdk2, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, bsd-aarch64)
> # Problematic frame:
> # V  [libjvm.dylib+0x89de98]  _ZN14PhaseIdealLoop11do_split_ifEP4NodePP10RegionNodeS4_+0x650
> 
> Current CompileTask:
> C2: 104626 23310       4       java.net.URI$Parser::parseHierarchical (178 bytes)
> 
> Stack: [0x00000001709bc000,0x0000000170bbf000],  sp=0x0000000170bbaad0,  free space=2042k
> Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
> V  [libjvm.dylib+0x89de98]  _ZN14PhaseIdealLoop11do_split_ifEP4NodePP10RegionNodeS4_+0x650
> V  [libjvm.dylib+0x70df7c]  _ZN14PhaseIdealLoop20split_if_with_blocksER9VectorSetR10Node_Stack+0x11c
> V  [libjvm.dylib+0x700ec0]  _ZN14PhaseIdealLoop18build_and_optimizeE12LoopOptsMode+0x838
> V  [libjvm.dylib+0x2ca9c4]  _ZN14PhaseIdealLoop8optimizeER12PhaseIterGVN12LoopOptsMode+0x108
> V  [libjvm.dylib+0x2cac24]  _ZN7Compile14optimize_loopsER12PhaseIterGVN12LoopOptsMode+0xb0
> V  [libjvm.dylib+0x2c7734]  _ZN7Compile8OptimizeEv+0xef4
> V  [libjvm.dylib+0x2c59fc]  _ZN7CompileC2EP5ciEnvP8ciMethodi7OptionsP12DirectiveSet+0xaa0
> V  [libjvm.dylib+0x23438c]  _ZN10C2Compiler14compile_methodEP5ciEnvP8ciMethodibP12DirectiveSet+0x134
> V  [libjvm.dylib+0x2d67e4]  _ZN13CompileBroker25invoke_compiler_on_methodEP11CompileTask+0x3d4
> V  [libjvm.dylib+0x2d6378]  _ZN13CompileBroker20compiler_thread_loopEv+0x440
> V  [libjvm.dylib+0x93bea8]  _ZN10JavaThread17thread_main_innerEv+0xa0
> V  [libjvm.dylib+0x93a908]  _ZN6Thread8call_runEv+0xe0
> V  [libjvm.dylib+0x7f19e8]  _ZL19thread_native_entryP6Thread+0x158
> C  [libsystem_pthread.dylib+0x7240]  _pthread_start+0x94

@TobiHartmann thanks for running testing. I reproduced one of them (thanks for helping with that too) and fixed it. Would you mind running testing again?

-------------

PR: https://git.openjdk.java.net/jdk/pull/7319


More information about the hotspot-compiler-dev mailing list