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

Do loop with continue with subsequent switch leads to incorrect stack maps

XMLWordPrintable

    • b22
    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      $ cat /etc/os-release
      NAME="Ubuntu"
      VERSION="20.04.6 LTS (Focal Fossa)"
      ID=ubuntu
      ID_LIKE=debian
      PRETTY_NAME="Ubuntu 20.04.6 LTS"
      VERSION_ID="20.04"
      HOME_URL="https://www.ubuntu.com/"
      SUPPORT_URL="https://help.ubuntu.com/"
      BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
      PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
      VERSION_CODENAME=focal
      UBUNTU_CODENAME=focal

      $ uname -a
      Linux dell-PowerEdge-R740 5.15.0-105-generic #115~20.04.1-Ubuntu SMP Mon Apr 15 17:33:04 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

      $ /path/to/jdk22/bin/javac -version
      javac 22

      A DESCRIPTION OF THE PROBLEM :
      We compiled the following testcase using javac and executed it with the JVM, resulting in the following crash error message (We tried using various versions of javac (1.8, 17, 22), but the issue persists.):

      Error: Unable to initialize main class Test
      Caused by: java.lang.VerifyError: Inconsistent stackmap frames at branch target 44
      Exception Details:
        Location:
          Test.main([Ljava/lang/String;)V @44: iload_2
        Reason:
          Type top (current frame, locals[4]) is not assignable to double (stack map, locals[4])
        Current Frame:
          bci: @16
          flags: { }
          locals: { '[Ljava/lang/String;', top, integer, integer }
          stack: { integer }
        Stackmap Frame:
          bci: @44
          flags: { }
          locals: { '[Ljava/lang/String;', top, integer, integer, double, double_2nd }
          stack: { }
        Bytecode:
          0000000: 083d 063e 0436 04a7 0003 1d07 a1ff f805
          0000010: ab00 0000 0000 001e 0000 0002 0000 0003
          0000020: 0000 001c 0000 0004 0000 001c 1c3c b1
        Stackmap Table:
          append_frame(@4,Top,Integer,Integer)
          same_frame(@10)
          append_frame(@44,Double)
          chop_frame(@46,1)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      javac Test.java
      java Test

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Infinite loop
      ACTUAL -
      Crash

      ---------- BEGIN SOURCE ----------
      class Test {
        public static void main(String[] k) {
          int a;
          int b = 5;
          int c = 3;
          do {
            boolean e = true;
            continue;
          } while (c < 4);
          switch (2) {
          case 3:
            double d;
          case 4:
            a = b;
          }
        }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


        1. Main.java
          0.3 kB
        2. Test.java
          0.2 kB

            liach Chen Liang
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: