JDK-8336701 : Wrong Output of Program Using JDK21-Release Version - 2
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 21
  • Priority: P2
  • Status: New
  • Resolution: Unresolved
  • OS: linux_ubuntu
  • CPU: x86_64
  • Submitted: 2024-07-02
  • Updated: 2024-07-18
Related Reports
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
$ 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

java version: jdk-21.0.3

A DESCRIPTION OF THE PROBLEM :
When running the test case using the release version of OpenJDK21, it can be observed that the results are inconsistent before and after applying the -Xint parameter. Similar to the issue we reported recently, testing has shown that this problem occurs with OpenJDK17 release version, OpenJDK17 mainline, and OpenJDK23 mainline. And similarly, it does not occur with OpenJDK11 and OpenJDK8. We suspect that this might be caused by the same issue as JBS-9077247, but we lack the relevant knowledge to determine if it is indeed the same cause.

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

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
-8000
ACTUAL -
-2272

---------- BEGIN SOURCE ----------
class Test {
    int[] b = new int[400];

    void c() {
        long e;
        for (e = 1; e < 9; ++e) {
            b[(int) e] -= e;
            synchronized (new Test()) { }
        }
        for (int f = 0; f < 10000; ++f) ;
    }

    void m() {
        for (int i = 0; i < 1000; ++i)
            c();
        System.out.println(b[8]);
    }

    public static void main(String[] k) {
        Test _instance = new Test();
        _instance.m();
    }
}
---------- END SOURCE ----------

FREQUENCY : always