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

C2: arraycopy with same non escaping src and dest but different positions causes wrong execution

    Details

    • Subcomponent:
    • Resolved In Build:
      b16
    • Verification:
      Verified

      Backports

        Description

        The patch below applied to an existing test case causes fails with an incorrect result.

        diff -r d003b3ef8b60 test/hotspot/jtreg/compiler/escapeAnalysis/TestSelfArrayCopy.java
        --- a/test/hotspot/jtreg/compiler/escapeAnalysis/TestSelfArrayCopy.java Mon Sep 16 09:28:54 2019 +0200
        +++ b/test/hotspot/jtreg/compiler/escapeAnalysis/TestSelfArrayCopy.java Mon Sep 16 11:58:55 2019 +0200
        @@ -43,7 +43,7 @@
                 // Non-escaping allocation
                 Integer[] array = {rI1, rI2};
                 // Arraycopy with src == dst
        - System.arraycopy(array, 0, array, 0, array.length - 1);
        + System.arraycopy(array, 0, array, 1, 1);
                 if (b) {
                     // Uncommon trap
                     System.out.println(array[0]);
        @@ -52,7 +52,7 @@
             }
         
             public static void main(String[] args) {
        - int expected = rI1 + rI2;
        + int expected = rI1 + rI1;
                 // Trigger compilation
                 for (int i = 0; i < 20_000; ++i) {
                     int result = test();
        @@ -60,5 +60,10 @@
                         throw new RuntimeException("Incorrect result: " + result + " != " + expected);
                     }
                 }
        + b = true;
        + int result = test();
        + if (result != expected) {
        + throw new RuntimeException("Incorrect result: " + result + " != " + expected);
        + }
             }
         }

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  roland Roland Westrelin
                  Reporter:
                  roland Roland Westrelin
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  5 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: