JDK-8303045 : Remove RegionNode::LoopStatus::NeverIrreducibleEntry assert with wrong assumption
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 21
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-02-22
  • Updated: 2023-03-28
  • Resolved: 2023-02-27
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 21
21 b12Fixed
Related Reports
Relates :  
Description
Happened once in a personal job.

# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (c:\\sb\\prod\\1676563492\\workspace\\open\\src\\hotspot\\share\\opto\\cfgnode.cpp:439), pid=20508, tid=18308
#  assert(status != RegionNode::LoopStatus::NeverIrreducibleEntry) failed: do not set this
#
# JRE version: Java(TM) SE Runtime Environment (21.0) (fastdebug build 21-internal-LTS-2023-02-16-1602470.daniel.jelinski.jdk)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 21-internal-LTS-2023-02-16-1602470.daniel.jelinski.jdk, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, windows-amd64)

From hs_err*.log:

---------------  T H R E A D  ---------------

Current thread (0x000001ebe8093700):  JavaThread "C2 CompilerThread0" daemon [_thread_in_native, id=18308, stack(0x00000079d3100000,0x00000079d3200000)]


Current CompileTask:
C2:  17281 4480 % !   4       DigestEchoServer$HttpsProxyTunnel$1::run @ 2 (164 bytes)

Stack: [0x00000079d3100000,0x00000079d3200000]
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [jvm.dll+0xbf8011]  os::win32::platform_print_native_stack+0xf1  (os_windows_x86.cpp:236)
V  [jvm.dll+0xe701b0]  VMError::report+0x10c0  (vmError.cpp:813)
V  [jvm.dll+0xe71dee]  VMError::report_and_die+0x6ce  (vmError.cpp:1593)
V  [jvm.dll+0xe72534]  VMError::report_and_die+0x64  (vmError.cpp:1352)
V  [jvm.dll+0x577307]  report_vm_error+0xb7  (debug.cpp:286)
V  [jvm.dll+0x457efb]  RegionNode::set_loop_status+0x3b  (cfgnode.cpp:439)
V  [jvm.dll+0xaa56c6]  IdealLoopTree::split_fall_in+0x156  (loopnode.cpp:3148)
V  [jvm.dll+0xa8cec6]  IdealLoopTree::beautify_loops+0xf6  (loopnode.cpp:3441)
V  [jvm.dll+0xa8d6b2]  IdealLoopTree::beautify_loops+0x8e2  (loopnode.cpp:3505)
V  [jvm.dll+0xa8dbbb]  PhaseIdealLoop::build_and_optimize+0x4db  (loopnode.cpp:4335)
V  [jvm.dll+0x519018]  PhaseIdealLoop::optimize+0xd8  (loopnode.hpp:1192)
V  [jvm.dll+0x50c0a2]  Compile::Optimize+0x972  (compile.cpp:2292)
V  [jvm.dll+0x50969b]  Compile::Compile+0x16bb  (compile.cpp:834)
V  [jvm.dll+0x427665]  C2Compiler::compile_method+0x145  (c2compiler.cpp:116)
V  [jvm.dll+0x523b99]  CompileBroker::invoke_compiler_on_method+0x849  (compileBroker.cpp:2240)
V  [jvm.dll+0x52130d]  CompileBroker::compiler_thread_loop+0x23d  (compileBroker.cpp:1917)
V  [jvm.dll+0x7ef322]  JavaThread::thread_main_inner+0x282  (javaThread.cpp:711)
V  [jvm.dll+0xde5833]  Thread::call_run+0x253  (thread.cpp:229)
V  [jvm.dll+0xbf6948]  os::win32::thread_native_entry+0xb8  (os_windows.cpp:550)
C  [ucrtbase.dll+0x21bb2]
C  [KERNEL32.DLL+0x174b4]
C  [ntdll.dll+0x526a1]


Comments
Changeset: d2660a69 Author: Emanuel Peter <epeter@openjdk.org> Date: 2023-02-27 07:15:27 +0000 URL: https://git.openjdk.org/jdk/commit/d2660a6915582d059d456f1ae8c78831b15f0ef2
27-02-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/12713 Date: 2023-02-22 13:35:35 +0000
22-02-2023

Quick analysis: This is part of the stacktrace: V [jvm.dll+0x577307] report_vm_error+0xb7 (debug.cpp:286) V [jvm.dll+0x457efb] RegionNode::set_loop_status+0x3b (cfgnode.cpp:439) V [jvm.dll+0xaa56c6] IdealLoopTree::split_fall_in+0x156 (loopnode.cpp:3148) In IdealLoopTree::split_fall_in we call RegionNode::set_loop_status. We want to transfer the loop-status of the old loop header to the new landing_pad. But set_loop_status has an assert that we do not set the default value NeverIrreducibleEntry. I think I should be able to create an example that triggers this, maybe in this way: Loop must be in a inlined method. Then, by default the regions are tagged with NeverIrreducibleEntry (we cannot know if the inlined method sits inside only reducible loops or also inside an irreducible loop). Then, we must make sure that in the inlined method we have a loop that triggers split_fall_in. So we need a loop with multiple fall-in (entry) edges to the same loop-head. If that is correct, I think we can just remove or at least somehow weaken the assert.
22-02-2023

Ok, I can have a look.
22-02-2023

Emanuel, please have a look.
22-02-2023

Initial ILW = (Potentially harmless) assert during C2 compilation, only showed up once with single test, no known workaround but disable compilation of affected method = MLH = P4
22-02-2023

The assert and corresponding logic was added by JDK-8280126 in JDK 21.
22-02-2023

Update: I was able to construct a reproducer for the assert from other tests, basically as outlined above. java -jar ~/Documents/asmtools-7.0-build/release/lib/asmtools.jar jasm Test.jasm javac TestMain.java ./java -Xbatch -XX:CompileCommand=compileonly,Test*::test* -XX:CompileCommand=printcompilation,Test*::test* -XX:+PrintInlining -XX:PerMethodTrapLimit=0 TestMain I get this (for debugging, I print the _head and landing_pad before we call set_loop_status): CompileCommand: compileonly Test*.test* bool compileonly = true CompileCommand: PrintCompilation Test*.test* bool PrintCompilation = true 782 27 b 3 TestMain::test_outer (7 bytes) @ 3 Test::test_inner (45 bytes) callee is too large 784 28 b 3 Test::test_inner (45 bytes) 786 29 b 4 Test::test_inner (45 bytes) split_fall_in 69 Region === 69 58 98 54 [[ 69 76 80 ]] #reducible !jvms: Test::test_inner @ bci:23 118 Region === 118 _ _ [[ 118 ]] 788 30 b 4 TestMain::test_outer (7 bytes) split_fall_in 78 Region === 78 67 107 63 [[ 78 85 89 ]] !jvms: Test::test_inner @ bci:23 TestMain::test_outer @ bci:3 (line 32) 128 Region === 128 _ _ [[ 128 ]] # # A fatal error has been detected by the Java Runtime Environment: # # Internal Error (/home/emanuel/Documents/fork2-jdk/open/src/hotspot/share/opto/cfgnode.cpp:439), pid=691014, tid=691029 # assert(status != RegionNode::LoopStatus::NeverIrreducibleEntry) failed: do not set this # .....
22-02-2023