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

C2: Internal Assert Failed: Infinite Loop in PhaseIterGVN::optimize

    XMLWordPrintable

    Details

      Description

      Running the attached test case on a debug build of JDK 19 b23 as follows:

      $ java Test.java

      triggers the following assertion failure:

      (...)
      # To suppress the following error report, specify this argument
      # after -XX: or in .hotspotrc: SuppressErrorAt=/phaseX.cpp:1162
      #
      # A fatal error has been detected by the Java Runtime Environment:
      #
      # Internal Error (src/hotspot/share/opto/phaseX.cpp:1162), pid=22625, tid=22644
      # assert(false) failed: infinite loop in PhaseIterGVN::optimize
      #
      # JRE version: Java(TM) SE Runtime Environment (19.0+23) (fastdebug build 19-ea+23-1706)
      # Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 19-ea+23-1706, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
      # Problematic frame:
      # V [libjvm.so+0x178df37] PhaseIterGVN::optimize()+0x6b7


      ORIGINAL REPORT:

      ADDITIONAL SYSTEM INFORMATION :
      Arch: x86_64
      OS: Ubuntu 20.04 LTS
      HotSpot:
      - openjdk version "11.0.16-internal" 2022-07-19
      - OpenJDK Runtime Environment (fastdebug build 11.0.16-internal+0-adhoc.my.my-jdk11u)
      - OpenJDK 64-Bit Server VM (fastdebug build 11.0.16-internal+0-adhoc.my.my-jdk11u, mixed mode)
      javac: javac 11.0.16-internal

      A DESCRIPTION OF THE PROBLEM :
      This bug is found in https://github.com/openjdk/jdk11u-dev repo (commit 9cb3797f) with the following log

      ```
       416 DecodeN === _ 417 [[ 442 ]] #java/lang/Byte:NotNull:exact * Oop:java/lang/Byte:NotNull:exact * !orig=[313] !jvms: Byte::valueOf @ bci:12 Test::iMeth @ bci:56
       437 Region === 437 451 448 [[ 437 438 442 446 ]] !orig=262,321 !jvms: Test::iMeth @ bci:61
       608 DecodeN === _ 606 [[ 397 522 ]] #java/lang/Byte:NotNull:exact * Oop:java/lang/Byte:NotNull:exact * !orig=[318],592 !jvms: Test::iMeth @ bci:61
       631 DecodeN === _ 629 [[ 522 ]] #java/lang/Byte:NotNull:exact * Oop:java/lang/Byte:NotNull:exact * !orig=[501],[318],592 !jvms: Test::iMeth @ bci:61
       516 Region === 516 512 460 [[ 516 464 519 521 522 523 ]]
       439 IfTrue === 438 [[ 440 ]] #1 !orig=330 !jvms: Test::iMeth @ bci:28
       465 IfTrue === 464 [[ 440 466 ]] #1
       442 Phi === 437 416 441 [[ 441 ]] #java/lang/Byte:exact * Oop:java/lang/Byte:exact * !orig=[318],592 !jvms: Test::iMeth @ bci:61
       522 Phi === 516 631 608 [[ 441 ]] #java/lang/Byte:exact * Oop:java/lang/Byte:exact *
       440 CountedLoop === 440 465 439 [[ 440 441 443 445 447 452 ]] inner stride: 1 post of N396 !orig=[396],[386],[182] !jvms: Test::iMeth @ bci:31
       26 ConL === 0 [[ 28 228 286 415 423 474 482 545 553 ]] #long:12
       441 Phi === 440 522 442 [[ 442 423 423 ]] #java/lang/Byte:exact * Oop:java/lang/Byte:exact * !orig=189 !jvms: Test::iMeth @ bci:31
       3 Start === 3 0 [[ 3 5 6 7 8 9 10 ]] #{0:control, 1:abIO, 2:memory, 3:rawptr:BotPTR, 4:return_address, 5:Test:NotNull *, 6:int, 7:long, 8:half, 9:int}
       423 AddP === _ 441 441 26 [[ 422 ]] Oop:java/lang/Byte:exact+12 * !orig=286 !jvms: Byte::byteValue @ bci:1 Test::iMeth @ bci:53
       7 Parm === 3 [[ 163 150 137 332 29 118 58 351 74 97 322 312 552 287 547 229 256 409 414 417 422 468 473 476 481 539 544 ]] Memory Memory: @BotPTR *+bot, idx=Bot; !orig=[174],[184] !jvms: Test::iMeth @ bci:-1
       422 LoadB === _ 7 423 [[ 421 ]] @java/lang/Byte:exact+12 *, name=value, idx=9; #byte !orig=287 !jvms: Byte::byteValue @ bci:1 Test::iMeth @ bci:53
          0--> 414 LoadB === _ 7 415 [[ 413 ]] @java/lang/Byte:exact+12 *, name=value, idx=9; #byte !orig=229 !jvms: Byte::byteValue @ bci:1 Test::iMeth @ bci:40
      # To suppress the following error report, specify this argument
      # after -XX: or in .hotspotrc: SuppressErrorAt=/phaseX.cpp:1193
      #
      # A fatal error has been detected by the Java Runtime Environment:
      #
      # Internal Error (/home/my/my-jdk11u/src/hotspot/share/opto/phaseX.cpp:1193), pid=3952425, tid=3952567
      # assert(false) failed: infinite loop in PhaseIterGVN::optimize
      #
      # JRE version: OpenJDK Runtime Environment (11.0.16) (fastdebug build 11.0.16-internal+0-adhoc.my.my-jdk11u)
      # Java VM: OpenJDK 64-Bit Server VM (fastdebug 11.0.16-internal+0-adhoc.my.my-jdk11u, mixed mode, tiered, compressed oops, g1 gc, linux-amd64)
      # No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
      #
      # An error report file with more information is saved as:
      # /tmp/hs_err_pid3952425.log
      #
      # Compiler replay data is saved as:
      # /tmp/replay_pid3952425.log
      #
      # If you would like to submit a bug report, please visit:
      # https://bugreport.java.com/bugreport/crash.jsp
      #
      Current thread is 3952567
      Dumping core ...
      Aborted
      ```

      Note, We CANNOT reproduce it in HotSpot 11.0.15.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. type: javac Test.java
      2. type: java -Xbatch Test

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      HotSpot does NOT crash
      ACTUAL -
      HotSpot DID crash

      ---------- BEGIN SOURCE ----------
      class Test {
        int N;
        long instanceCount;

        int iMeth(int i, long l, short s1) {
          float fArr[] = new float[N];
          Byte ax$1 = 0xFFFFFFFF;
          Byte ax$0 = 1;
          for (int ax$2 = 0; ax$2 < 10000; ax$2++)
            if ((ax$2 & 1) == 0) ax$0 = (byte) ax$0;
            else ax$1 = (byte) ax$1;
          long meth_res = Double.doubleToLongBits(checkSum(fArr));
          return (int) meth_res;
        }

        void mainTest(String[] strArr1) {
          short s = 21753;
          int i21 = 97;
          s = (short) iMeth(i21, instanceCount, s);
        }

        public static void main(String[] strArr) {
          Test _instance = new Test();
          for (; ; ) _instance.mainTest(strArr);
        }

        public static double checkSum(float[] a) {
          double sum = 0;
          for (int j = 0; j < a.length; j++) {
            sum += (a[j] / (j + 1) + a[j] % (j + 1));
          }
          return sum;
        }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

        1. hs_err_pid13616.log
          52 kB
        2. replay_pid13616.log
          95 kB
        3. Test.java
          0.8 kB

          Issue Links

            Activity

              People

              Assignee:
              chagedorn Christian Hagedorn
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated: