JDK-8335753 : C2: assert(x_ctrl == get_late_ctrl_with_anti_dep(x->as_Load(), early_ctrl, x_ctrl)) failed: anti-dependences were already checked
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 17,21,22,23,24
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2024-07-05
  • Updated: 2024-12-13
  • Resolved: 2024-12-13
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 25
25Resolved
Related Reports
Duplicate :  
Relates :  
Description
A quick mention in the PR would be appreciated, I spent quite some time extracting and cleaning the JASM so that it also reproduces on older JDK. Though it can probably be further reduced - and maybe even a JAVA file constructed.

Affected: JDK23, 22, 21, 17 (could not reproduce with JDK11 - not sure why, please check again once you understand the bug)

Hard to say what is wrong exactly, but could be a normal loop-opts bug. Wrong anti-dependence indicates that this may lead to wrong results.

emanuel@emanuel-oracle:xyz$ java -jar ~/Documents/asmtools-7.0-build/release/lib/asmtools.jar jasm X.jasm
emanuel@emanuel-oracle:xyz$ /oracle-work/jdk-fork2/build/linux-x64-debug/jdk/bin/java -XX:CompileCommand=printcompilation,X::* -XX:CompileCommand=compileonly,X::test -Xcomp -XX:-TieredCompilation X
CompileCommand: PrintCompilation X.* bool PrintCompilation = true
CompileCommand: compileonly X.test bool compileonly = true
489   26    b        X::test (189 bytes)
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/oracle-work/jdk-fork2/open/src/hotspot/share/opto/loopopts.cpp:1756), pid=3740705, tid=3740719
#  assert(x_ctrl == get_late_ctrl_with_anti_dep(x->as_Load(), early_ctrl, x_ctrl)) failed: anti-dependences were already checked
#
# JRE version: Java(TM) SE Runtime Environment (24.0) (fastdebug build 24-internal-2024-06-13-1913126.emanuel...)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 24-internal-2024-06-13-1913126.emanuel..., compiled mode, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0x129dfb0]  PhaseIdealLoop::try_sink_out_of_loop(Node*)+0xcd0
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -- %E" (or dumping to /oracle-work/xyz/core.3740705)
#
# An error report file with more information is saved as:
# /oracle-work/xyz/hs_err_pid3740705.log
#
# Compiler replay data is saved as:
# /oracle-work/xyz/replay_pid3740705.log
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
#

Current CompileTask:
C2:516   26    b        X::test (189 bytes)

Stack: [0x00007f38ed83a000,0x00007f38ed93b000],  sp=0x00007f38ed935d10,  free space=1007k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x129dfb0]  PhaseIdealLoop::try_sink_out_of_loop(Node*)+0xcd0  (loopopts.cpp:1756)
V  [libjvm.so+0x129e093]  PhaseIdealLoop::split_if_with_blocks_post(Node*)+0x83  (loopopts.cpp:1517)
V  [libjvm.so+0x129e956]  PhaseIdealLoop::split_if_with_blocks(VectorSet&, Node_Stack&)+0x96  (loopopts.cpp:1950)
V  [libjvm.so+0x1290a89]  PhaseIdealLoop::build_and_optimize()+0xee9  (loopnode.cpp:4815)
V  [libjvm.so+0x9de3a0]  PhaseIdealLoop::optimize(PhaseIterGVN&, LoopOptsMode)+0x390  (loopnode.hpp:1115)
V  [libjvm.so+0x9d7005]  Compile::optimize_loops(PhaseIterGVN&, LoopOptsMode)+0x75  (compile.cpp:2170)
V  [libjvm.so+0x9d97f1]  Compile::Optimize()+0xe21  (compile.cpp:2417)
V  [libjvm.so+0x9dcf53]  Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x1b33  (compile.cpp:852)
V  [libjvm.so+0x832065]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x1d5  (c2compiler.cpp:142)
V  [libjvm.so+0x9e8c08]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0x928  (compileBroker.cpp:2303)
V  [libjvm.so+0x9e9898]  CompileBroker::compiler_thread_loop()+0x478  (compileBroker.cpp:1961)
V  [libjvm.so+0xe91e7c]  JavaThread::thread_main_inner()+0xcc  (javaThread.cpp:759)
V  [libjvm.so+0x17ab9b6]  Thread::call_run()+0xb6  (thread.cpp:225)
V  [libjvm.so+0x1495ed7]  thread_native_entry(Thread*)+0x127  (os_linux.cpp:849)
Comments
I verified that this is a duplicate of JDK-8335709.
13-12-2024

Deferring to JDK 25 for now because this is an old issue. Feel free to re-target to JDK 24 if the fix is ready in time.
17-10-2024

> could not reproduce with JDK11 - not sure why The optimization was only added by JDK-8252372 in JDK 17. ILW = Assert during C2 compilation when trying to sink a load out of a loop (might lead to incorrect execution), edge case (jasm) but reproducible, disable split if or compilation of affected method = HLM = P3
05-07-2024