JDK-8341009 : Inconsistent Output Results Under Default JIT Configuration
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 16,17,21,23,24
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: linux_ubuntu
  • CPU: x86_64
  • Submitted: 2024-09-23
  • Updated: 2024-09-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 24
24Unresolved
Related Reports
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
$ ./release-jdk/jdk-17.0.12/bin/java -version
java version "17.0.12" 2024-07-16 LTS
Java(TM) SE Runtime Environment (build 17.0.12+8-LTS-286)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.12+8-LTS-286, mixed mode, sharing)

$ ./release-jdk/jdk-21.0.4/bin/java -version
java version "21.0.4" 2024-07-16 LTS
Java(TM) SE Runtime Environment (build 21.0.4+8-LTS-274)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.4+8-LTS-274, mixed mode, sharing)

$ ./release-jdk/jdk-23/bin/java -version
java version "23" 2024-09-17
Java(TM) SE Runtime Environment (build 23+37-2369)
Java HotSpot(TM) 64-Bit Server VM (build 23+37-2369, mixed mode, sharing)

$ ./github-jdk/compile-from-source/bin/java -version
openjdk version "24-internal" 2025-03-18
OpenJDK Runtime Environment (fastdebug build 24-internal-adhoc.user.jdk)
OpenJDK 64-Bit Server VM (fastdebug build 24-internal-adhoc.user.jdk, mixed mode)

$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.2 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
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"
UBUNTU_CODENAME=jammy

A DESCRIPTION OF THE PROBLEM :
We observed an inconsistency when running the following testcase. The results were inconsistent when we used Oracle's JDK versions 17, 21, and 23, as well as a JDK compiled from the source code obtained from the GitHub JDK repository. The output differed from the results when JIT was completely disabled using the -Xint option. Moreover, under the default JIT configuration, the results varied across repeated executions. We believe this is a problem that is easy to trigger and has a wide impact.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
javac -source 8 -target 8 -cp . Test.java
java Test

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
43560

ACTUAL -
27522


---------- BEGIN SOURCE ----------
class Test {
  int a = 256;
  float[] b = new float[a];
  long c;

  void m() {
    for (int f = 0; f < 10000; ++f) ;
    float[][] g = new float[a][a];
    for (int d = 7; d < 16; d++) {
      long e = 1;
      do {
        g[d][(int) e] = d;
        synchronized (new Test()) {
        }
      } while (++e < 5);
    }
    for (int i = 0; i < a; ++i) {
      for (int j = 0; j < a ; ++j) {
        c += g[i][j];
      }
    }
  }

  void h() {
    for (int j = 6; 116 > j; ++j)
      m();
    System.out.println(c);
  }

  public static void main(String[] k) {
    Test test = new Test();
    test.h();
  }
}

---------- END SOURCE ----------

FREQUENCY : always



Comments
Initial ILW = Same as JDK-8327963 = P3
27-09-2024

I suspect that this is another instance of JDK-8327963, the "synchronized (new Test())" is quite unique. Since it's a version with a long loop, it just only reproduces after JDK-8256655.
26-09-2024