JDK-8307522 : C2: assert(n->req() == 2 && n->in(1) != __null) failed
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 11.0.19
  • Priority: P4
  • Status: New
  • Resolution: Unresolved
  • OS: linux_ubuntu
  • CPU: x86_64
  • Submitted: 2023-04-27
  • Updated: 2023-05-05
Description
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 ----------


Comments
Issue is reproduced on debug build. crash is observed. OS: Windows 10 JDK 11.0.19 fastdebug: Fail JDK 17.0.7 fastdebug: Pass JDK 20.0.1 fastdebug: Pass JDK 21ea: Pass ILW = assertion failure in debug build (no failure observed in release build); reported once ; no workaround available = MLM = P4 Moving it to dev team for further analysis.
05-05-2023