Derby
  1. Derby
  2. DERBY-4459

Verification error at execute-time when an outer function which takes a primitive arg is wrapped around an inner function which returns the corresponding Java wrapper object

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 10.4.2.1, 10.5.3.1, 10.6.1.0
    • Fix Version/s: 10.5.3.2, 10.6.2.4, 10.7.1.1
    • Component/s: SQL
    • Labels:
      None

      Description

      An insane Derby raises a verification error when trying to run the following query:

      values( negateInt( getNullInt() ) );

      where negateInt() takes a primitive int argument and getNullInt() returns an Integer.

      Sane Derby raises an assertion. The same test case, run against 10.3.3.1, also fails but raises a more graceful compile-time exception.

      1. derby-4459-01-aa-disableOptimization.diff
        3 kB
        Rick Hillegas
      2. derby-4459.sql
        0.4 kB
        Rick Hillegas
      3. derby4459.java
        0.1 kB
        Rick Hillegas

        Issue Links

          Activity

          Hide
          Rick Hillegas added a comment -

          Attaching a reproducible test case: derby4459.java and derby-4459.sql. If you compile the class and run the script through ij, you will see this output:

          ij version 10.6
          ij> connect 'jdbc:derby:memory:db;create=true';
          ij> create function getNullInt() returns int language java parameter style java external name 'derby4459.getNullInt';
          0 rows inserted/updated/deleted
          ij> create function negateInt( a int ) returns int language java parameter style java external name 'derby4459.negateInt';
          0 rows inserted/updated/deleted
          ij> – this fails gracefully
          values( negateInt( cast( null as int) ) );
          1
          -----------
          ERROR 39004: A NULL value cannot be passed to a method which takes a parameter of primitive type 'int'.
          ij> – this fails gracelessly
          values( negateInt( getNullInt() ) );
          ERROR XBCM2: Cannot create an instance of generated class org.apache.derby.exe.ac0b5b0099x0125x4b6bxa3fdx000000135f981.
          ERROR XJ001: Java exception: '(class: org/apache/derby/exe/ac0b5b0099x0125x4b6bxa3fdx000000135f981, method: e0 signature: ()Ljava/lang/Object Expecting to find integer on stack: java.lang.VerifyError'.

          Show
          Rick Hillegas added a comment - Attaching a reproducible test case: derby4459.java and derby-4459.sql. If you compile the class and run the script through ij, you will see this output: ij version 10.6 ij> connect 'jdbc:derby:memory:db;create=true'; ij> create function getNullInt() returns int language java parameter style java external name 'derby4459.getNullInt'; 0 rows inserted/updated/deleted ij> create function negateInt( a int ) returns int language java parameter style java external name 'derby4459.negateInt'; 0 rows inserted/updated/deleted ij> – this fails gracefully values( negateInt( cast( null as int) ) ); 1 ----------- ERROR 39004: A NULL value cannot be passed to a method which takes a parameter of primitive type 'int'. ij> – this fails gracelessly values( negateInt( getNullInt() ) ); ERROR XBCM2: Cannot create an instance of generated class org.apache.derby.exe.ac0b5b0099x0125x4b6bxa3fdx000000135f981. ERROR XJ001: Java exception: '(class: org/apache/derby/exe/ac0b5b0099x0125x4b6bxa3fdx000000135f981, method: e0 signature: ()Ljava/lang/Object Expecting to find integer on stack: java.lang.VerifyError'.
          Hide
          Rick Hillegas added a comment -

          Linking this issue to DERBY-1030 because this bug may be another symptom of the over-eager optimization which causes that bug.

          Show
          Rick Hillegas added a comment - Linking this issue to DERBY-1030 because this bug may be another symptom of the over-eager optimization which causes that bug.
          Hide
          Rick Hillegas added a comment -

          Linking to DERBY-479 because this bug may be another symptom of the over-eager optimization which causes that bug.

          Show
          Rick Hillegas added a comment - Linking to DERBY-479 because this bug may be another symptom of the over-eager optimization which causes that bug.
          Hide
          Rick Hillegas added a comment -

          Attaching derby-4459-01-aa-disableOptimization.diff. This disables the same over-eager optimization which led to DERBY-1030.

          For more context, please see DERBY-1030. This is another case of that optimization being applied too liberally. This patch disables that optimization when the bind() phase has determined that an argument needs to be cast to a primitive in order to match the selected method. Running tests now.

          Touches the following files:

          -------------

          M java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java

          Disables the optimization.

          -------------

          M java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java

          Adds a test case.

          Show
          Rick Hillegas added a comment - Attaching derby-4459-01-aa-disableOptimization.diff. This disables the same over-eager optimization which led to DERBY-1030 . For more context, please see DERBY-1030 . This is another case of that optimization being applied too liberally. This patch disables that optimization when the bind() phase has determined that an argument needs to be cast to a primitive in order to match the selected method. Running tests now. Touches the following files: ------------- M java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java Disables the optimization. ------------- M java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java Adds a test case.
          Hide
          Rick Hillegas added a comment -

          Tests ran cleanly for me except for the following errors which seem to have been introduced into the mainline recently:

          1) testAttributeAccumulatedConnectionCount(org.apache.derbyTesting.functionTests.tests.management.NetworkServerMBeanTest)java.security.PrivilegedActionException: javax.management.InstanceNotFoundException: org.apache.derby:type=NetworkServer,system=c013800d-0129-cd0d-100f-ffffe1d7aa3e
          at java.security.AccessController.doPrivileged(Native Method)
          at org.apache.derbyTesting.functionTests.tests.management.MBeanTest.getAttribute(MBeanTest.java:379)
          at org.apache.derbyTesting.functionTests.tests.management.NetworkServerMBeanTest.testAttributeAccumulatedConnectionCount(NetworkServerMBeanTest.java:93)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:109)
          at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
          at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
          at junit.extensions.TestSetup.run(TestSetup.java:25)
          at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
          at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
          at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
          at junit.extensions.TestSetup.run(TestSetup.java:25)
          at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
          at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
          at junit.extensions.TestSetup.run(TestSetup.java:25)
          at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
          Caused by: javax.management.InstanceNotFoundException: org.apache.derby:type=NetworkServer,system=c013800d-0129-cd0d-100f-ffffe1d7aa3e
          at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1010)
          at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getAttribute(DefaultMBeanServerInterceptor.java:627)
          at com.sun.jmx.mbeanserver.JmxMBeanServer.getAttribute(JmxMBeanServer.java:659)
          at org.apache.derbyTesting.functionTests.tests.management.MBeanTest$4.run(MBeanTest.java:382)
          ... 41 more
          There was 1 failure:
          1) ttestSetPortPriority(org.apache.derbyTesting.functionTests.tests.derbynet.ServerPropertiesTest)junit.framework.AssertionFailedError: Port 1537 exceeeds expected maximum. You may need to update TestConfiguration.MAX_PORTS_USED and the Wiki page at http://wiki.apache.org/db-derby/DerbyJUnitTesting if test runs now require more available ports
          at org.apache.derbyTesting.junit.TestConfiguration.getNextAvailablePort(TestConfiguration.java:1413)
          at org.apache.derbyTesting.functionTests.tests.derbynet.ServerPropertiesTest.ttestSetPortPriority(ServerPropertiesTest.java:445)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:109)
          at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
          at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
          at junit.extensions.TestSetup.run(TestSetup.java:25)
          at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
          at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
          at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
          at junit.extensions.TestSetup.run(TestSetup.java:25)
          at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
          at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
          at junit.extensions.TestSetup.run(TestSetup.java:25)
          at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
          at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
          at junit.extensions.TestSetup.run(TestSetup.java:25)

          FAILURES!!!
          Tests run: 8845, Failures: 1, Errors: 1

          Show
          Rick Hillegas added a comment - Tests ran cleanly for me except for the following errors which seem to have been introduced into the mainline recently: 1) testAttributeAccumulatedConnectionCount(org.apache.derbyTesting.functionTests.tests.management.NetworkServerMBeanTest)java.security.PrivilegedActionException: javax.management.InstanceNotFoundException: org.apache.derby:type=NetworkServer,system=c013800d-0129-cd0d-100f-ffffe1d7aa3e at java.security.AccessController.doPrivileged(Native Method) at org.apache.derbyTesting.functionTests.tests.management.MBeanTest.getAttribute(MBeanTest.java:379) at org.apache.derbyTesting.functionTests.tests.management.NetworkServerMBeanTest.testAttributeAccumulatedConnectionCount(NetworkServerMBeanTest.java:93) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:109) at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24) at junit.extensions.TestSetup$1.protect(TestSetup.java:21) at junit.extensions.TestSetup.run(TestSetup.java:25) at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57) at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24) at junit.extensions.TestSetup$1.protect(TestSetup.java:21) at junit.extensions.TestSetup.run(TestSetup.java:25) at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24) at junit.extensions.TestSetup$1.protect(TestSetup.java:21) at junit.extensions.TestSetup.run(TestSetup.java:25) at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57) Caused by: javax.management.InstanceNotFoundException: org.apache.derby:type=NetworkServer,system=c013800d-0129-cd0d-100f-ffffe1d7aa3e at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1010) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getAttribute(DefaultMBeanServerInterceptor.java:627) at com.sun.jmx.mbeanserver.JmxMBeanServer.getAttribute(JmxMBeanServer.java:659) at org.apache.derbyTesting.functionTests.tests.management.MBeanTest$4.run(MBeanTest.java:382) ... 41 more There was 1 failure: 1) ttestSetPortPriority(org.apache.derbyTesting.functionTests.tests.derbynet.ServerPropertiesTest)junit.framework.AssertionFailedError: Port 1537 exceeeds expected maximum. You may need to update TestConfiguration.MAX_PORTS_USED and the Wiki page at http://wiki.apache.org/db-derby/DerbyJUnitTesting if test runs now require more available ports at org.apache.derbyTesting.junit.TestConfiguration.getNextAvailablePort(TestConfiguration.java:1413) at org.apache.derbyTesting.functionTests.tests.derbynet.ServerPropertiesTest.ttestSetPortPriority(ServerPropertiesTest.java:445) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:109) at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24) at junit.extensions.TestSetup$1.protect(TestSetup.java:21) at junit.extensions.TestSetup.run(TestSetup.java:25) at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57) at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24) at junit.extensions.TestSetup$1.protect(TestSetup.java:21) at junit.extensions.TestSetup.run(TestSetup.java:25) at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24) at junit.extensions.TestSetup$1.protect(TestSetup.java:21) at junit.extensions.TestSetup.run(TestSetup.java:25) at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24) at junit.extensions.TestSetup$1.protect(TestSetup.java:21) at junit.extensions.TestSetup.run(TestSetup.java:25) FAILURES!!! Tests run: 8845, Failures: 1, Errors: 1
          Hide
          Rick Hillegas added a comment -

          Committed patch at subversion revision 964039.

          Show
          Rick Hillegas added a comment - Committed patch at subversion revision 964039.
          Hide
          Kathey Marsden added a comment -

          Reopen for backport.

          Show
          Kathey Marsden added a comment - Reopen for backport.
          Hide
          Kathey Marsden added a comment -

          Assign to myself temporarily for backport

          Show
          Kathey Marsden added a comment - Assign to myself temporarily for backport
          Hide
          Kathey Marsden added a comment -

          Resolving after backport to 10.5. Thank you Rick for the fix.

          Show
          Kathey Marsden added a comment - Resolving after backport to 10.5. Thank you Rick for the fix.

            People

            • Assignee:
              Rick Hillegas
              Reporter:
              Rick Hillegas
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development