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

C1: Missing receiver null check in Reference::get intrinsic

    XMLWordPrintable

Details

    • b12
    • 11
    • b03

    Backports

      Description

        Originally reported against Graal https://github.com/oracle/graal/issues/6350 .

        The following code segfaults in C1 compiled tier 1 code with graal (only the tier 1 version crashes, the tier 3 compile of it does not).

        #############################
        import java.lang.ref.WeakReference;
        import java.math.MathContext;

        class T {
          int f() {
            int q = 43837, p;
            MathContext u = null;
            for (int w = 648; w < 9230; w += 1)
              try {
                p = u.getPrecision();
              } catch (Throwable x) {
              } finally {
              }
            WeakReference r = null;
            try {
              while (r.get() != null) {}
            } catch (Throwable x) {
            } finally {
            }
            return (int) (long) q;
          }

          public static void main(String[] g) {
            T t = new T();
            for (; ; ) t.f();
          }
        }
        #############################

        Reproduce with /jdk-21/bin/java -XX:TieredStopAtLevel=1 T1

        Does not crash with regular tiered compilation because c2 compile of this is fine. Crashes with Graal because graal does not OSR compile this loop because the call target method of u.getPrecision(); is not resolved (in fact its always null and throws). MDO has exception seen but no profile so graal rejects OSR. This leads to C1 tier 1 compile of it which fails. Simulate with stop at tier 1 to fault immediately. Theoretically if a similar example would trigger C2 rejecting compile of such an example this could lead to a tier 1 compile of it without graal and expose the problem as well.

        Attachments

          1. Test.java
            0.7 kB
          2. T1.java
            0.5 kB
          3. hs_err_pid86805.log
            70 kB

          Issue Links

            Activity

              People

                thartmann Tobias Hartmann
                davleopo David Leopoldseder
                Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: