Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-4053

[drlvm][verifier] Unexpected VerifyError is thrown if end_pc from exception table of code attribute is equal to the length of the code array

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • None
    • DRLVM
    • None

    Description

      Unexpected VerifyError is thrown if end_pc from exception table of code attribute is equal to the length of the code array

      This issue caused the failures of 11 test cases from Geronimo unit test suite.

      Affected tests:
      org.apache.geronimo.gjndi.JavaCompContextTest
      org.apache.geronimo.gjndi.JavaCompGBeanTest
      org.apache.geronimo.gjndi.KernelContextGBeanTest

      According J2SE VM specification:

      "4.7.3 The Code Attribute
      ...
      Each exception_table entry contains the following four items:
      start_pc, end_pc
      The values of the two items start_pc and end_pc indicate the ranges in the code array at which the exception handler is active. The value of start_pc must be a valid index into the code array of the opcode of an instruction. The value of end_pc either must be a valid index into the code array of the opcode of an instruction or must be equal to code_length, the length of the code array ... "

      But DRLVM throws VerifyError if ending point in exception table is equal to the length of the code array.

      Please, use the code below for reproducing:

      ------------------------------------- Verify.java --------------------------------------

      public class Verify {

      public static void main(String[] args) throws ClassNotFoundException {
      try

      { Class cl = Class.forName("test"); System.out.println("TEST PASSED"); }

      catch (Throwable e)

      { System.out.println("TEST FAILED: unexpected " + e); }

      }
      }

      ------------------------------------- test.ccode--------------------------------------

      magic = xCAFEBABE
      minor_version = 3
      major_version = 45
      constant_pool_count = 13

      constant_pool {
      /* #1 */ Method = #12 #6
      /* #2 */ UTF8 = "java/lang/Object"
      /* #3 */ UTF8 = "SourceFile"
      /* #4 */ UTF8 = "<init>"
      /* #5 */ Class = #11
      /* #6 */ NameAndType = #4 #10
      /* #7 */ UTF8 = "Code"
      /* #8 */ UTF8 = "test.ccode"
      /* #9 */ UTF8 = "test"
      /* #10 */ UTF8 = "()V"
      /* #11 */ UTF8 = "test"
      /* #12 */ Class = #2
      }

      access_flags = PUBLIC SUPER // x21
      this_class = #5 // "test"
      super_class = #12 // "java/lang/Object"
      interfaces_count = 0

      interfaces {
      }

      fields_count = 0
      methods_count = 2

      methods {
      method {
      access_flag = PUBLIC // x01
      name_index = #4 // "<init>"
      descriptor_index = #10 // "()V"
      attributes_count = 1

      attributes {
      attribute Code {
      attribute_name_index = #7 // "Code"
      attribute_length = 17
      max_stack = 1
      max_locals = 1
      code_length = 5

      code asm

      { 0: aload_0 1: invokespecial #1 4: return }

      exception_table_length = 0
      attributes_count = 0
      }
      }
      }

      // Test method

      method {
      access_flag = PUBLIC // x01
      name_index = #9 // "test"
      descriptor_index = #10 // "()V"
      attributes_count = 1
      attributes {
      attribute Code {
      attribute_name_index = #7 // "Code"
      attribute_length = 35
      max_stack = 2
      max_locals = 2
      code_length = 15

      code asm

      { 0: sipush 1 3: pop 4: return 5: sipush 2 8: pop 9: return 10: sipush 3 13: pop 14: return }

      exception_table_length = 1
      exception_table

      { // start_pc end_pc handler_pc catch_type 0 15 10 0 // end_pc is equal to code_length }

      attributes_count = 0
      }
      }
      }
      }

      attributes_count = 1

      attributes {

      attribute SourceFile

      { attribute_name_index = #3 // "SourceFile" attribute_length = 2 sourcefile_index = #8 // "test.ccode" }

      }

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

      test class file can be created using VMTT tool from http://issues.apache.org/jira/browse/HARMONY-3206
      reproduce.zip contains test and Verify class files.

      Output on Harmony-r544727:

      Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors,
      as applicable.
      java version "1.5.0"
      pre-alpha : not complete or compatible
      svn = r544727, (Jun 6 2007), Windows/ia32/msvc 1310, release build
      http://harmony.apache.org

      TEST FAILED: unexpected java.lang.VerifyError: (class: test, method: test()V) At least one of except
      ion handler parameters [0, 15, 10] are out of instruction set

      Output on RI:

      java version "1.5.0_11"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
      Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode)

      TEST PASSED

      Attachments

        1. fix_one_if.patch
          1 kB
          Alexei Fedotov
        2. reproduce.zip
          2 kB
          Elena Sayapina
        3. test.patch
          0.8 kB
          Alexei Fedotov

        Issue Links

          Activity

            People

              gshimansky Gregory Shimansky
              evs Elena Sayapina
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: