Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8327963 [Umbrella] Incorrect result of C2 compiled code since JDK-8237581
  3. JDK-8329535

Wrong output of program running with jdk17u and oracle-jdk17-release

XMLWordPrintable

    • x86_64
    • linux_ubuntu

      ADDITIONAL SYSTEM INFORMATION :
      ```bash
      $ cat /etc/os-release
      VERSION="22.04.4 LTS (Jammy Jellyfish)"

      $ oracle-jdk-17.0.10/bin/java -version
      java version "17.0.10" 2024-01-16 LTS
      Java(TM) SE Runtime Environment (build 17.0.10+11-LTS-240)
      Java HotSpot(TM) 64-Bit Server VM (build 17.0.10+11-LTS-240, mixed mode, sharing)
      ```

      A DESCRIPTION OF THE PROBLEM :
      When I use JDK 17u (compiled from the source code obtained from the GitHub JDK17u repository) and Oracle JDK 17 release (downloaded from the Oracle official website) to run the program below, I get incorrect results (which are inconsistent with the results obtained using JDK 21 release).

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      java Test

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      30804
      30804
      30804
      30804
      30804
      30804
      30804
      30804
      30804
      30804

      ACTUAL -
      30804
      30804
      27738
      27738
      27738
      27738
      27738
      27738
      27738
      27738


      ---------- BEGIN SOURCE ----------
      class Test {
        int a = 400;
        long[] b = new long[a];
        float c(int p, int d, int e) {
          int f;
          int g;
          byte by = 3;
          for (f = 2; f < 49; f++) {
            int h = 0;
            while (h < 20000)
              h++;
            for (g = 1; g < 11; g++) {
              b[g] = d;
              b[f] = by;
              synchronized (new Test()) {}
            }
          }
          long k = p;
          return k;
        }
        void l(String[] m) {
          int i = 3069;
          c(i, i, i);
          long n = 0;
          for (int j = 0; j < b.length; j++)
            n += b[j];
          System.out.println(n);
        }
        public static void main(String[] o) {
          Test q = new Test();
          for (int i = 0; i < 10; i++)
            q.l(o);
        }
      }
      ---------- END SOURCE ----------

            chagedorn Christian Hagedorn
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: