JDK-8263187 : C2 compilation fails with "No reaching definition for liveout value"
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 11,16,17
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2021-03-08
  • Updated: 2021-03-09
  • Resolved: 2021-03-09
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 17
17Resolved
Related Reports
Duplicate :  
Relates :  
Description
Running attached test MainClass.java:

java  -XX:CompileCommand=quiet -XX:CompileCommand=compileonly,MainClass::test -Xbatch -XX:+UseParallelGC MainClass

# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/oracle/jdk/open/src/hotspot/share/opto/reg_split.cpp:1284), pid=78215, tid=78224
#  assert(Reachblock[slidx] != __null) failed: No reaching definition for liveout value

Current CompileTask:
C2:    377   25    b  4       MainClass::test (80 bytes)

Stack: [0x00007fd43742f000,0x00007fd437530000],  sp=0x00007fd43752ac80,  free space=1007k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x164b5f7]  PhaseChaitin::Split(unsigned int, ResourceArea*)+0x5487
V  [libjvm.so+0x8acbe6]  PhaseChaitin::Register_Allocate()+0x5e6
V  [libjvm.so+0xa067c4]  Compile::Code_Gen()+0x314
V  [libjvm.so+0xa1159c]  Compile::Compile(ciEnv*, ciMethod*, int, bool, bool, bool, bool, DirectiveSet*)+0x19dc
V  [libjvm.so+0x83ce3a]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x1ea
V  [libjvm.so+0xa21361]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0xea1
V  [libjvm.so+0xa21fe8]  CompileBroker::compiler_thread_loop()+0x5a8
V  [libjvm.so+0x1844636]  JavaThread::thread_main_inner()+0x256
V  [libjvm.so+0x184a990]  Thread::call_run()+0x100
V  [libjvm.so+0x1536ac6]  thread_native_entry(Thread*)+0x116


With JDK version < 16, it fails earlier:

Bad graph detected in compute_lca_of_uses
n:  476	Phi	===  466  23  541  [[ 263 ]]  #int:0..65493 !orig=418
early(n):  466	Region	===  466  465  532  [[ 466  411  550  474  475  476  477  480  483 ]] 
n->in(1):  23	ConI	===  0  [[ 26  235  558  497  557  476  483  376  431 ]]  #int:0
early(n->in(1)):  0	Root	===  0  326  327  267  [[ 0  1  3  22  23  24  312  282  262  253  233  84  85  91  92  105  106  231  215  187  174  161  147  146  339  555  556  345  694  695 ]] 
n->in(2):  541	Phi	===  532  622  555  [[ 476 ]]  #int:0..65493
early(n->in(2)):  532	Region	===  532  615  613  [[ 532  466  553  539  546  541  542  544 ]] 
n->in(2)->in(1):  622	Phi	===  615  584  555  [[ 541 ]]  #int:0..65493
early(n->in(2)->in(1)):  615	Region	===  615  614  531  [[ 615  532  617  620  622  623  625  628 ]] 
n->in(2)->in(2):  555	ConI	===  0  [[ 622  584  541 ]]  #int:-38
early(n->in(2)->in(2)):  0	Root	===  0  326  327  267  [[ 0  1  3  22  23  24  312  282  262  253  233  84  85  91  92  105  106  231  215  187  174  161  147  146  339  555  556  345  694  695 ]] 

LCA(n):  411	Region	===  411  410  466  [[ 411  263  692  416  417  423  419  421 ]] 
n->out(0):  263	CallStaticJava	===  411  37  250  8  9 ( 262  10  416  43  345  417  423  693  693  476 ) [[ 264 ]] # Static uncommon_trap(reason='unstable_if' action='reinterpret' debug_id='0')  void ( int ) C=0,000100 Objects::requireNonNull @ bci:1 reexecute MainClass::test @ bci:44 !jvms: Objects::requireNonNull @ bci:1 MainClass::test @ bci:44
n->out(0)->out(0):  264	Proj	===  263  [[ 267 ]] #0 !jvms: Objects::requireNonNull @ bci:1 MainClass::test @ bci:44

idoms of early 466:
idom[0]  466	Region	===  466  465  532  [[ 466  411  550  474  475  476  477  480  483 ]] 
idom[1]  456	If	===  102  442  [[ 457  464 ]] P=0,099072, C=16382,000000 !orig=220,[256] !jvms: MainClass::test @ bci:32
idom[2]  102	Proj	===  101  [[ 456 ]] #0 !orig=[126],[135] !jvms: MainClass::test @ bci:-1
idom[3]  101	MemBarRelease	===  40  1  51  1  1  43  [[ 102  103 ]]  !jvms: MainClass::test @ bci:-1
idom[4]  40	Proj	===  39  [[ 101  43 ]] #0 !jvms: MainClass::test @ bci:0
idom[5]  39	Initialize	===  31  1  42  1  1  38  95  88  [[ 40  41 ]]  !jvms: MainClass::test @ bci:0
idom[6]  31	CatchProj	===  30  [[ 39  88  95 ]] #0@bci -1  !jvms: MainClass::test @ bci:0
idom[7]  30	Catch	===  27  29  [[ 31  32 ]]  !jvms: MainClass::test @ bci:0
idom[8]  27	Proj	===  26  [[ 30 ]] #0 !jvms: MainClass::test @ bci:0
idom[9]  26	Allocate	===  5  6  7  8  1 ( 24  22  23  1  10  11  1  1  1  1 ) [[ 27  28  29  36  37  38 ]]  rawptr:NotNull ( int:>=0, java/lang/Object:NotNull *, bool, top ) MainClass::test @ bci:0 !jvms: MainClass::test @ bci:0
idom[10]  5	Parm	===  3  [[ 26 ]] Control !jvms: MainClass::test @ bci:-1

idoms of (wrong) LCA 411:
idom[0]  411	Region	===  411  410  466  [[ 411  263  692  416  417  423  419  421 ]] 
idom[1]  456	If	===  102  442  [[ 457  464 ]] P=0,099072, C=16382,000000 !orig=220,[256] !jvms: MainClass::test @ bci:32
idom[2]  102	Proj	===  101  [[ 456 ]] #0 !orig=[126],[135] !jvms: MainClass::test @ bci:-1
idom[3]  101	MemBarRelease	===  40  1  51  1  1  43  [[ 102  103 ]]  !jvms: MainClass::test @ bci:-1
idom[4]  40	Proj	===  39  [[ 101  43 ]] #0 !jvms: MainClass::test @ bci:0
idom[5]  39	Initialize	===  31  1  42  1  1  38  95  88  [[ 40  41 ]]  !jvms: MainClass::test @ bci:0
idom[6]  31	CatchProj	===  30  [[ 39  88  95 ]] #0@bci -1  !jvms: MainClass::test @ bci:0
idom[7]  30	Catch	===  27  29  [[ 31  32 ]]  !jvms: MainClass::test @ bci:0
idom[8]  27	Proj	===  26  [[ 30 ]] #0 !jvms: MainClass::test @ bci:0
idom[9]  26	Allocate	===  5  6  7  8  1 ( 24  22  23  1  10  11  1  1  1  1 ) [[ 27  28  29  36  37  38 ]]  rawptr:NotNull ( int:>=0, java/lang/Object:NotNull *, bool, top ) MainClass::test @ bci:0 !jvms: MainClass::test @ bci:0
idom[10]  5	Parm	===  3  [[ 26 ]] Control !jvms: MainClass::test @ bci:-1

Real LCA of early 466 (idom[1]) and (wrong) LCA 411 (idom[1]):
 456	If	===  102  442  [[ 457  464 ]] P=0,099072, C=16382,000000 !orig=220,[256] !jvms: MainClass::test @ bci:32

# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (workspace/open/src/hotspot/share/opto/loopnode.cpp:4121), pid=78044, tid=78052
#  assert(!had_error) failed: bad dominance

Current CompileTask:
C2:    265    2    b  4       MainClass::test (80 bytes)

Stack: [0x00007f1cba5e5000,0x00007f1cba6e6000],  sp=0x00007f1cba6e0570,  free space=1005k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x118c2cc]  PhaseIdealLoop::compute_lca_of_uses(Node*, Node*, bool)+0x81c
V  [libjvm.so+0x118cae0]  PhaseIdealLoop::build_loop_late_post_work(Node*, bool)+0x190
V  [libjvm.so+0x118d12a]  PhaseIdealLoop::build_loop_late(VectorSet&, Node_List&, Node_Stack&)+0xba
V  [libjvm.so+0x1192c9c]  PhaseIdealLoop::build_and_optimize(LoopOptsMode)+0x6cc
V  [libjvm.so+0x90d5ed]  PhaseIdealLoop::verify(PhaseIterGVN&)+0x31d
V  [libjvm.so+0x90b09b]  Compile::Optimize()+0xf5b
V  [libjvm.so+0x90c95c]  Compile::Compile(ciEnv*, ciMethod*, int, bool, bool, bool, DirectiveSet*)+0x15ac
V  [libjvm.so+0x759695]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, DirectiveSet*)+0x175
V  [libjvm.so+0x91b9c0]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0xd60
V  [libjvm.so+0x91c788]  CompileBroker::compiler_thread_loop()+0x6c8
V  [libjvm.so+0x16ca5cc]  JavaThread::thread_main_inner()+0x21c
V  [libjvm.so+0x16d0310]  Thread::call_run()+0x100
V  [libjvm.so+0x13d49a6]  thread_native_entry(Thread*)+0x116


With a product build, we crash in Node::rematerialize():

# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007ff5c79b9660, pid=78777, tid=78784

Current CompileTask:
C2:     93    1    b        MainClass::test (80 bytes)

Stack: [0x00007ff59d9b5000,0x00007ff59dab6000],  sp=0x00007ff59dab11f8,  free space=1008k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0xbdc660]  Node::rematerialize() const+0x0
V  [libjvm.so+0x5652be]  PhaseChaitin::Register_Allocate()+0x51e
V  [libjvm.so+0x60cbe7]  Compile::Code_Gen()+0x297
V  [libjvm.so+0x612ba3]  Compile::Compile(ciEnv*, C2Compiler*, ciMethod*, int, bool, bool, bool, DirectiveSet*)+0x10f3
V  [libjvm.so+0x53db8c]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, DirectiveSet*)+0xbc
V  [libjvm.so+0x61ad6b]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0x47b
V  [libjvm.so+0x61c218]  CompileBroker::compiler_thread_loop()+0x4e8
V  [libjvm.so+0xdcf677]  JavaThread::thread_main_inner()+0x1f7
V  [libjvm.so+0xdd433d]  Thread::call_run()+0x10d
V  [libjvm.so+0xc12d87]  thread_native_entry(Thread*)+0xe7
Comments
After some investigation it turned out that this is a duplicate of JDK-8261812 (just a different failure mode).
09-03-2021

Similar to JDK-8039050.
08-03-2021

ILW = Assert or crash during C2 compilation, easy to reproduce with regression test, -XX:-EliminateAllocations or disable C2 compilation of affected method = HMM = P2
08-03-2021