C2 Compiler crash "assert(false) failed: bad AD file" in matcher.cpp with -Xcomp on JDK 11

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: P3
    • None
    • Affects Version/s: 11.0.30
    • Component/s: hotspot

      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
      - Build environment: Linux, compiled from source with GCC 9.5

      A DESCRIPTION OF THE PROBLEM :
      A fatal error occurs in the C2 compiler when compiling a specific method generated by a fuzzer. The crash occurs when running with the `-Xcomp` flag on a fastdebug build of OpenJDK 11.

      The crash triggers an assertion failure in `matcher.cpp`:
      `internal Error (.../opto/matcher.cpp:1591), pid=..., tid=... assert(false) failed: bad AD file`.
      This suggests that the instruction matcher encountered a node configuration in the Ideal Graph that could not be mapped to a machine instruction defined in the AD file.

      Specifics:
      - **JDK Version:** OpenJDK 11.0.31 (fastdebug build 11.0.31-internal+0-adhoc.syc.jdk11u-dev)
      - **OS:** Linux x64 (Arch Linux)
      - **Flags:** `-Xcomp` triggers the crash. `-Xint` and `-Xmixed` work correctly.
      - **Error:** `assert(false) failed: bad AD file`

      The log includes a dump of an `If` node and a `Bool` node immediately prior to the crash, indicating the issue likely arises during the matching of a specific control flow pattern involving a Phi node inside a loop/switch construct.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Save the attached source code as `Test.java`.
      2. Compile the source code:
         `javac Test.java`
      3. Run the class with `-Xcomp`:
         `java -Xcomp Test`

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

      public class Test {
          
          public static long instanceCount = 2772208695340607833L;
          public static int iFld = -8;

          public void mainTest(java.lang.String[] strArr1) {
              byte loclaByte = (byte)73;
              int localInt1 = 63811;
              int localInt2 = 606;
              int localInt3 = 606;
              int localInt4 = 4;
              int localInt5 = -4918;
              int localInt6 = -10;
              Object O21 = new Object();
              switch (((((int) (Test.iFld + Test.instanceCount)) >>> 1) % 1) + 39) {
                  case 39 :
                      {
                          localInt1 = 1;
                          do {
                              for (localInt4 = ((int) (98)); localInt4 > 1; localInt4--) {
                                  localInt2 = localInt1 + localInt4;
                                  synchronized(O21) {
                                      switch ((localInt1 % 10) + 68) {
                                          case 75 :
                                              {
                                                  for (localInt3 = 0; localInt3 < (((localInt2) + ((int)(((byte) ((((byte) ((loclaByte) + ((byte)36)))) + (((byte) (((byte)78) + (loclaByte)))))))))); localInt3++) {
                                                      if ((668) > 0) {
                                                          localInt2 = 765;
                                                      } else {
                                                          localInt2 = 765;
                                                  
                                                      }
                                                  }
                                              }
                                          case 76 :
                                              {
                                                  localInt5 = localInt6;
                                              }
                                          case 77 :
                                      }
                                  }
                              }
                          } while ((++localInt1) < 125 );
                      }
              }
          }
          
          public static void main(java.lang.String[] args) {
              Test _instance = new Test();
              for (int i = 0; i < 10; i++) {
                  try {
                      _instance.mainTest(args);
                  } catch (java.lang.Exception ex) {
                      System.out.println(ex.getClass().getCanonicalName());
                  }
              }
              System.out.println("PASS");
          }

      }

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

      FREQUENCY :
      ALWAYS

            Assignee:
            Unassigned
            Reporter:
            Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: