JDK-8366490 : Incorrect result with C2 compiled code
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 26
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2025-09-01
  • Updated: 2025-09-02
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 26
26Unresolved
Related Reports
Causes :  
Description
Please change the description once the root cause is known.

TEST: javafuzzer_tests/Test_2267.java
TEST RESULT: Failed. Difference in 'STDOUT' stream. 
Expected: i34 b1 lArr2 = 0,0,-674306231546582954
Actual  : i34 b1 lArr2 = 0,0,-14801518782581705
Comments
Another case: ===== Test_3916.C2_STRESS.out ==== 34c34 < i27 b3 iArr1 = -17,1,-957521283 --- > i27 b3 iArr1 = -17,1,-749775398
02-09-2025

Attached another reduced version `Test.java` from the test of JDK-8366491: $ java -XX:CompileCommand=quiet -XX:CompileCommand=compileonly,*Test*::* -XX:-TieredCompilation -Xbatch -XX:+StressGCM Test.java > c2 $ java -Xint Test.java > int $ diff c2 int 5c5 < i38 i39 iArr1 = 642 --- > i38 i39 iArr1 = -62394
01-09-2025

Thanks [~dholmes] for the report and [~thartmann] for triaging. The original machine has AVX512 features. My machine does too, and it reproduces with two runs like this: ./java -XX:CompileCommand=quiet -XX:CompileCommand=compileonly,*Test*::* -XX:-TieredCompilation -Xcomp -XX:+StressGCM Test_2267.java > log1.txt ./java -XX:CompileCommand=quiet -XX:CompileCommand=compileonly,*Test*::* -XX:-TieredCompilation -Xcomp -XX:+StressGCM Test_2267.java > log2.txt diff log1.txt log2.txt 41c41 < i34 b1 lArr2 = 0,0,-14801518546227665 --- > i34 b1 lArr2 = 0,0,-674306231546582954 89c89 < i34 b1 lArr2 = 0,0,-674306231546582954 --- > i34 b1 lArr2 = 0,0,-14611427833466614 I'll investigate more once we have the reduced reproducer.
01-09-2025

ILW = Incorrect result with C2 compiled code (regression), easy to reproduce with JavaFuzzer generated test and stress options, -XX:-UseAutoVectorizationSpeculativeAliasingChecks = HLM = P3
01-09-2025

I narrowed it down to jdk-26+13-1339 which only contains JDK-8324751. Emanuel, could you please have a look?
01-09-2025

I can reproduce this with '-XX:CompileCommand=quiet -XX:CompileCommand=compileonly,*Test*::* -XX:-TieredCompilation -Xcomp -XX:+StressGCM' and attached Test_2267.java < i34 b1 lArr2 = 0,0,-674306231546582954 --- > i34 b1 lArr2 = 0,0,-14801518782581397 89c89 < i34 b1 lArr2 = 0,0,-674306231546582954 --- > i34 b1 lArr2 = 0,0,-14801518782581397 On my machine, it requires 'sde64 -future --' though.
01-09-2025

I spent some time to reduce it more, and clean it up. Not yet sure what the cause it, investigating. for i in {1..10}; do ./java -XX:CompileCommand=quiet -XX:CompileCommand=compileonly,Reduced1::test -XX:CompileCommand=printcompilation,Reduced1::* -XX:CompileCommand=dontinline,Reduced1::allocateArrays -XX:-TieredCompilation -Xbatch -XX:+StressGCM Reduced1.java || break; done This works on my AVX512 machine, but it also reproduces with -XX:UseAVX=2 4618 98 % b Reduced1::test @ 20 (53 bytes) 4633 99 b Reduced1::test (53 bytes) a[4]: -924 Exception in thread "main" java.lang.RuntimeException: wrong value -896 -924 at Reduced1.main(Reduced1.java:28) But the result is not always the same, it depends a bit on timing. Sometimes the runs don't fail. Here another example output: 4600 98 % b Reduced1::test @ 20 (53 bytes) 4616 99 b Reduced1::test (53 bytes) 4760 100 % b Reduced1::test @ 20 (53 bytes) 4776 101 b Reduced1::test (53 bytes) a[4]: -896 a[4]: -896 a[4]: -896 a[4]: -896 a[4]: -896 a[4]: -896 a[4]: -896 a[4]: -896 a[4]: -896 a[4]: -896 4561 98 % b Reduced1::test @ 20 (53 bytes) 4575 99 b Reduced1::test (53 bytes) a[4]: -924 Exception in thread "main" java.lang.RuntimeException: wrong value -896 -924 at Reduced1.main(Reduced1.java:28)
01-09-2025