JDK-8264958 : C2 compilation fails with assert "n is later than its clone"
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 11,13.0.4,14,16,17
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2021-04-09
  • Updated: 2025-01-24
  • Resolved: 2021-04-16
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 11 JDK 17
11.0.12-oracleFixed 17 b19Fixed
Related Reports
Relates :  
Description
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/oracle/jdk/open/src/hotspot/share/opto/loopopts.cpp:1501), pid=332405, tid=332418
#  assert(dom_depth(n_ctrl) <= dom_depth(x_ctrl)) failed: n is later than its clone


Current CompileTask:
C2:    596  393    b  4       MainClass::test (55 bytes)

Stack: [0x00007ff082238000,0x00007ff082339000],  sp=0x00007ff082333260,  free space=1004k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x12ff474]  PhaseIdealLoop::split_if_with_blocks_post(Node*)+0xcf4
V  [libjvm.so+0x12ff9b1]  PhaseIdealLoop::split_if_with_blocks(VectorSet&, Node_Stack&)+0x201
V  [libjvm.so+0x12f3f9d]  PhaseIdealLoop::build_and_optimize(LoopOptsMode)+0x121d
V  [libjvm.so+0xa2a5fb]  PhaseIdealLoop::optimize(PhaseIterGVN&, LoopOptsMode)+0x32b
V  [libjvm.so+0xa267d6]  Compile::Optimize()+0x586
V  [libjvm.so+0xa295b5]  Compile::Compile(ciEnv*, ciMethod*, int, bool, bool, bool, bool, DirectiveSet*)+0x1905
V  [libjvm.so+0x853a7a]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x1ea
V  [libjvm.so+0xa39401]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0xf21
V  [libjvm.so+0xa3a0a8]  CompileBroker::compiler_thread_loop()+0x5a8
V  [libjvm.so+0x1863181]  JavaThread::thread_main_inner()+0x271
V  [libjvm.so+0x186b2c0]  Thread::call_run()+0x100
V  [libjvm.so+0x1556df6]  thread_native_entry(Thread*)+0x116
Comments
Fix Request (11u) This fixes a compiler bug introduced by 11.0.6 backport and keeps codebases in sync (I see 11.0.11-oracle). Patch applies cleanly to 11u, passes tier{1,2}. New regression test fails without the product patch, and passes with it.
21-04-2021

Changeset: 71373280 Author: Roland Westrelin <roland@openjdk.org> Date: 2021-04-16 11:34:45 +0000 URL: https://git.openjdk.java.net/jdk/commit/71373280
16-04-2021

Roland, could you please have a look?
09-04-2021

(rr) print x_ctrl->dump(3) 88 Bool === _ 87 [[ 89 ]] [le] !jvms: MainClass::test @ bci:18 (line 9) 150 CountedLoop === 150 149 120 [[ 150 140 138 89 78 ]] stride: 1 strip mined !orig=[141],[75] !jvms: MainClass::test @ bci:8 (line 8) 89 If === 150 88 [[ 90 91 ]] P=0,200098, C=16382,000000 !jvms: MainClass::test @ bci:18 (line 9) 90 IfTrue === 89 [[ 94 ]] #1 !jvms: MainClass::test @ bci:18 (line 9) 91 IfFalse === 89 [[ 94 97 ]] #0 !jvms: MainClass::test @ bci:18 (line 9) 94 Region === 94 91 90 [[ 94 145 98 109 ]] !orig=111 !jvms: MainClass::test @ bci:26 (line 12) n_ctrl == x_head: (rr) print x_head->dump(2) 145 CountedLoopEnd === 94 144 [[ 146 120 ]] [lt] P=0,909101, C=16381,000000 !orig=[119] !jvms: MainClass::test @ bci:5 (line 7) 148 IfTrue === 147 [[ 149 ]] #1 70 IfTrue === 60 [[ 149 ]] #1 !jvms: MainClass::test @ bci:5 (line 7) 120 IfTrue === 145 [[ 150 ]] #1 !jvms: MainClass::test @ bci:5 (line 7) 149 OuterStripMinedLoop === 149 70 148 [[ 149 150 ]] 150 CountedLoop === 150 149 120 [[ 150 140 138 89 78 ]] stride: 1 strip mined !orig=[141],[75] !jvms: MainClass::test @ bci:8 (line 8) Then the code introduced by JDK-8229483 sets x_ctrl to x_ctrl = x_head->as_Loop()->skip_strip_mined()->in(LoopNode::EntryControl) = 70 IfTrue Which violates: assert(dom_depth(n_ctrl) <= dom_depth(x_ctrl), "n is later than its clone");
09-04-2021

Looks like this has been introduced by JDK-8229483.
09-04-2021

ILW = Assert during C2 compilation, reproducible with generated test, no workaround but disable loop opts = HLM = P3
09-04-2021