JDK-8327012 : Incorrect result of C2 compiled code
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 15,17,21,22,23
  • Priority: P3
  • Status: In Progress
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2024-02-26
  • Updated: 2024-03-08
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 23
23Unresolved
Related Reports
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
Linux Ubuntu20.04

openjdk version "1.8.0_402"
OpenJDK Runtime Environment (Temurin)(build 1.8.0_402-b06)
OpenJDK 64-Bit Server VM (Temurin)(build 25.402-b06, mixed mode)

openjdk version "11.0.22" 2024-01-16
OpenJDK Runtime Environment Temurin-11.0.22+7 (build 11.0.22+7)
OpenJDK 64-Bit Server VM Temurin-11.0.22+7 (build 11.0.22+7, mixed mode)

openjdk version "17.0.10" 2024-01-16
OpenJDK Runtime Environment Temurin-17.0.10+7 (build 17.0.10+7)
OpenJDK 64-Bit Server VM Temurin-17.0.10+7 (build 17.0.10+7, mixed mode, sharing)

A DESCRIPTION OF THE PROBLEM :

In TestCase2, the arrays var1 and var7 are initialized using the prodReductionInit function, followed by 2000 iterations of the prodReductionImplement function for simple array operations. However, Hotspot encounters errors in the final results. Testing on Hotspot-8, 11, and 17 reveals that Hotspot-8 and 11 only occasionally output exceptions, whereas Hotspot-17 consistently outputs exceptions when the -Xcomp parameter is set.

We have uploaded the relevant test cases to Google Drive for ease of reproduction.
https://drive.google.com/file/d/1zrFxmAQ2FuS0IjO9NolWuScBr0bPNGag/view?usp=sharing

REGRESSION : Last worked in version 17.0.10

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
java-17/bin/java -Xcomp TestCase2

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Success
ACTUAL -
Exception

---------- BEGIN SOURCE ----------
public class TestCase2 {
    public static void main(String[] var0) throws Exception {
        double[] var7 = new double[262144];
        double[] var1 = new double[262144];
        prodReductionInit(var7, var1);
        double var2 = 2000.0;
        double var4 = 0.0;

        for(int var6 = 0; var6 < 2000; ++var6) {
            var4 = prodReductionImplement(var7, var1, (double)(var6 + 1));
        }

        if (var4 == var2) {
            System.out.println("Success");
        } else {
            System.out.println("Exception");
        }

    }

    public static double prodReductionImplement(double[] var0, double[] var1, double var2) {
        for(int var4 = 0; var4 < var0.length; ++var4) {
            var2 *= var0[var4] - var1[var4];
        }

        return var2;
    }

    public static void prodReductionInit(double[] var0, double[] var1) {
        for(int var5 = 0; var5 < var0.length; ++var5) {
            var0[var5] = (double)(var5 + 2);
            var1[var5] = (double)(var5 + 1);
            double var2 = 1.0;
            double[] var4 = new double[100];
        }

    }
}

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

FREQUENCY : always



Comments
../../../linux-x64-debug/jdk/bin/java -Xcomp -XX:-TieredCompilation -XX:CompileCommand=compileonly,TestCase2::* -Xlog:cpu+os TestCase2.java Seems to fail with the original JAVA code on my AVX512 machine, and on JDK23. No SDE needed. emanuel@emanuel-oracle:/oracle-work/jdk-fork8/build/linux-x64-slowdebug/jdk/bin$ ../../../linux-x64-debug/jdk/bin/java -Xcomp -XX:-TieredCompilation -XX:CompileCommand=compileonly,TestCase2::* -Xlog:cpu+os TestCase2.java [0.008s][info][os,cpu] Logical CPUs per core: 2 [0.008s][info][os,cpu] L1 data cache line size: 64 [0.008s][info][os,cpu] UseSSE=4 UseAVX=3 UseAES=1 MaxVectorSize=64 [0.008s][info][os,cpu] Allocation prefetching: PREFETCHW at distance 192, 4 lines of 64 bytes [0.008s][info][os,cpu] PrefetchCopyIntervalInBytes 576 [0.008s][info][os,cpu] PrefetchScanIntervalInBytes 576 [0.008s][info][os,cpu] ContendedPaddingWidth 128 [0.008s][info][os,cpu] CPU: total 16 (initial active 16) (8 cores per cpu, 2 threads per core) family 6 model 141 stepping 1 microcode 0x4e, cx8, cmov, fxsr, ht, mmx, 3dnowpref, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, lzcnt, tsc, tscinvbit, avx, avx2, aes, erms, clmul, bmi1, bmi2, adx, avx512f, avx512dq, avx512cd, avx512bw, avx512vl, sha, fma, vzeroupper, avx512_vpopcntdq, avx512_vpclmulqdq, avx512_vaes, avx512_vnni, clflush, clflushopt, clwb, avx512_vbmi2, avx512_vbmi, rdtscp, rdpid, fsrm, gfni, avx512_bitalg, f16c, pku, ospke, cet_ibt, cet_ss, avx512_ifma [0.025s][info][os,cpu] CPU Model and flags from /proc/cpuinfo: [0.025s][info][os,cpu] model name : 11th Gen Intel(R) Core(TM) i7-11850H @ 2.50GHz [0.025s][info][os,cpu] flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l2 invpcid_single cdp_l2 ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves split_lock_detect dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq rdpid movdiri movdir64b fsrm avx512_vp2intersect [0.025s][info][os,cpu] Online cpus: 0-15 [0.025s][info][os,cpu] Offline cpus: [0.025s][info][os,cpu] cache level: 1 [0.025s][info][os,cpu] cache type: Data [0.025s][info][os,cpu] cache size: 48K [0.025s][info][os,cpu] cache coherency line size: 64 [0.025s][info][os,cpu] cache level: 1 [0.025s][info][os,cpu] cache type: Instruction [0.025s][info][os,cpu] cache size: 32K [0.025s][info][os,cpu] cache coherency line size: 64 [0.025s][info][os,cpu] cache level: 2 [0.025s][info][os,cpu] cache type: Unified [0.025s][info][os,cpu] cache size: 1280K [0.025s][info][os,cpu] cache coherency line size: 64 [0.025s][info][os,cpu] cache level: 3 [0.025s][info][os,cpu] cache type: Unified [0.025s][info][os,cpu] cache size: 24576K [0.025s][info][os,cpu] cache coherency line size: 64 [0.025s][info][os,cpu] BIOS frequency limitation: <Not Available> [0.025s][info][os,cpu] Frequency switch latency (ns): 0 [0.025s][info][os,cpu] Available cpu frequencies: <Not Available> [0.026s][info][os,cpu] Maximum cpu frequency: 4800000 [0.026s][info][os,cpu] Minimum cpu frequency: 800000 [0.026s][info][os,cpu] Current cpu frequency: 1961648 [0.026s][info][os,cpu] Available governors: performance powersave [0.026s][info][os,cpu] Current governor: powersave [0.026s][info][os,cpu] Core performance/turbo boost: <Not Available> CompileCommand: compileonly TestCase2.* bool compileonly = true Exception
07-03-2024

ILW = Incorrect result with C2 compiled code (old issue), reproducible with generated test and -Xcomp, no known workaround but disable compilation of affected method = HLM = P3
29-02-2024

Might be related to JDK-8326992 which also only reproduces after JDK-8237581 in JDK 15.
29-02-2024

I can reproduce this with latest JDK 23 and only with attached class file. It requires a modern CPU, simulating with SDE works: sde -future -- ../jdks/jdk-23/fastdebug/bin/java -Xcomp -XX:-TieredCompilation -XX:CompileCommand=compileonly,TestCase2::* TestCase2 CompileCommand: compileonly TestCase2.* bool compileonly = true Exception -XX:-UseSuperWord does not help, so it's not an issue with the SuperWord optimization. First reproduces since JDK-8237581 in JDK 15.
29-02-2024

Compiled from "TestCase2.java" public class TestCase2 minor version: 0 major version: 61 flags: (0x0021) ACC_PUBLIC, ACC_SUPER this_class: #9 // TestCase2 super_class: #2 // java/lang/Object interfaces: 0, fields: 0, methods: 4, attributes: 1
29-02-2024

No exceptions with Hotspot 17.0.11+5-LTS and -Xcomp parameter is set on Linux JDK1.8.0_411- =============== $java -showversion -Xcomp TestCase2 java version "1.8.0_411" Java(TM) SE Runtime Environment (build 1.8.0_411-b07) Java HotSpot(TM) 64-Bit Server VM (build 25.411-b07, compiled mode) Success $java -showversion -Xcomp TestCase2 java version "1.8.0_411" Java(TM) SE Runtime Environment (build 1.8.0_411-b07) Java HotSpot(TM) 64-Bit Server VM (build 25.411-b07, compiled mode) Success $java -showversion -Xcomp TestCase2 java version "1.8.0_411" Java(TM) SE Runtime Environment (build 1.8.0_411-b07) Java HotSpot(TM) 64-Bit Server VM (build 25.411-b07, compiled mode) Success jdk-11.0.20 =========== $java -showversion TestCase2 java version "11.0.20" 2023-07-18 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.20+9-LTS-256) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.20+9-LTS-256, mixed mode) Success $java -showversion -Xcomp TestCase2 java version "11.0.20" 2023-07-18 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.20+9-LTS-256) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.20+9-LTS-256, compiled mode) Success $java -showversion -Xcomp TestCase2 java version "11.0.20" 2023-07-18 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.20+9-LTS-256) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.20+9-LTS-256, compiled mode) Success $java -showversion -Xcomp TestCase2 java version "11.0.20" 2023-07-18 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.20+9-LTS-256) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.20+9-LTS-256, compiled mode) Success $java -showversion -Xcomp TestCase2 java version "11.0.20" 2023-07-18 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.20+9-LTS-256) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.20+9-LTS-256, compiled mode) Success jdk-17.0.11 ========= $jdk-17.0.11/bin/java -showversion -Xcomp TestCase2 java version "17.0.11-ea" 2024-04-16 LTS Java(TM) SE Runtime Environment (build 17.0.11-ea+2-LTS-178) Java HotSpot(TM) 64-Bit Server VM (build 17.0.11-ea+2-LTS-178, compiled mode, sharing) Success $java -showversion -Xcomp TestCase2 java version "17.0.11-ea" 2024-04-16 LTS Java(TM) SE Runtime Environment (build 17.0.11-ea+2-LTS-178) Java HotSpot(TM) 64-Bit Server VM (build 17.0.11-ea+2-LTS-178, compiled mode, sharing) Success $java -showversion -Xcomp TestCase2 java version "17.0.11-ea" 2024-04-16 LTS Java(TM) SE Runtime Environment (build 17.0.11-ea+2-LTS-178) Java HotSpot(TM) 64-Bit Server VM (build 17.0.11-ea+2-LTS-178, compiled mode, sharing) Success $java -showversion -Xcomp TestCase2 java version "17.0.11-ea" 2024-04-16 LTS Java(TM) SE Runtime Environment (build 17.0.11-ea+2-LTS-178) Java HotSpot(TM) 64-Bit Server VM (build 17.0.11-ea+2-LTS-178, compiled mode, sharing) Success $java -showversion -Xcomp TestCase2 java version "17.0.11-ea" 2024-04-16 LTS Java(TM) SE Runtime Environment (build 17.0.11-ea+2-LTS-178) Java HotSpot(TM) 64-Bit Server VM (build 17.0.11-ea+2-LTS-178, compiled mode, sharing) Success 17.0.11+5-LTS ================= java -showversion -Xcomp TestCase2 java version "17.0.11" 2024-04-16 LTS Java(TM) SE Runtime Environment (build 17.0.11+5-LTS-205) Java HotSpot(TM) 64-Bit Server VM (build 17.0.11+5-LTS-205, compiled mode, sharing) Success $java -showversion -Xcomp TestCase2 java version "17.0.11" 2024-04-16 LTS Java(TM) SE Runtime Environment (build 17.0.11+5-LTS-205) Java HotSpot(TM) 64-Bit Server VM (build 17.0.11+5-LTS-205, compiled mode, sharing) Success $/java -showversion -Xcomp TestCase2 java version "17.0.11" 2024-04-16 LTS Java(TM) SE Runtime Environment (build 17.0.11+5-LTS-205) Java HotSpot(TM) 64-Bit Server VM (build 17.0.11+5-LTS-205, compiled mode, sharing) Success $java -showversion -Xcomp TestCase2 java version "17.0.11" 2024-04-16 LTS Java(TM) SE Runtime Environment (build 17.0.11+5-LTS-205) Java HotSpot(TM) 64-Bit Server VM (build 17.0.11+5-LTS-205, compiled mode, sharing) Success $java -showversion -Xcomp TestCase2 java version "17.0.11" 2024-04-16 LTS Java(TM) SE Runtime Environment (build 17.0.11+5-LTS-205) Java HotSpot(TM) 64-Bit Server VM (build 17.0.11+5-LTS-205, compiled mode, sharing) Success $
28-02-2024