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

C2: blocks made unreachable by NeverBranch-to-Goto conversion are removed incorrectly

    XMLWordPrintable

Details

    • b14

    Backports

      Description

        HOW TO REPRODUCE:

        The attached reduced Java Fuzzer test from JDK-8292507 (different bug than reported in JDK-8292507) starts to fail after JDK-8292285:

        To reproduce:
        $ java -Xcomp -XX:CompileOnly=Test Test.java

        #
        # A fatal error has been detected by the Java Runtime Environment:
        #
        # Internal Error (src/hotspot/share/opto/block.cpp:1742), pid=36133, tid=36146
        # assert(_cfg.number_of_blocks() >= (uint) (size - 1)) failed: number of blocks can not shrink
        #
        # JRE version: Java(TM) SE Runtime Environment (20.0+11) (fastdebug build 20-ea+11-661)
        # Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 20-ea+11-661, compiled mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
        # Problematic frame:
        # V [libjvm.so+0x770b84] PhaseBlockLayout::PhaseBlockLayout(PhaseCFG&)+0x7d4
        .......
        Command Line: -Xcomp -XX:CompileOnly=Test --add-modules=ALL-DEFAULT jdk.compiler/com.sun.tools.javac.launcher.Main Test.java
        .......
        Current CompileTask:
        C2: 1763 85 b 4 Test::test (47 bytes)

        FAILURE ANALYSIS:

        The failure unveils three major flaws in the current removal of unreachable blocks after NeverBranch-to-goto conversion (introduced in JDK-8292285):

        1. The unreachable block removal and pre-order index update loop [1] skips the block next to the removed one, and iterates beyond the end of the block count ('_number_of_blocks').

        2. The outer block traversal loop [2] iterates beyond the end of the block count whenever one or more unreachable blocks are removed.

        3. Transitively unreachable blocks (such as B10 in transitive.pdf) are not removed. These blocks arise in methods with two or more infinite loops (see multiple-infinite-loops.pdf).

        [1] https://github.com/openjdk/jdk/blob/7b5f9edb59ef763acca80724ca37f3624d720d06/src/hotspot/share/opto/block.cpp#L613-L621
        [2] https://github.com/openjdk/jdk/blob/7b5f9edb59ef763acca80724ca37f3624d720d06/src/hotspot/share/opto/block.cpp#L698-L729

        Attachments

          1. hs_err_pid36133.log
            78 kB
          2. multiple-infinite-loops.pdf
            18 kB
          3. Test.java
            0.4 kB
          4. transitive.pdf
            14 kB

          Issue Links

            Activity

              People

                rcastanedalo Roberto Castaneda Lozano
                chagedorn Christian Hagedorn
                Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: