C2: assert(no_dead_loop) failed: dead loop detected

XMLWordPrintable

      The attached test fails with:

         0 Root === 0 419 [[ 0 1 3 316 21 235 26 283 30 280 34 277 38 57 64 77 90 107 121 123 127 128 131 253 213 224 465 520 602 637 670 672 674 720 ]]
        57 ConI === 0 [[ 413 237 319 250 414 238 ]] #int:1
       413 LShiftI === _ 413 57 [[ 414 413 319 392 238 396 376 405 ]] !orig=[318],330 !jvms: Test::test @ bci:135 (line 10)

      # To suppress the following error report, specify this argument
      # after -XX: or in .hotspotrc: SuppressErrorAt=/phaseX.cpp:943
      #
      # A fatal error has been detected by the Java Runtime Environment:
      #
      # Internal Error (/opt/mach5/mesos/work_dir/slaves/0c72054a-24ab-4dbb-944f-97f9341a1b96-S8340/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/2b16cd18-b6f0-4a5f-94ea-280dc3e571e9/runs/902cb1a2-457c-492e-ba4b-9ba741d5ac3a/workspace/open/src/hotspot/share/opto/phaseX.cpp:943), pid=20349, tid=20363
      # assert(no_dead_loop) failed: dead loop detected
      #
      # JRE version: Java(TM) SE Runtime Environment (20.0+36) (fastdebug build 20+36-2344)
      # Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 20+36-2344, compiled mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
      # Problematic frame:
      # V [libjvm.so+0x177e778] PhaseGVN::dead_loop_check(Node*) [clone .part.0]+0x158
      ..............
      Current CompileTask:
      C2: 128 5 % b 4 T::test @ 52 (143 bytes)

      Stack: [0x00007fc50df00000,0x00007fc50e000000], sp=0x00007fc50dffb050, free space=1004k
      Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
      V [libjvm.so+0x177e778] PhaseGVN::dead_loop_check(Node*) [clone .part.0]+0x158 (phaseX.cpp:943)
      V [libjvm.so+0x178d0b9] PhaseIterGVN::transform_old(Node*)+0x4e9
      V [libjvm.so+0x17852ee] PhaseIterGVN::optimize()+0x6e
      V [libjvm.so+0xae1e9a] Compile::process_for_post_loop_opts_igvn(PhaseIterGVN&)+0xca
      V [libjvm.so+0xae9f7b] Compile::Optimize()+0x163b
      V [libjvm.so+0xaed8ce] Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x18ce
      V [libjvm.so+0x8ff687] C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x4e7
      V [libjvm.so+0xafa9ec] CompileBroker::invoke_compiler_on_method(CompileTask*)+0xa7c
      V [libjvm.so+0xafb7a8] CompileBroker::compiler_thread_loop()+0x5d8
      V [libjvm.so+0x1069eb6] JavaThread::thread_main_inner()+0x206
      V [libjvm.so+0x1a6ef00] Thread::call_run()+0x100
      V [libjvm.so+0x1702b53] thread_native_entry(Thread*)+0x103


      ---- Original report ----

      ADDITIONAL SYSTEM INFORMATION :
      A deterministic crash occurs in the HotSpot JVM when a complex nested loop structure is promoted to the C2 compiler. The crash is bypassed when running with -Xint, confirming that the issue lies within the JIT compilation process (likely during PhaseIdealLoop or Loop Unrolling).

      A DESCRIPTION OF THE PROBLEM :
      JVM Crash in C2 Compiler (Loop Optimizer) during nested loop optimization with floating-point arithmetic

      REGRESSION : Java version that customer using for 11.0.30, 17.0.18



      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. javac T.java
      2. java -Xcomp T -> Observe the crash (SIGSEGV).
      3. java -Xint T -> Observe normal execution.

      ---------- BEGIN SOURCE ----------
      public class T {
          public static void main(String[] args) {
              float res = test(false, false);
              System.out.println("res: " + res);
          }

          public static float test(boolean flag1, boolean flag2) {
              float ret = 1.0F;
              int x = 0;
              LOOP1 : for (int i = ((short) (1)); i < 1000000; i *= 2) {
                  if ((i % 5) != 0) {
                      LOOP2 : for (int j = 1; j < 1000000; j *= 2) {
                          if ((j % 5) != 0) {
                              if (x == 0) {
                                  if (j > 100) {
                                      LOOP3 : for (float m = 1.0F; m < 30000.0F; m *= 1.0001F) {
                                          ret *= 0.99999F;
                                      }
                                      x = 1;
                                  }
                                  int y = 77;
                                  for (int e = 0; e < 77; e++) {
                                      y -= x;
                                  }
                                  if (y == 0) {
                                      return ret;
                                  }
                                  if (ret > 20000) {
                                      ret = 7.0F;
                                      continue LOOP1;
                                  }
                              }
                          }
                      }
                  }
              }
              return ret;
          }
      }
      ---------- END SOURCE ----------

      FREQUENCY :
      ALWAYS

            Assignee:
            Unassigned
            Reporter:
            Webbug Group
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: