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

Inconsistent execution results between -Xint and -Xcomp on OpenJDK8

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      macOS version:

      ```
      Software:

          System Software Overview:

            System Version: macOS 13.2 (22D49)
            Kernel Version: Darwin 22.3.0
            Boot Volume: Macintosh HD
            Boot Mode: Normal
            Computer Name: MacBook Pro
            User Name: MacBook
            Secure Virtual Memory: Enabled
            System Integrity Protection: Enabled
            Time since boot: 1 day, 2 hours, 19 minutes

      Hardware:

          Hardware Overview:

            Model Name: MacBook Pro
            Model Identifier: MacBookPro18,1
            Model Number: MK193CH/A
            Chip: Apple M1 Pro
            Total Number of Cores: 10 (8 performance and 2 efficiency)
            Memory: 16 GB
            System Firmware Version: 8419.80.7
            OS Loader Version: 8419.80.7
            Activation Lock Status: Disabled
      ```

      OpenJDK version:
      ```
      openjdk version "1.8.0_392"
      OpenJDK Runtime Environment (Temurin)(build 1.8.0_392-b08)
      OpenJDK 64-Bit Server VM (Temurin)(build 25.392-b08, mixed mode)
      ```

      A DESCRIPTION OF THE PROBLEM :
      We found a test program that produces inconsistent results between the -Xint and -Xcomp execution modes. Furthermore, this issue is specific to OpenJDK8 and does not occur in OpenJDK11.

      The test program can be found at:

      https://drive.google.com/file/d/1RSG5Q6QtDVbIyi9KDnem1_STNS5oG_0z/view?usp=sharing.

      The decompiled code is shown below:

      ```java
      public class InconsistentValue2 {
          public static int CHECKSUM = 0;

          public InconsistentValue2() {
          }

          public static void main(String[] var0) {
              byte var3 = 0;
              InconsistentValue2 var1 = new InconsistentValue2();
              var1.test(var3);
              System.out.println(Integer.toString(CHECKSUM));
          }

          int test(int var1) {
              for(int var6 = 0; var6 < 100; ++var6) {
                  for(int var7 = var6; var7 < 100; ++var7) {
                      byte var8 = 0;
                      long var9 = 0L;

                      while(true) {
                          long var11;
                          int var10000 = (var11 = var9 - 100L) == 0L ? 0 : (var11 < 0L ? -1 : 1);
                          CHECKSUM = Check.checksum(CHECKSUM, var9);
                          if (var10000 >= 0) {
                              var1 += var8;
                              break;
                          }
                          ++var9;
                      }
                  }
              }
              return var1;
          }
      }
      ```

      If we run this program on OpenJDK8 with the following command:

      ```java
      java -cp . -Xint InconsistentValue2
      ```

      The output of the above command is 25502500.

      However, if we run this program on OpenJDK8 with the following command:

      ```java
      java -cp . -Xcomp InconsistentValue2
      ```

      The output of the above command is 25502547.


      REGRESSION : Last worked in version 11


      FREQUENCY : always


            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: