C2: synchronized remains reachable when it shouldn't

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: P4
    • None
    • Affects Version/s: 26
    • Component/s: hotspot

      In the repro below, synchronized block is never reached as a[i] always throws. It remains reachable and causes JDK-8373011 on its Unlock node. Instead, it seems that anything after a[i] = 0 should be marked as dead code and not processed further.

      public class Repro {
          public static void main(String[] args) {
              int[] a = new int[0]; // test only valid when size is 0.
              for (int i = 0; i < Integer.valueOf(10000); i++) // test only valid with boxed loop limit
                  try {
                      test(a);
                  } catch (ArrayIndexOutOfBoundsException e) {
                  }
          }

          static void test(int[] a) {
              for (int i = 0; i < 1;) {
                  a[i] = 0;
                  synchronized (TestUnlockNodeNullMemprof.class) {
                  }
                  for (int j = 0; Integer.valueOf(j) < 1;)
                      j = 0;
              }
          }
      }


      (repro simplified from JDK-8370502)

            Assignee:
            Unassigned
            Reporter:
            Kerem Kat
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: