Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8307522

C2: assert(n->req() == 2 && n->in(1) != __null) failed

XMLWordPrintable

    • x86_64
    • linux_ubuntu

      ADDITIONAL SYSTEM INFORMATION :
      OS: 22.04

      A DESCRIPTION OF THE PROBLEM :
      C2 crash when compile the following code without any options:
      ```
      import java.util.Arrays;

      public class TestIllegalArrayCopyBeforeInfiniteLoop {
          private static char src[] = new char[10];
          private static int count = 0;
          private static final int iter = 10_000;

          public static void main(String[] args) throws Exception {
              for (int i = 0; i < iter; ++i) {
                  foo();
              }
              if (count != iter) {
                  throw new RuntimeException("test failed");
              }
          }

          static void foo() {
              try {
                  Arrays.copyOfRange(src, -1, 128);
                  do {
                  } while (true);
              } catch (ArrayIndexOutOfBoundsException ex) {
                  count++;
              }
          }
      }
      ```

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      To reproduce:

      `java TestIllegalArrayCopyBeforeInfiniteLoop.java`


      ---------- BEGIN SOURCE ----------
      import java.util.Arrays;

      public class TestIllegalArrayCopyBeforeInfiniteLoop {
          private static char src[] = new char[10];
          private static int count = 0;
          private static final int iter = 10_000;

          public static void main(String[] args) throws Exception {
              for (int i = 0; i < iter; ++i) {
                  foo();
              }
              if (count != iter) {
                  throw new RuntimeException("test failed");
              }
          }

          static void foo() {
              try {
                  Arrays.copyOfRange(src, -1, 128);
                  do {
                  } while (true);
              } catch (ArrayIndexOutOfBoundsException ex) {
                  count++;
              }
          }
      }

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

            thartmann Tobias Hartmann
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: