JDK-8343944 : C2: MinLNode::add_ring() computes _widen wrongly leading to an endless compilation
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 21,23,24
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2024-11-11
  • Updated: 2024-11-11
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 24
24Unresolved
Related Reports
Relates :  
Relates :  
Description
In MinLNode::add_ring() we wrongly take the MIN2() of the _widen instead of MAX2() which leads to an endless compilation with the attached Java Fuzzer test because we never reach a fixed point in CCP.

We eventually hit the MemLimit of 1GB and crash with a debug build because we keep creating new types.

To reproduce:
$ java -XX:CompileCommand=compileonly,*Test*::* -Xcomp Test.java
$ -XX:CompileCommand=compileonly,*Reduced*::* -Xcomp Reduced.java

For quicker crash, set memlimit to a lower value like 1m:
$ -XX:CompileCommand=compileonly,*Reduced*::* -Xcomp -XX:CompileCommand=memlimit,*.*,1m~crash Reduced.java

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/opt/mach5/mesos/work_dir/slaves/82441f27-1222-4bbe-ad17-e607ee550c54-S61/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/20dd5f16-3048-4958-b70d-13ddc6ef4b86/runs/c1649dc7-2974-4ac7-a57f-1a5d0a465d29/workspace/open/src/hotspot/share/compiler/compilationMemoryStatistic.cpp:568), pid=3119046, tid=3119064
#  fatal error: c2 Test::mainTest(([Ljava/lang/String;)V): Hit MemLimit (limit: 1073741824 now: 1073746024)
#
# JRE version: Java(TM) SE Runtime Environment (24.0) (fastdebug build 24-internal-2024-11-09-0602259.alan.bateman.jdk)
............
Command Line: -Xmx1G -XX:+IgnoreUnrecognizedVMOptions -XX:CompileCommand=quiet -XX:CompileCommand=compileonly,*Test*::* -Xcomp -XX:MaxRAMPercentage=4.16667 -Dtest.boot.jdk=/opt/mach5/mesos/work_dir/jib-master/install/jdk/23/37/bundles/linux-x64/jdk-23_linux-x64_bin.tar.gz/jdk-23 -Djava.io.tmpdir=/opt/mach5/mesos/work_dir/slaves/ccd15758-3c17-44a6-a32a-40698b0633d8-S4684/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/6f8a6b69-712b-4c46-8022-383d049cbc08/runs/ada53426-be6b-4cb8-bf7e-519713cb3ef5/testoutput/test-support/jtreg_closed_test_hotspot_jtreg_applications_javafuzzer_BigTest_java/tmp Test
...........
Current CompileTask:
C2:19646   43    b  4       Test::mainTest (804 bytes)

Stack: [0x00007f3e09677000,0x00007f3e09777000],  sp=0x00007f3e097713b0,  free space=1000k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x1937fa8]  VMError::report_and_die(int, char const*, char const*, __va_list_tag*, Thread*, unsigned char*, void*, void*, char const*, int, unsigned long)+0x488  (compilationMemoryStatistic.cpp:568)
V  [libjvm.so+0xafba15]  report_fatal(VMErrorType, char const*, int, char const*, ...)+0x105  (debug.cpp:214)
V  [libjvm.so+0xa18453]  CompilationMemoryStatistic::on_arena_change(long, Arena const*)+0x3e3  (compilationMemoryStatistic.cpp:568)
V  [libjvm.so+0x60c2ac]  Arena::grow(unsigned long, AllocFailStrategy::AllocFailEnum)+0x10c  (arena.cpp:308)
V  [libjvm.so+0x60c51b]  Arena::Arealloc(void*, unsigned long, unsigned long, AllocFailStrategy::AllocFailEnum)+0x1bb  (arena.hpp:134)
V  [libjvm.so+0xbc321f]  Dict::Insert(void*, void*, bool)+0x12f  (dict.cpp:173)
V  [libjvm.so+0x1874ac4]  Type::hashcons()+0x164  (type.cpp:763)
V  [libjvm.so+0x15b65f2]  PhaseCCP::analyze()+0x2d2  (phaseX.cpp:1818)
V  [libjvm.so+0xa3ea84]  Compile::Optimize()+0x794  (compile.cpp:2408)
V  [libjvm.so+0xa42d4f]  Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x1b6f  (compile.cpp:852)
V  [libjvm.so+0x88ba85]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x1d5  (c2compiler.cpp:142)
V  [libjvm.so+0xa4edd8]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0x928  (compileBroker.cpp:2319)
V  [libjvm.so+0xa4fb18]  CompileBroker::compiler_thread_loop()+0x528  (compileBroker.cpp:1977)
V  [libjvm.so+0xf102bc]  JavaThread::thread_main_inner()+0xcc  (javaThread.cpp:772)
V  [libjvm.so+0x1851826]  Thread::call_run()+0xb6  (thread.cpp:232)
V  [libjvm.so+0x1531f88]  thread_native_entry(Thread*)+0x128  (os_linux.cpp:858)
Comments
Wrong code was introduced with JDK-8303466 but JDK-8324655 makes it much easier (or even possible?) to trigger due to adding a CMove -> MinL optimization which is exercised with the attached test.
11-11-2024

ILW = Endless compilation due to not reaching a fixed point in CCP, single Java Fuzzer failure, disable compilation of affected method = HLM = P3
11-11-2024