Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8072753

Nondeterministic wrong answer on arithmetic

    Details

    • Subcomponent:
    • Introduced In Build:
      b102
    • Introduced In Version:
      8
    • Resolved In Build:
      b53
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        FULL PRODUCT VERSION :
        java version "1.8.0_31"
        Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
        Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)


        FULL OS VERSION :
        Linux laptopi 3.13.0-45-generic #74-Ubuntu SMP Tue Jan 13 19:36:28 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
        Linux thinkpad 3.18.5-1-ARCH #1 SMP PREEMPT Fri Jan 30 07:31:50 CET 2015 x86_64 GNU/Linux


        A DESCRIPTION OF THE PROBLEM :
        A code containing only simple arithmetic (generated using deterministic pseudorandom) randomly gives different results, even though it should be deterministic.


        THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: No

        THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Yes

        REGRESSION. Last worked in version 7u75

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        1. Save the code as code.java
        2. Compile the code
            $ javac code.java
        3. Run the code repeatedly, observing the changes in output, for example
            $ for i in {1..100}; do java code | sha256sum; done


        EXPECTED VERSUS ACTUAL BEHAVIOR :
        All the invocations of "java code" should output the same output with sha256 hash 629dbc538b4aa4fd16ecaefbf9cfcba1fe5910aec75740a84583dda03f044838.

        However, actual result contains many different outputs, like
        629dbc538b4aa4fd16ecaefbf9cfcba1fe5910aec75740a84583dda03f044838 -
        0f2175f5f25089d63426ccf42b4e082cb51ad760c5a8534c764f8792c0ca46f4 -
        c4a0bf7126460fd6ee02999121ec9a2d90c05b9bf27070d78de9a7605b4694e6 -
        dc66d58743810f6a000d1ab4694b98eac85dcb4dffd99dfd43a6260b508ab007 -
        629dbc538b4aa4fd16ecaefbf9cfcba1fe5910aec75740a84583dda03f044838 -
        629dbc538b4aa4fd16ecaefbf9cfcba1fe5910aec75740a84583dda03f044838 -
        629dbc538b4aa4fd16ecaefbf9cfcba1fe5910aec75740a84583dda03f044838 -
        a857ae2566df12c396990cb36828d646eb34c5e548e3c7f2af91e23782c5805e -
        629dbc538b4aa4fd16ecaefbf9cfcba1fe5910aec75740a84583dda03f044838 -
        d3bb7a3e570e4a8d0a7ae1fd3e6fccad4fbe8495b56ff08fdfbde70e00f19622 -
        a82888399f7f4544e4ec230cf1b3e7b53ecc6571422b5e17b5b685ff9e655c79 -
        629dbc538b4aa4fd16ecaefbf9cfcba1fe5910aec75740a84583dda03f044838 -
        629dbc538b4aa4fd16ecaefbf9cfcba1fe5910aec75740a84583dda03f044838 -
        629dbc538b4aa4fd16ecaefbf9cfcba1fe5910aec75740a84583dda03f044838 -
        629dbc538b4aa4fd16ecaefbf9cfcba1fe5910aec75740a84583dda03f044838 -
        a857ae2566df12c396990cb36828d646eb34c5e548e3c7f2af91e23782c5805e -
        629dbc538b4aa4fd16ecaefbf9cfcba1fe5910aec75740a84583dda03f044838 -
        629dbc538b4aa4fd16ecaefbf9cfcba1fe5910aec75740a84583dda03f044838 -
        629dbc538b4aa4fd16ecaefbf9cfcba1fe5910aec75740a84583dda03f044838 -
        629dbc538b4aa4fd16ecaefbf9cfcba1fe5910aec75740a84583dda03f044838 -
        629dbc538b4aa4fd16ecaefbf9cfcba1fe5910aec75740a84583dda03f044838 -
        629dbc538b4aa4fd16ecaefbf9cfcba1fe5910aec75740a84583dda03f044838 -
        c322caa467fcdd0e70519760c123b8fcf167e6cfdf98f648316f4e729643d77b -
        629dbc538b4aa4fd16ecaefbf9cfcba1fe5910aec75740a84583dda03f044838 -
        a857ae2566df12c396990cb36828d646eb34c5e548e3c7f2af91e23782c5805e -
        629dbc538b4aa4fd16ecaefbf9cfcba1fe5910aec75740a84583dda03f044838 -
        629dbc538b4aa4fd16ecaefbf9cfcba1fe5910aec75740a84583dda03f044838 -
        629dbc538b4aa4fd16ecaefbf9cfcba1fe5910aec75740a84583dda03f044838 -
        629dbc538b4aa4fd16ecaefbf9cfcba1fe5910aec75740a84583dda03f044838 -
        9c6eb5a688d7c78b9260baac02adf4720f0590b442c7d4ce5be64c755d66b5b7 -
        629dbc538b4aa4fd16ecaefbf9cfcba1fe5910aec75740a84583dda03f044838 -
        d113cb8865e399499ae18a19bfd494b461a403fa7a5ff2fb30ad59c0ee575f91 -
        629dbc538b4aa4fd16ecaefbf9cfcba1fe5910aec75740a84583dda03f044838 -
        629dbc538b4aa4fd16ecaefbf9cfcba1fe5910aec75740a84583dda03f044838 -
        0f2175f5f25089d63426ccf42b4e082cb51ad760c5a8534c764f8792c0ca46f4 -
        629dbc538b4aa4fd16ecaefbf9cfcba1fe5910aec75740a84583dda03f044838 -
        629dbc538b4aa4fd16ecaefbf9cfcba1fe5910aec75740a84583dda03f044838 -
        629dbc538b4aa4fd16ecaefbf9cfcba1fe5910aec75740a84583dda03f044838 -
        ...
        REPRODUCIBILITY :
        This bug can be reproduced often.

        ---------- BEGIN SOURCE ----------
        import java.util.*;
        import java.io.*;
        class code {
            public static void main(String[] args) {
                Random r = new Random(42);
                int x = 0;
                StringBuilder sb = new StringBuilder();
                for(int i = 0; i < 1000000; ++i) {
                    int v = Math.abs(r.nextInt());
                    sb.append('+').append(v).append('\n');

                    x += v;
                    while(x < 0) x += 1000000000;
                    sb.append('=').append(x).append('\n');
                }
                System.out.println(sb.toString());
            }
        }

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

        CUSTOMER SUBMITTED WORKAROUND :
        Use -Xint.

          Issue Links

            Activity

            Hide
            iignatyev Igor Ignatyev added a comment -
            sqe is ok to deferr it to 8u60.
            Show
            iignatyev Igor Ignatyev added a comment - sqe is ok to deferr it to 8u60.
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/hs-comp/hotspot/rev/f1b92b73e6aa
            User: iveresov
            Date: 2015-02-17 23:41:52 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/hs-comp/hotspot/rev/f1b92b73e6aa User: iveresov Date: 2015-02-17 23:41:52 +0000
            Hide
            mcastegr Mattis Castegren (Inactive) added a comment -
            Removing the regression label as this has happened since 6 at least
            Show
            mcastegr Mattis Castegren (Inactive) added a comment - Removing the regression label as this has happened since 6 at least
            Hide
            iveresov Igor Veresov added a comment -
            [~mcastegr], could you guys please backport this to 6 and 7?
            Show
            iveresov Igor Veresov added a comment - [~mcastegr], could you guys please backport this to 6 and 7?
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/jdk9/hotspot/rev/f1b92b73e6aa
            User: lana
            Date: 2015-03-04 22:02:39 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/hotspot/rev/f1b92b73e6aa User: lana Date: 2015-03-04 22:02:39 +0000

              People

              • Assignee:
                iveresov Igor Veresov
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                14 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: