JDK-8317504 : assert(false) failed: Bad graph detected in build_loop_late
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 8
  • Priority: P4
  • Status: New
  • Resolution: Unresolved
  • OS: linux_ubuntu
  • CPU: x86_64
  • Submitted: 2023-09-25
  • Updated: 2023-10-04
Description
ADDITIONAL SYSTEM INFORMATION :
# JRE version: OpenJDK Runtime Environment (8.0_392) (build 1.8.0_392-internal-fastdebug--b00)
# Java VM: OpenJDK 64-Bit Server VM (25.392-b00-fastdebug compiled mode linux-amd64 compressed oops)

A DESCRIPTION OF THE PROBLEM :
I ran a regression testcase on JDK8u392 and found that the JVM crashed without any options.

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/data//jdk8u/hotspot/src/share/vm/opto/loopnode.cpp:3621), pid=32638, tid=0x00007f8fca050700
#  assert(false) failed: Bad graph detected in build_loop_late
#
# JRE version: OpenJDK Runtime Environment (8.0_392) (build 1.8.0_392-internal-fastdebug--b00)
# Java VM: OpenJDK 64-Bit Server VM (25.392-b00-fastdebug compiled mode linux-amd64 compressed oops)
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
#

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
java TestLoopPredicateDep

ACTUAL -
Bad graph detected in build_loop_late
n:  494 Bool    === _  493  [[ 479 ]] [lt]
early(n):  184  IfTrue  ===  175  [[ 421  432 ]] #1 !jvms: TestLoopPredicateDep::getPermutations @ bci:44
n->in(1):  493  CmpUL   === _  491  492  [[ 494 ]] 
early(n->in(1)):  184   IfTrue  ===  175  [[ 421  432 ]] #1 !jvms: TestLoopPredicateDep::getPermutations @ bci:44
n->in(1)->in(1):  491   AddL    === _  502  500  [[ 493 ]] 
early(n->in(1)->in(1)):  184    IfTrue  ===  175  [[ 421  432 ]] #1 !jvms: TestLoopPredicateDep::getPermutations @ bci:44
n->in(1)->in(2):  492   ConvI2L === _  212  [[ 493  486 ]]  #long:0..maxint !orig=[485]
early(n->in(1)->in(2)):  446    IfTrue  ===  445  [[ 448  210 ]] #1

LCA(n):  477    IfTrue  ===  476  [[ 479 ]] #1
n->out(0):  479 If      ===  477  494  [[ 480  481 ]] P=0.999999, C=-1.000000 !orig=163 !jvms: TestLoopPredicateDep::getPermutations @ bci:44
n->out(0)->out(0):  480 IfTrue  ===  479  [[ 163  227  232 ]] #1
n->out(0)->out(1):  481 IfFalse ===  479  [[ 444 ]] #0

idom[0]  477    IfTrue  ===  476  [[ 479 ]] #1
idom[1]  476    If      ===  455  487  [[ 477  478 ]] P=0.999999, C=-1.000000 !orig=163 !jvms: TestLoopPredicateDep::getPermutations @ bci:44
idom[2]  455    IfTrue  ===  454  [[ 476  323  328 ]] #1
idom[3]  454    If      ===  452  461  [[ 455  456 ]] P=0.999999, C=-1.000000 !orig=163 !jvms: TestLoopPredicateDep::getPermutations @ bci:44
idom[4]  452    IfTrue  ===  451  [[ 454 ]] #1
idom[5]  451    If      ===  449  458  [[ 452  453 ]] P=0.999999, C=-1.000000 !orig=163 !jvms: TestLoopPredicateDep::getPermutations @ bci:44
idom[6]  449    IfTrue  ===  448  [[ 451  249  254 ]] #1
idom[7]  448    If      ===  446  237  [[ 449  450 ]] P=0.999999, C=-1.000000 !orig=163 !jvms: TestLoopPredicateDep::getPermutations @ bci:44
idom[8]  446    IfTrue  ===  445  [[ 448  210 ]] #1
idom[9]  445    If      ===  150  199  [[ 446  447 ]] P=0.999999, C=-1.000000 !orig=163 !jvms: TestLoopPredicateDep::getPermutations @ bci:44
idom[10]  150   IfTrue  ===  149  [[ 445 ]] #1 !jvms: TestLoopPredicateDep::getPermutations @ bci:41
idom[11]  149   If      ===  414  148  [[ 150  151 ]] P=0.000012, C=483322.000000 !jvms: TestLoopPredicateDep::getPermutations @ bci:41
idom[12]  414   Loop    ===  414  113  388  [[ 414  119  423  441  116  149  126 ]]  !orig=[114] !jvms: TestLoopPredicateDep::getPermutations @ bci:22
idom[13]  113   IfTrue  ===  103  [[ 414 ]] #1 !jvms: TestLoopPredicateDep::getPermutations @ bci:22
idom[14]  103   If      ===  100  102  [[ 104  113 ]] P=0.999999, C=-1.000000 !jvms: TestLoopPredicateDep::getPermutations @ bci:22
idom[15]  100   IfTrue  ===  90  [[ 103 ]] #1 !jvms: TestLoopPredicateDep::getPermutations @ bci:22
idom[16]  90    If      ===  464  89  [[ 91  100 ]] P=0.999999, C=-1.000000 !jvms: TestLoopPredicateDep::getPermutations @ bci:22
idom[17]  464   IfTrue  ===  463  [[ 90  143 ]] #1
idom[18]  463   If      ===  54  131  [[ 464  465 ]] P=0.999999, C=-1.000000 !orig=90 !jvms: TestLoopPredicateDep::getPermutations @ bci:22
idom[19]  54    Proj    ===  53  [[ 463  57 ]] #0 !jvms: TestLoopPredicateDep::getPermutations @ bci:1
idom[20]  53    Initialize      ===  45  1  56  1  1  52  70  [[ 54  55 ]]  !jvms: TestLoopPredicateDep::getPermutations @ bci:1
idom[21]  45    CatchProj       ===  44  [[ 53  70 ]] #0@bci -1  !jvms: TestLoopPredicateDep::getPermutations @ bci:1
idom[22]  44    Catch   ===  41  43  [[ 45  46 ]]  !jvms: TestLoopPredicateDep::getPermutations @ bci:1
idom[23]  41    Proj    ===  40  [[ 44 ]] #0 !jvms: TestLoopPredicateDep::getPermutations @ bci:1
idom[24]  40    AllocateArray   ===  5  6  7  8  1 ( 38  23  28  22  10  11  1  1  1  1  1 ) [[ 41  42  43  50  51  52 ]]  rawptr:NotNull ( int:>=0, java/lang/Object:NotNull *, bool, int ) TestLoopPredicateDep::getPermutations @ bci:1 !jvms: TestLoopPredicateDep::getPermutations @ bci:1
idom[25]  5     Parm    ===  3  [[ 40 ]] Control !jvms: TestLoopPredicateDep::getPermutations @ bci:-1

# To suppress the following error report, specify this argument
# after -XX: or in .hotspotrc:  SuppressErrorAt=/loopnode.cpp:3621
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/data//jdk8u/hotspot/src/share/vm/opto/loopnode.cpp:3621), pid=79762, tid=0x00007f2de4939700
#  assert(false) failed: Bad graph detected in build_loop_late
#
# JRE version: OpenJDK Runtime Environment (8.0_392) (build 1.8.0_392-internal-fastdebug--b00)
# Java VM: OpenJDK 64-Bit Server VM (25.392-b00-fastdebug mixed mode linux-amd64 compressed oops)
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home//repository//toreport/TestLoopPredicateDep_09_24_13_39_23/hs_err_pid79762.log
#
# Compiler replay data is saved as:
# /home//repository//toreport/TestLoopPredicateDep_09_24_13_39_23/replay_pid79762.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
#

---------- BEGIN SOURCE ----------
public class TestLoopPredicateDep {
    public static void getPermutations(byte[] inputArray, byte[][] outputArray) {
        int[] indexes = new int[]{0, 2};

        for (int a = 0; a < a + 16; a++) {
            int oneIdx = indexes[0]++;
            for (int b = a + 1; b < inputArray.length; b++) {
                int twoIdx = indexes[1]++;
                outputArray[twoIdx][0] = inputArray[a];
                outputArray[twoIdx][1] = inputArray[b];
            }
        }
    }

    public static void main(String[] args) {
        final byte[] inputArray = new byte[]{0, 1};
        final byte[][] outputArray = new byte[3][2];

        for (int i = 0; i < 10; ++i) {
            Thread t = new Thread(new Runnable() {
                public void run() {
                    for (int i = 0; i < 1000000; i++) {
                        getPermutations(inputArray, outputArray);
                    }
                }
            });
            t.setDaemon(true);
            t.start();
            try {
                Thread.sleep(100);
            } catch (Exception e) {
            }
        }
    }

}

---------- END SOURCE ----------

FREQUENCY : always