JDK-8271203 : C2: assert(iff->Opcode() == Op_If || iff->Opcode() == Op_CountedLoopEnd || iff->Opcode() == Op_RangeCheck) failed: Check this code when new subtype is added
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 16,17,18
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2021-07-23
  • Updated: 2021-08-23
  • Resolved: 2021-08-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 17 JDK 18
17.0.1Fixed 18 b11Fixed
Related Reports
Relates :  
Description
The attached JavaFuzzer test fails with the following assertion:

To reproduce:
$ java java -XX:-TieredCompilation Test.java
$ java -Xbatch -XX:-TieredCompilation -XX:CompileOnly=Reduced Reduced.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/loopopts.cpp:237), pid=492453, tid=492466
#  assert(iff->Opcode() == Op_If || iff->Opcode() == Op_CountedLoopEnd || iff->Opcode() == Op_RangeCheck) failed: Check this code when new subtype is added
#
# 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, mixed mode, sharing, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0x12e63a3]  PhaseIdealLoop::dominated_by(Node*, Node*, bool, bool)+0xd3
...........
Command Line: -XX:CompileCommand=quiet -XX:-TieredCompilation Test
...........
Current thread (0x00007f91e02b0b40):  JavaThread "C2 CompilerThread0" daemon [_thread_in_native, id=492466, stack(0x00007f9199cf8000,0x00007f9199df9000)]


Current CompileTask:
C2:   2894  108   !         Test::mainTest (1045 bytes)

Stack: [0x00007f9199cf8000,0x00007f9199df9000],  sp=0x00007f9199df30a0,  free space=1004k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x12e63a3]  PhaseIdealLoop::dominated_by(Node*, Node*, bool, bool)+0xd3
V  [libjvm.so+0x12b8423]  PhaseIdealLoop::do_unswitching(IdealLoopTree*, Node_List&)+0x11b3
V  [libjvm.so+0x12b2f0e]  IdealLoopTree::iteration_split(PhaseIdealLoop*, Node_List&)+0x23e
V  [libjvm.so+0x12b2d05]  IdealLoopTree::iteration_split(PhaseIdealLoop*, Node_List&)+0x35
V  [libjvm.so+0x12df1a8]  PhaseIdealLoop::build_and_optimize(LoopOptsMode)+0xd58
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
I've already pushed the backport to JDK 17u and forgot to request approval. Doing this now: Fix request (17u): This bug leads to an assert during C2 compilation. The fix is low risk because it does not affect product (change in assert condition) and has been tested in the JDK 18 CI for a while and with tier1-3 in JDK 17u. The patch applies cleanly.
23-08-2021

Changeset: 3f38a50c Author: Yi Yang <yyang@openjdk.org> Date: 2021-08-16 02:30:57 +0000 URL: https://git.openjdk.java.net/jdk/commit/3f38a50c528cccc30ca9e513b15ce9866d92aa82
16-08-2021

[~thartmann] Okay! Status updated.
29-07-2021

[~yyang] please assign bugs to you and set them to In Progress if you are working on them.
29-07-2021

The `iff` is a LongCountedLoopEnd. I guess the code works just fine with them as well? [~roland]
23-07-2021

ILW = Assert in C2 loop unswitching, only with single JavaFuzzer test, disable compilation of affected method = HLM = P3
23-07-2021