JDK-8299661 : double accumulation error
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 8
  • Priority: P4
  • Status: New
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2023-01-04
  • Updated: 2023-01-05
Description
A DESCRIPTION OF THE PROBLEM :
19 sets of double type values add jvm cash


---------- BEGIN SOURCE ----------
import java.math.BigDecimal;
import java.util.Random;

public class TestDoubleError {

    public static void main(String[] args) {
        TestDoubleError a = new TestDoubleError();
        for (int i = 0; i < 100000; i++) {
            String executer = a.executer("test-" + i);
            System.out.println(executer);
        }
        System.out.println("run-end");
    }

    public String executer(String uuid) {
        System.out.println("run" + uuid);

        double totalScore = 0;
        String realDetailStr = "";

        try {
            Random rd = new Random();
            totalScore = totalScore + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0;

//            System.out.println(totalScore);
            BigDecimal bigDecimal = new BigDecimal(totalScore).setScale(2, BigDecimal.ROUND_HALF_UP);
            totalScore = bigDecimal.doubleValue();

        } catch (Exception e) {
        }
        return totalScore + "," + realDetailStr;
    }

}
---------- END SOURCE ----------


Comments
Issue is reproduced. Crash is observed in the jvm: # Problematic frame: # V [jvm.dll+0x401586] OS: Windows 10 JDK 8u351: Fail ILW = Crash in GA build, reproducible with single test case ,no known workaround yet = MLM = P4 Moving it to dev team for further analysis.
05-01-2023