JDK-8290964 : C2 compilation fails with assert "non-reduction loop contains reduction nodes"
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 11.0.16,17,19,20
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-07-25
  • Updated: 2023-01-09
  • Resolved: 2022-10-05
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 11 JDK 17 JDK 19 JDK 20
11.0.19-oracleFixed 17.0.7-oracleFixed 19.0.2Fixed 20 b18Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
Similar to JDK-8286177:

#  Internal Error (/oracle/jdk3/open/src/hotspot/share/opto/superword.cpp:2452), pid=1970381, tid=1970394
#  assert(!lpt()->has_reduction_nodes() || cl->is_reduction_loop()) failed: non-reduction loop contains reduction nodes
#
# JRE version: Java(TM) SE Runtime Environment (20.0) (fastdebug build 20-internal-2022-07-25-1155399.tobias...)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 20-internal-2022-07-25-1155399.tobias..., compiled mode, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0x1a4948e]  SuperWord::output()+0xc0e

Current CompileTask:
C2:    305   31    b  4       Test::mainTest (617 bytes)

Stack: [0x00007f294ad5d000,0x00007f294ae5e000],  sp=0x00007f294ae57e00,  free space=1003k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x1a4948e]  SuperWord::output()+0xc0e
V  [libjvm.so+0x1a4c4b2]  SuperWord::transform_loop(IdealLoopTree*, bool)+0x262
V  [libjvm.so+0x14ffed2]  PhaseIdealLoop::build_and_optimize()+0x12b2
V  [libjvm.so+0xb1c5e3]  PhaseIdealLoop::optimize(PhaseIterGVN&, LoopOptsMode)+0x293
V  [libjvm.so+0xb18e37]  Compile::Optimize()+0xda7
V  [libjvm.so+0xb1b020]  Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x15c0
V  [libjvm.so+0x925373]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x683
V  [libjvm.so+0xb2a138]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0xbb8
V  [libjvm.so+0xb2b068]  CompileBroker::compiler_thread_loop()+0x638
V  [libjvm.so+0x10a5c88]  JavaThread::thread_main_inner()+0x238
V  [libjvm.so+0x1ada4e0]  Thread::call_run()+0x100
V  [libjvm.so+0x17974a4]  thread_native_entry(Thread*)+0x104
Comments
A pull request was submitted for review. URL: https://git.openjdk.org/jdk11u-dev/pull/1630 Date: 2023-01-03 17:47:05 +0000
03-01-2023

Fix request [11u, 17u] I backport this for parity with 11.0.19-/17.0.7-oracle. No risk, removes assertions in C2. Clean backport. SAP nightly testing passed.
03-01-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk17u-dev/pull/1008 Date: 2022-12-30 17:46:16 +0000
30-12-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk19u/pull/84 Date: 2022-11-22 16:02:35 +0000
22-11-2022

Fix Request (JDK 19u) Fixes an assertion during C2 compilation. The fix is low risk (only removes assertion code) and applies cleanly. Already tested and backported to Oracle JDK 11u and 17u.
22-11-2022

Changeset: 4bdd1c91 Author: Roberto CastaƱeda Lozano <rcastanedalo@openjdk.org> Date: 2022-10-05 09:43:31 +0000 URL: https://git.openjdk.org/jdk/commit/4bdd1c914859e221c64208d47ef309d463609953
05-10-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/10535 Date: 2022-10-03 13:41:07 +0000
03-10-2022

Attachment <Test-2.java> could not be scanned. The system has removed attachment. Please check the file before attempting to upload it again
05-09-2022

Attachment <Test-2.java> could not be scanned. The system has removed attachment. Please check the file before attempting to upload it again
05-09-2022

I've attached another fuzzer fail (Test-2.java). To reproduce: $ java -Xcomp -XX:CompileOnly=Test Test-2.java
05-09-2022

I've attached both hs_err_pid files the jdk-19+34-2229-tier8 sighting: $ ls -ltr hs_err_pid* -rw-r--r--@ 1 dcubed green 80651 Aug 7 09:23 hs_err_pid31368.log -rw-r--r--@ 1 dcubed green 80488 Aug 7 09:23 hs_err_pid45332.log
07-08-2022

Here's snippets from the first hs_err_pid file in the jdk-19+34-2229-tier8 sighting: applications/javafuzzer/BigTest.java # Internal Error (c:\sb\prod\1659537137\workspace\open\src\hotspot\share\opto\superword.cpp:2422), pid=31368, tid=28736 # assert(!lpt()->has_reduction_nodes() || cl->is_reduction_loop()) failed: non-reduction loop contains reduction nodes # # JRE version: Java(TM) SE Runtime Environment (19.0+34) (fastdebug build 19-ea+34-2229) # Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 19-ea+34-2229, compiled mode, sharing, compressed oops, compressed class ptrs, g1 gc, windows-amd64) <snip> --------------- T H R E A D --------------- Current thread (0x000002566f332ca0): JavaThread "C2 CompilerThread0" daemon [_thread_in_native, id=28736, stack(0x0000007e92e00000,0x0000007e92f00000)] Current CompileTask: C2: 319 3 !b Test::mainTest (634 bytes) Stack: [0x0000007e92e00000,0x0000007e92f00000] Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) V [jvm.dll+0xc85441] os::platform_print_native_stack+0xf1 (os_windows_x86.cpp:235) V [jvm.dll+0xee793b] VMError::report+0x10eb (vmError.cpp:835) V [jvm.dll+0xee947e] VMError::report_and_die+0x7fe (vmError.cpp:1687) V [jvm.dll+0xee9c04] VMError::report_and_die+0x64 (vmError.cpp:1468) V [jvm.dll+0x5a72a7] report_vm_error+0xb7 (debug.cpp:283) V [jvm.dll+0xdfa49d] SuperWord::output+0xed (superword.cpp:2421) V [jvm.dll+0xdeb86c] SuperWord::SLP_extract+0x52c (superword.cpp:582) V [jvm.dll+0xe01629] SuperWord::transform_loop+0x419 (superword.cpp:179) V [jvm.dll+0xae155d] PhaseIdealLoop::build_and_optimize+0x13ad (loopnode.cpp:4597) V [jvm.dll+0x53971a] Compile::Optimize+0x111a (compile.cpp:2300) V [jvm.dll+0x536492] Compile::Compile+0x1472 (compile.cpp:818) V [jvm.dll+0x45d795] C2Compiler::compile_method+0x145 (c2compiler.cpp:115) V [jvm.dll+0x54fc31] CompileBroker::invoke_compiler_on_method+0x791 (compileBroker.cpp:2313) V [jvm.dll+0x54d2b9] CompileBroker::compiler_thread_loop+0x279 (compileBroker.cpp:1981) V [jvm.dll+0xe64e44] JavaThread::thread_main_inner+0x2a4 (thread.cpp:1332) V [jvm.dll+0xe59e5c] Thread::call_run+0x1ac (thread.cpp:366) V [jvm.dll+0xc83ce9] thread_native_entry+0xb9 (os_windows.cpp:545) C [ucrtbase.dll+0x1fb80] C [KERNEL32.DLL+0x84d4] C [ntdll.dll+0x51791] Here's snippets from the second hs_err_pid file in the jdk-19+34-2229-tier8 sighting: # Internal Error (c:\sb\prod\1659537137\workspace\open\src\hotspot\share\opto\superword.cpp:2422), pid=45332, tid=39028 # assert(!lpt()->has_reduction_nodes() || cl->is_reduction_loop()) failed: non-reduction loop contains reduction nodes # # JRE version: Java(TM) SE Runtime Environment (19.0+34) (fastdebug build 19-ea+34-2229) # Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 19-ea+34-2229, compiled mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, windows-amd64) <snip> --------------- T H R E A D --------------- Current thread (0x000002bc30b35df0): JavaThread "C2 CompilerThread0" daemon [_thread_in_native, id=39028, stack(0x000000e4dbf00000,0x000000e4dc000000)] Current CompileTask: C2: 340 6 !b 4 Test::mainTest (634 bytes) Stack: [0x000000e4dbf00000,0x000000e4dc000000] Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) V [jvm.dll+0xc85441] os::platform_print_native_stack+0xf1 (os_windows_x86.cpp:235) V [jvm.dll+0xee793b] VMError::report+0x10eb (vmError.cpp:835) V [jvm.dll+0xee947e] VMError::report_and_die+0x7fe (vmError.cpp:1687) V [jvm.dll+0xee9c04] VMError::report_and_die+0x64 (vmError.cpp:1468) V [jvm.dll+0x5a72a7] report_vm_error+0xb7 (debug.cpp:283) V [jvm.dll+0xdfa49d] SuperWord::output+0xed (superword.cpp:2421) V [jvm.dll+0xdeb86c] SuperWord::SLP_extract+0x52c (superword.cpp:582) V [jvm.dll+0xe01629] SuperWord::transform_loop+0x419 (superword.cpp:179) V [jvm.dll+0xae155d] PhaseIdealLoop::build_and_optimize+0x13ad (loopnode.cpp:4597) V [jvm.dll+0x53971a] Compile::Optimize+0x111a (compile.cpp:2300) V [jvm.dll+0x536492] Compile::Compile+0x1472 (compile.cpp:818) V [jvm.dll+0x45d795] C2Compiler::compile_method+0x145 (c2compiler.cpp:115) V [jvm.dll+0x54fc31] CompileBroker::invoke_compiler_on_method+0x791 (compileBroker.cpp:2313) V [jvm.dll+0x54d2b9] CompileBroker::compiler_thread_loop+0x279 (compileBroker.cpp:1981) V [jvm.dll+0xe64e44] JavaThread::thread_main_inner+0x2a4 (thread.cpp:1332) V [jvm.dll+0xe59e5c] Thread::call_run+0x1ac (thread.cpp:366) V [jvm.dll+0xc83ce9] thread_native_entry+0xb9 (os_windows.cpp:545) C [ucrtbase.dll+0x1fb80] C [KERNEL32.DLL+0x84d4] C [ntdll.dll+0x51791]
07-08-2022

Here's some hs_err_pid snippets for the jdk-20+10-537-tier6 sighting: applications/javafuzzer/MediumTest.java # Internal Error (c:\sb\prod\1659691166\workspace\open\src\hotspot\share\opto\superword.cpp:2453), pid=19524, tid=6852 # assert(!lpt()->has_reduction_nodes() || cl->is_reduction_loop()) failed: non-reduction loop contains reduction nodes # # JRE version: Java(TM) SE Runtime Environment (20.0+10) (fastdebug build 20-ea+10-537) # Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 20-ea+10-537, compiled mode, sharing, compressed oops, compressed class ptrs, g1 gc, windows-amd64) <snip> --------------- T H R E A D --------------- Current thread (0x0000023aba10a2d0): JavaThread "C2 CompilerThread0" daemon [_thread_in_native, id=6852, stack(0x0000008584400000,0x0000008584500000)] Current CompileTask: C2: 734 78 b Test::mainTest (618 bytes) Stack: [0x0000008584400000,0x0000008584500000] Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) V [jvm.dll+0xc5e081] os::win32::platform_print_native_stack+0xf1 (os_windows_x86.cpp:236) V [jvm.dll+0xebb29e] VMError::report+0x10de (vmError.cpp:839) V [jvm.dll+0xebccce] VMError::report_and_die+0x65e (vmError.cpp:1687) V [jvm.dll+0xebd444] VMError::report_and_die+0x64 (vmError.cpp:1468) V [jvm.dll+0x59c427] report_vm_error+0xb7 (debug.cpp:284) V [jvm.dll+0xdd62ad] SuperWord::output+0xed (superword.cpp:2452) V [jvm.dll+0xdc6dfc] SuperWord::SLP_extract+0x52c (superword.cpp:584) V [jvm.dll+0xddd3e6] SuperWord::transform_loop+0x3e6 (superword.cpp:179) V [jvm.dll+0xab60ca] PhaseIdealLoop::build_and_optimize+0x135a (loopnode.cpp:4597) V [jvm.dll+0x53014a] Compile::Optimize+0x10da (compile.cpp:2408) V [jvm.dll+0x52cf5d] Compile::Compile+0x14ad (compile.cpp:824) V [jvm.dll+0x452b45] C2Compiler::compile_method+0x145 (c2compiler.cpp:115) V [jvm.dll+0x547050] CompileBroker::invoke_compiler_on_method+0x980 (compileBroker.cpp:2314) V [jvm.dll+0x5445fc] CompileBroker::compiler_thread_loop+0x25c (compileBroker.cpp:1982) V [jvm.dll+0x81385f] JavaThread::thread_main_inner+0x29f (javaThread.cpp:700) V [jvm.dll+0xe34af7] Thread::call_run+0x257 (thread.cpp:229) V [jvm.dll+0xc5c9a8] thread_native_entry+0xb8 (os_windows.cpp:546) C [ucrtbase.dll+0x1fb80] C [KERNEL32.DLL+0x84d4] C [ntdll.dll+0x51791]
06-08-2022

Thanks for the report [~thartmann], I plan to propose a patch for JDK-8287087 for JDK 20, that should address these failures and prevent the potential miscompilations that the assertion warns about.
03-08-2022

I attached another Test that the JavaFuzzer just found.
03-08-2022

Looks like the fix for JDK-8286177 was incomplete (maybe the re-design described in JDK-8287087 is required). [~rcastanedalo], could you please have a look? I can not reproduce this with JDK 17u or 11u but those version should be affected as well.
25-07-2022

ILW = Same as JDK-8286177 = P3
25-07-2022