Groovy
  1. Groovy
  2. GROOVY-704

Primitive function arguments cause VerifyError

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0-beta-9
    • Fix Version/s: 1.0-beta-10
    • Component/s: None
    • Labels:
      None
    • Environment:
      Windows XP, Java 1.4.2_06

      Description

      The following code:

      def foo(double x, y) {
      println "x: "+x
      println "y: "+y
      }

      foo(10.0d, 0)

      causes Groovy to complain that the value passed to y is the wrong type. Making foo a member function of a class (in another file), and giving it three arguments, the function runs but y is null and the value that should go to y, goes to the third arg. At one point I had it triggering an internal error in the JVM.

      Changing double to Double fixes the problem.

      1. AsmClassGenerator2.diff
        0.8 kB
        Martin C. Martin

        Issue Links

          Activity

          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open Closed Closed
          10d 19h 23m 1 james strachan 25/Jan/05 07:53
          Closed Closed Reopened Reopened
          11h 57m 2 Martin C. Martin 25/Jan/05 19:53
          Reopened Reopened Closed Closed
          10d 15h 48m 2 Martin C. Martin 05/Feb/05 11:39
          Mark Thomas made changes -
          Workflow jira [ 12968420 ] Default workflow, editable Closed status [ 12976161 ]
          Mark Thomas made changes -
          Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
          Mark Thomas made changes -
          Workflow jira [ 12729859 ] Default workflow, editable Closed status [ 12741902 ]
          Mark Thomas made changes -
          Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
          Martin C. Martin made changes -
          Status Reopened [ 4 ] Closed [ 6 ]
          Resolution Fixed [ 1 ]
          Jochen Theodorou made changes -
          Link This issue is duplicated by GROOVY-669 [ GROOVY-669 ]
          Jochen Theodorou made changes -
          Link This issue is duplicated by GROOVY-564 [ GROOVY-564 ]
          Martin C. Martin made changes -
          Attachment AsmClassGenerator2.diff [ 13877 ]
          Hide
          Martin C. Martin added a comment -

          Changes the fix; doesn't use dummy variables, instead getNextVariableID() takes size of each var into account.

          Show
          Martin C. Martin added a comment - Changes the fix; doesn't use dummy variables, instead getNextVariableID() takes size of each var into account.
          Martin C. Martin made changes -
          Resolution Fixed [ 1 ]
          Status Closed [ 6 ] Reopened [ 4 ]
          Hide
          Martin C. Martin added a comment -

          Adding patch for a slightly cleaner solution

          Show
          Martin C. Martin added a comment - Adding patch for a slightly cleaner solution
          james strachan made changes -
          Status Reopened [ 4 ] Closed [ 6 ]
          Resolution Fixed [ 1 ]
          Hide
          james strachan added a comment -

          Just to update my previous comment - it was Pilho Kim who provided me with the bug fix on IRC - many thanks Pilho!

          Show
          james strachan added a comment - Just to update my previous comment - it was Pilho Kim who provided me with the bug fix on IRC - many thanks Pilho!
          james strachan made changes -
          Status Closed [ 6 ] Reopened [ 4 ]
          Resolution Fixed [ 1 ]
          Hide
          james strachan added a comment -

          fixing resolve comment

          Show
          james strachan added a comment - fixing resolve comment
          james strachan made changes -
          Field Original Value New Value
          Fix Version/s 1.0-beta-10 [ 11467 ]
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Closed [ 6 ]
          Hide
          james strachan added a comment -

          I think this is resolved now - I've added a test case groovy.bugs.DoubleSizeParametersBug to try reproduce it and I think its fixed now?

          Show
          james strachan added a comment - I think this is resolved now - I've added a test case groovy.bugs.DoubleSizeParametersBug to try reproduce it and I think its fixed now?
          Hide
          Martin C. Martin added a comment -

          After a little more searching, I discovered this:

          http://java.sun.com/docs/books/vmspec/2nd-edition/html/Overview.doc.html#15722

          "A single local variable can hold a value of type boolean, byte, char, short, int, float, reference, or returnAddress. A pair of local variables can hold a value of type long or double."

          So when an argument is a long or a double, we need to increase the index of all subsequent arguments.

          Show
          Martin C. Martin added a comment - After a little more searching, I discovered this: http://java.sun.com/docs/books/vmspec/2nd-edition/html/Overview.doc.html#15722 "A single local variable can hold a value of type boolean, byte, char, short, int, float, reference, or returnAddress. A pair of local variables can hold a value of type long or double." So when an argument is a long or a double, we need to increase the index of all subsequent arguments.
          Hide
          Martin C. Martin added a comment -

          I spent a while on it this evening, and couldn't find the problem. But I did discover that you don't need the function call or the first println, although you do need to access y. So the shortest code that produces this bug is:

          def foo(double x, y)

          { y }

          Everything looks fine, and the methodType in AsmClassGenerator2.visitMethod() is right:

          (DLjava/lang/Object;)Ljava/lang/Object;

          Maybe it's a bug in the objectweb ClassWriter?

          Show
          Martin C. Martin added a comment - I spent a while on it this evening, and couldn't find the problem. But I did discover that you don't need the function call or the first println, although you do need to access y. So the shortest code that produces this bug is: def foo(double x, y) { y } Everything looks fine, and the methodType in AsmClassGenerator2.visitMethod() is right: (DLjava/lang/Object;)Ljava/lang/Object; Maybe it's a bug in the objectweb ClassWriter?
          Martin C. Martin created issue -

            People

            • Assignee:
              Unassigned
              Reporter:
              Martin C. Martin
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development