JDK-8271954 : C2: assert(false) failed: Bad graph detected in build_loop_late
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 17,18
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2021-08-05
  • Updated: 2022-11-22
  • Resolved: 2022-06-10
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 JDK 18
17.0.2Fixed 18 b16Fixed
Related Reports
Relates :  
Relates :  
Description
The attached Java Fuzzer test starts to fail after JDK-8252372 with the following assertion:

To reproduce:
$ java -XX:-TieredCompilation -Xcomp -XX:CompileOnly=Test Test.java

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/opt/mach5/mesos/work_dir/slaves/3c846bae-ce30-4a97-93ee-9fef4497ccb6-S124123/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/57294efe-464f-4c0a-b55a-fd67bfa32e7b/runs/71c23d41-87fd-4de4-92b5-4ba130c3e1dd/workspace/open/src/hotspot/share/opto/loopnode.cpp:5337), pid=1941868, tid=1941881
#  assert(false) failed: Bad graph detected in build_loop_late
#
# JRE version: Java(TM) SE Runtime Environment (18.0+7) (fastdebug build 18-ea+7-268)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 18-ea+7-268, compiled mode, sharing, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0x12ddb47]  PhaseIdealLoop::build_loop_late_post_work(Node*, bool)+0x307
...........
Command Line: -XX:CompileCommand=quiet -XX:-TieredCompilation -Xcomp -XX:CompileOnly=Test Test
...........
Current thread (0x00007f649c2b1140):  JavaThread "C2 CompilerThread0" daemon [_thread_in_native, id=1941881, stack(0x00007f64562fb000,0x00007f64563fc000)]


Current CompileTask:
C2:    230    3    b        Test::mainTest (566 bytes)

Stack: [0x00007f64562fb000,0x00007f64563fc000],  sp=0x00007f64563f62f0,  free space=1004k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x12ddb47]  PhaseIdealLoop::build_loop_late_post_work(Node*, bool)+0x307
V  [libjvm.so+0x12ddfea]  PhaseIdealLoop::build_loop_late(VectorSet&, Node_List&, Node_Stack&)+0xba
V  [libjvm.so+0x12de957]  PhaseIdealLoop::build_and_optimize(LoopOptsMode)+0x507
V  [libjvm.so+0x9fba3c]  PhaseIdealLoop::optimize(PhaseIterGVN&, LoopOptsMode)+0x28c
V  [libjvm.so+0x9f8525]  Compile::Optimize()+0x1475
V  [libjvm.so+0x9f9ff4]  Compile::Compile(ciEnv*, ciMethod*, int, bool, bool, bool, bool, bool, DirectiveSet*)+0x1564
V  [libjvm.so+0x81a076]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x646
V  [libjvm.so+0xa0aab9]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0xef9
V  [libjvm.so+0xa0b7e8]  CompileBroker::compiler_thread_loop()+0x598
V  [libjvm.so+0x186829c]  JavaThread::thread_main_inner()+0x27c
V  [libjvm.so+0x186eb90]  Thread::call_run()+0x100
V  [libjvm.so+0x1551464]  thread_native_entry(Thread*)+0x104
Comments
The provided test 'TestUnswitchWithSunkNodes.java' has been run in all necessary configurations during ATR18, which I consider enough to verify this bug.
03-02-2022

Fix request (17u): The bug leads to an assert in C2 (regression in JDK 17). The fix is medium risk and has been tested in the JDK 18 for a while and with tier1-3 in JDK 17u. The patch applies cleanly.
28-09-2021

Changeset: c86e24d4 Author: Christian Hagedorn <chagedorn@openjdk.org> Date: 2021-09-16 11:57:30 +0000 URL: https://git.openjdk.java.net/jdk/commit/c86e24d4be1e1a26a2a8323ef7ddbab6326bbf3a
16-09-2021

It's unrelated. This bug is caused by JDK-8252372 which is an optimization in split if and does not reproduce with -XX:-SplitIfBlocks while JDK-8272574 crashes with -XX:-SplitIfBlocks.
18-08-2021

Could this be related to JDK-8272574?
18-08-2021

ILW = C2 assertion failure, found with multiple Java Fuzzer tests, use -XX:-SplitIfBlocks = HMM = P2
05-08-2021