C2 compiler assertion failure in mixed mode with strip-mined loop: assert(is_OuterStripMinedLoop()) failed at node.hpp:882 when compiling a small test case

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      - Operating system: Linux
      - Compiler/toolchain: GCC 9.5
      - Source commit: 18b30dbc0742f3cc70b3f03ce4417e7c4789cc3b (tag: 11.0.31-internal+0, branch: master)
      - Build type: fastdebug (also happens in release version)
      - Build environment: Linux, compiled from source with GCC 9.5
      - Also happens in 11.0.30(commit: 5d80a0e0571e163077356904d7810fcc8d9b26f0), released version
      - Also happens in jdk-11.0.30+7, released version


      A DESCRIPTION OF THE PROBLEM :
      Running the attached Java program under -Xmixed -Xbatch on an OpenJDK 11u fastdebug build crashes the VM with an internal C2 assertion:
      assert(is_OuterStripMinedLoop()) failed: invalid node class
      This looks related to loop strip-mining in the C2 optimizer. The same program runs to completion under -Xcomp -Xbatch and -Xint -Xbatch, so the issue appears specific to mixed-mode compilation with tiered/C2.

      The JVM generates both an hs_err file and a compiler replay log, indicating the crash occurs during JIT compilation. The failure is 100% reproducible on my setup with -Xmixed -Xbatch.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Save the source code below as Test.java.
      2. Compile: javac Test.java
      3. Run with mixed mode: java -Xmixed -Xbatch Test
         - Crashes with the assertion in node.hpp:882.
      4. Compare with:
         - java -Xcomp -Xbatch Test => prints PASS
         - java -Xint -Xbatch Test => prints PASS

      ---------- BEGIN SOURCE ----------

      public class Test {
          
          public static void main(String[] args) {
              try {
                  for (int i = 0; i < 10000; i++) {
                      foo();
                  }
              } catch (Exception ex) {
              }
              System.out.println("PASS");
          }

          static int foo() {
              int minusOne = -1;
              int localVar1 = 175;
              boolean localVar2 = false;
              int[] arr = null;
              
              for (int tmpVar1 = 0; tmpVar1 < localVar1; tmpVar1++) {
                  for (minusOne = 0; minusOne < gb_int; minusOne++) {
                      if ((localVar1) > 0) {
                          minusOne = minusOne + minusOne;
                          for (minusOne = 0; minusOne < gb_int2; minusOne++) {
                              if ((268) > 0) {
                                  minusOne = minusOne + minusOne;
                                  localVar1 += (230);
                                  int tmp1 = localVar1 + (230);
                                  int tmp2 = localVar1 - (230);
                                  arr = new int[minusOne];
                              }
                          }
                      }
                  }
                  minusOne += (202);
                  boolean tmp3 = localVar2 && (!localVar2);
                  
              }
              return arr[minusOne - 1];
          }

          public static int gb_int = 175;

          public static int gb_int2 = 175;

          public static int gb_int3 = 175;
      }

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

      FREQUENCY :
      ALWAYS

            Assignee:
            Daniel Skantz
            Reporter:
            Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: