JDK-8297642 : PhaseIdealLoop::only_has_infinite_loops must detect all loops that never lead to termination
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 17,20
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-11-25
  • Updated: 2024-07-04
  • Resolved: 2022-12-08
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 20
17.0.7-oracleFixed 20 b27Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
This is a reduction from a fuzzer test I am using for JDK-8280126, but it used to work on my un-synced repo. Probably it is related to the issues in JDK-8294217.

When I last debugged the test, it seemed to create an infinite irreducible loop, that did not have a NeverBranch node inserted. That was also against my assumption at the time. But I was able to work around that. Now it seems to be triggered in maiinline already.

Reproduce it:
java -jar ~/Documents/asmtools-7.0-build/release/lib/asmtools.jar jasm TestIrreducibleInfiniteNoNeverBranch.jasm
java -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:CompileCommand=compileonly,TestIrreducibleInfiniteNoNeverBranch::test* -XX:-TieredCompilation -XX:-RenumberLiveNodes -Xbatch -Xcomp -XX:PerMethodTrapLimit=0 -XX:+TraceLoopOpts TestIrreducibleInfiniteNoNeverBranch

I vaguely remember that -XX:PerMethodTrapLimit=0 was required to create this graph.

# To suppress the following error report, specify this argument
# after -XX: or in .hotspotrc:  SuppressErrorAt=/loopnode.cpp:4300
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/home/emanuel/Documents/fork2-jdk/open/src/hotspot/share/opto/loopnode.cpp:4300), pid=1154129, tid=1154142
#  assert(_ltree_root->_child == __null || C->has_loops() || only_has_infinite_loops() || C->has_exception_backedge()) failed: parsing found no loops but there are some
#
# JRE version: Java(TM) SE Runtime Environment (20.0) (slowdebug build 20-internal-2022-11-25-1142101.emanuel...)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (slowdebug 20-internal-2022-11-25-1142101.emanuel..., compiled mode, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0xf685e3]  PhaseIdealLoop::build_and_optimize()+0x353
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -- %E" (or dumping to /home/emanuel/Documents/debug-tools/bytecode-fuzzer/core.1154129)
#
# An error report file with more information is saved as:
# /home/emanuel/Documents/debug-tools/bytecode-fuzzer/hs_err_pid1154129.log
#
# Compiler replay data is saved as:
# /home/emanuel/Documents/debug-tools/bytecode-fuzzer/replay_pid1154129.log
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
#

Current CompileTask:
C2:36803  100 %  b  4       Test::test @ 2 (27 bytes)

Stack: [0x00007f4fc436f000,0x00007f4fc4470000],  sp=0x00007f4fc446ad80,  free space=1007k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x12a2718]  PhaseIdealLoop::place_outside_loop(Node*, IdealLoopTree*) const+0x348  (loopopts.cpp:1266)
V  [libjvm.so+0x12a5bd6]  PhaseIdealLoop::try_sink_out_of_loop(Node*)+0x376  (loopopts.cpp:1753)
V  [libjvm.so+0x12a6603]  PhaseIdealLoop::split_if_with_blocks_post(Node*)+0x83  (loopopts.cpp:1531)
V  [libjvm.so+0x12a6ec6]  PhaseIdealLoop::split_if_with_blocks(VectorSet&, Node_Stack&)+0x96  (loopopts.cpp:1964)
V  [libjvm.so+0x1299519]  PhaseIdealLoop::build_and_optimize()+0xee9  (loopnode.cpp:4815)
V  [libjvm.so+0x9e4770]  PhaseIdealLoop::optimize(PhaseIterGVN&, LoopOptsMode)+0x390  (loopnode.hpp:1117)
V  [libjvm.so+0x9df283]  Compile::Optimize()+0x4c3  (compile.cpp:2366)
V  [libjvm.so+0x9e3326]  Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x1b06  (compile.cpp:852)
V  [libjvm.so+0x835575]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x1d5  (c2compiler.cpp:142)
V  [libjvm.so+0x9eef68]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0x928  (compileBroker.cpp:2303)
V  [libjvm.so+0x9efbf8]  CompileBroker::compiler_thread_loop()+0x478  (compileBroker.cpp:1961)
V  [libjvm.so+0xe994dc]  JavaThread::thread_main_inner()+0xcc  (javaThread.cpp:757)
V  [libjvm.so+0x17b9076]  Thread::call_run()+0xb6  (thread.cpp:225)
V  [libjvm.so+0x14a1717]  thread_native_entry(Thread*)+0x127  (os_linux.cpp:858)
Comments
Fix request [17u] I backport this for parity with 17.0.7-oracle. No risk, fixes an assertion. Related issues are either backported or just discuss this issue. Clean backport. Test passes and fails without the fix. SAP nighlty testing passed.
15-01-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk17u-dev/pull/1058 Date: 2023-01-11 14:49:34 +0000
11-01-2023

Changeset: d562d3fc Author: Emanuel Peter <epeter@openjdk.org> Date: 2022-12-08 15:29:26 +0000 URL: https://git.openjdk.org/jdk/commit/d562d3fcbe22a0443037c5b447e1a41401275814
08-12-2022

Note, the bug is NOT limited to irreducible loops.
02-12-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/11473 Date: 2022-12-02 08:11:06 +0000
02-12-2022

A second from those fuzzer tests also produces this same assert. test_020 and test_021
25-11-2022

ILW = Debug assert in C2, single irreducible test case and debug VM only, no workaround = MLH = P4
25-11-2022