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

Incorrect return processing for the LF editor of MethodHandles.permuteArguments

    Details

      Backports

        Description

        The following code crashes the VM:

        import java.lang.invoke.*;
        import static java.lang.invoke.MethodType.*;
        import static java.lang.invoke.MethodHandles.*;

        class Crash {
         public static void main(String[] args) throws Throwable {
           MethodHandle crash = permuteArguments(foldArguments(
             dropArguments(identity(int[].class), 1, int.class, int.class),
             arrayElementSetter(int[].class)
           ), methodType(int[].class, int.class, int[].class, int.class), 1, 2, 0);
           int[] arr = new int[1];
           arr = (int[])crash.invokeExact(1, arr, 0);
           System.out.println(arr);
         }
        }

        Also reproducible with -Xint.

        See also email thread:

          http://mail.openjdk.java.net/pipermail/jdk9-dev/2017-July/005915.html

          Activity

          Hide
          psandoz Paul Sandoz added a comment -
          permuteArguments is incorrectly calculating the result position when the result is from the reordered argument list and is not adjusting for the leading argument that is not part of the argument list (a classic one-off error).
          Show
          psandoz Paul Sandoz added a comment - permuteArguments is incorrectly calculating the result position when the result is from the reordered argument list and is not adjusting for the leading argument that is not part of the argument list (a classic one-off error).
          Hide
          psandoz Paul Sandoz added a comment -
          Fix Request.

          http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8184119-permute-args-return-an-arg/webrev/

          This bug can crash the VM. The fix corrects a one off error in the lambda form editor when calculating the argument to derive the return value. The fix is small (one line). The test has been verified to fail without the fix. The risk is estimated to be low. All existing MethodHandle tests pass locally (JPRT run has been kicked off).



          Show
          psandoz Paul Sandoz added a comment - Fix Request. http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8184119-permute-args-return-an-arg/webrev/ This bug can crash the VM. The fix corrects a one off error in the lambda form editor when calculating the argument to derive the return value. The fix is small (one line). The test has been verified to fail without the fix. The risk is estimated to be low. All existing MethodHandle tests pass locally (JPRT run has been kicked off).
          Hide
          jrose John Rose added a comment - - edited
          Fix request approved. Crasher is a P1 bug.
          Show
          jrose John Rose added a comment - - edited Fix request approved. Crasher is a P1 bug.
          Hide
          hgupdate HG Updates added a comment -
          URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/9003926e4a8a
          User: psandoz
          Date: 2017-07-11 21:32:10 +0000
          Show
          hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/9003926e4a8a User: psandoz Date: 2017-07-11 21:32:10 +0000
          Hide
          hgupdate HG Updates added a comment -
          URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/9003926e4a8a
          User: lana
          Date: 2017-07-20 03:20:49 +0000
          Show
          hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/9003926e4a8a User: lana Date: 2017-07-20 03:20:49 +0000

            People

            • Assignee:
              psandoz Paul Sandoz
              Reporter:
              psandoz Paul Sandoz
            • Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: