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

[Graal] Initialized array might be set to null if initialized with negative size

    XMLWordPrintable

    Details

      Description

      The attached test fails with NPE with Graal, works fine with C2/C1.

      To reproduce
      java -Xmx4G -Xcomp -Xbatch -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-TieredCompilation -XX:+UseJVMCICompiler -Djvmci.Compiler=graal -XX:CompileOnly=Test -XX:JVMCIThreads=1 Test



      The failed block is her. The iArr is set to null in line "114: iArr = new int[i16];"
      ----
              FuzzerUtils.init(iArr, 48);
              FuzzerUtils.init(dArr1, 97.120959);

              for (int i1 : iArr) {
                  iArr[(i1 >>> 1) % N] = (int)((i1 + d) * (iMeth1((byte)(-26), 23003) * i1));
                  s1 |= (short)Test.instanceCount;
      }
      try {
                  i16 = -10;
                  iArr = new int[i16];
                  System.out.println(iArr);

              }
              catch (NegativeArraySizeException exc3) {
                  System.out.println(iArr);

      ---

      Output:
      [I@1ee807c6
      [I@1ee807c6
      [[D@76a4d6c
      i s2 i20 = 3,-22665,308
      i21 b2 i22 = 0,1,1
      i23 i24 i25 = 11,13,85
      i26 by1 i27 = 24354,0,1
      i28 i29 i30 = 56665,2,-59409
      i31 iArr1 bArr = 2,5744,52917
      dArr2 = 5014282634130562625
      Test.instanceCount dFld Test.fFld = -532517063,4672423618418835456,1186874932
      Test.lArrFld Test.fArrFld = -1786446380397048024,4644683212426575872
      vMeth_check_sum: 7032348078224458096
      iMeth1_check_sum: -484578656290674832
      iMeth_check_sum: -9120033907704388679
      null
      null
      [[D@78a2da20
      Exception in thread "main" java.lang.NullPointerException
      at FuzzerUtils.checkSum(FuzzerUtils.java:224)
      at Test.iMeth(Test.java:142)
      at Test.mainTest(Test.java:160)
      at Test.main(Test.java:221)

        Attachments

        1. FuzzerUtils.class
          8 kB
        2. FuzzerUtils.java
          13 kB
        3. FuzzerUtils$1.class
          0.8 kB
        4. Test.class
          6 kB
        5. Test.java
          9 kB
        6. UserDefinedExceptionTest.class
          0.2 kB

          Issue Links

            Activity

              People

              Assignee:
              never Tom Rodriguez
              Reporter:
              lmesnik Leonid Mesnik
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: