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

modify a primitive array through a stream and a for cycle causes jre crash

XMLWordPrintable

    • 9
    • b11
    • Verified

        ADDITIONAL SYSTEM INFORMATION :
        Intel i7-8650u 32GB
        Windows 10
        OpenJDK 14.0.2

        A DESCRIPTION OF THE PROBLEM :
        I have a very small code:

          public static void main(String[] args) {
            int n = 4096;
            long[] data = new long[n * n];

            for (int k = 0; k < n; k++) {
              IntStream.range(0, n).forEach(j -> {
                for (int i = 0; i < n; i++)
                  data[j * n + i]++;
              });
            }
          }

        which has the following output:

        #
        # A fatal error has been detected by the Java Runtime Environment:
        #
        # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffd01641aee, pid=27584, tid=15100
        #
        # JRE version: OpenJDK Runtime Environment (14.0.2+12) (build 14.0.2+12-46)
        # Java VM: OpenJDK 64-Bit Server VM (14.0.2+12-46, mixed mode, sharing, tiered, compressed oops, g1 gc, windows-amd64)
        # Problematic frame:
        # V [jvm.dll+0x6b1aee]
        #
        # No core dump will be written. Minidumps are not enabled by default on client versions of Windows
        #
        # An error report file with more information is saved as:
        # C:\Users\elszszo\git\eulerproject\hs_err_pid27584.log
        #
        # Compiler replay data is saved as:
        # C:\Users\elszszo\git\eulerproject\replay_pid27584.log
        #
        # If you would like to submit a bug report, please visit:
        # https://bugreport.java.com/bugreport/crash.jsp
        #

        If I remove either the outer loop (k), or if I use only j*n or i or j as the array index in the increment line instead of the composite j*n + i , it runs without any issue.

        REGRESSION : Last worked in version 8u261

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Just execute the following method included

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Should be executed without jre crash, with no output.
        ACTUAL -
        jre crash:

        #
        # A fatal error has been detected by the Java Runtime Environment:
        #
        # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffd01641aee, pid=27584, tid=15100
        #
        # JRE version: OpenJDK Runtime Environment (14.0.2+12) (build 14.0.2+12-46)
        # Java VM: OpenJDK 64-Bit Server VM (14.0.2+12-46, mixed mode, sharing, tiered, compressed oops, g1 gc, windows-amd64)
        # Problematic frame:
        # V [jvm.dll+0x6b1aee]
        #
        # No core dump will be written. Minidumps are not enabled by default on client versions of Windows
        #
        # An error report file with more information is saved as:
        # C:\Users\elszszo\git\eulerproject\hs_err_pid27584.log
        #
        # Compiler replay data is saved as:
        # C:\Users\elszszo\git\eulerproject\replay_pid27584.log
        #
        # If you would like to submit a bug report, please visit:
        # https://bugreport.java.com/bugreport/crash.jsp
        #


        ---------- BEGIN SOURCE ----------
          @Test
          public void test() {
            int n = 4096;
            long[] data = new long[n * n];

            for (int k = 0; k < n; k++) {
              IntStream.range(0, n).forEach(j -> {
                for (int i = 0; i < n; i++)
                  data[j * n + i]++;
              });
            }
          }

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

        CUSTOMER SUBMITTED WORKAROUND :
        if I replace the Instream with a conservative for-loop, it works.

        FREQUENCY : always


              kvn Vladimir Kozlov
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

                Created:
                Updated:
                Resolved: