C2 crashes in PhiNode::Ideal(PhaseGVN*, bool) accessing NULL pointer

XMLWordPrintable

      C2 compiler crashes on OpenJDK upstream and jdk25 because of accessing NULL pointer in "PhiNode::Ideal(PhaseGVN*, bool)", with the following error:

      ```
      #
      # A fatal error has been detected by the Java Runtime Environment:
      #
      # SIGSEGV (0xb) at pc=0x00007113448e5f34, pid=1893359, tid=1893589
      #
      # JRE version: OpenJDK Runtime Environment (27.0) (build 27-internal-adhoc.user.openjdk)
      # Java VM: OpenJDK 64-Bit Server VM (27-internal-adhoc.user.openjdk, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, parallel gc, linux-amd64)
      # Problematic frame:
      # V [libjvm.so+0x6e5f34] PhiNode::Ideal(PhaseGVN*, bool)+0x34
      #
      # Core dump will be written. Default location: /home/user/openjdk/repro/core.1893359
      #
      # An error report file with more information is saved as:
      # /home/user/openjdk/repro/hs_err_pid1893359.log
      #
      # Compiler replay data is saved as:
      # /home/user/openjdk/repro/replay_pid1893359.log
      #
      # If you would like to submit a bug report, please visit:
      # https://bugreport.java.com/bugreport/crash.jsp
      #
      Aborted (core dumped)
      ```

      Please find the reproducer attached. The reproducer downloads scala packages, compiles "Repro.scala" file, creates "repro.jar", and then run it. "Repro.scala" must be located at the same directory as "run.sh". The reproducer can be run with the following command:

      ```
      JAVA_HOME=<path-to-jdk> bash run.sh
      ```

      GDB backtrace is in the attached "bt.txt" file.

      The crash occurs because "Node *r = in(0)" is null in PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) method. I cannot reproduce it with "fastdebug", it reproduces only with "release" configuration.

      I've found that the problem appears after "JDK-8351833 Unexpected increase in live nodes when splitting Phis through MergeMems in PhiNode::Ideal".

        1. bt.txt
          4 kB
        2. hs_err_pid1893359.log
          79 kB
        3. replay_pid1893359.log
          446 kB
        4. repro.jar
          12 kB
        5. Repro.scala
          2 kB
        6. run.sh
          2 kB

            Assignee:
            Unassigned
            Reporter:
            Roman Marchenko
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: