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

"invokevirtual" for interface method crashes VM

XMLWordPrintable

    • 1.2beta
    • sparc
    • solaris_2.5.1
    • Verified



      Name: icC57033 Date: 08/15/97


      The section "6.4 The JAVA Virtual machine instruction set" of The Java Virtual Machine
      Specification, subsection invokevirtual says:

      The item at that index in the constant pool must have the tag CONSTANT_Methodref (4.4.2),
      a reference to a class name, a method name, and the method's descriptor (4.3.3).

      Meanwhile, following test crashes VM during execution.
      This is due to a reference to a interface name, a method name, and the method's descriptor
      instead of a reference to a class name, a method name, and the method's descriptor.
      Those crashing is reproduceable for release 1.1.1, 1.1.2, 1.1.3, 1.1.4, 1.2
      -----------------------------------------------------------------
      //File: @(#)invokevirtual00304.jasm 1.1 97/08/14
      //Copyright 08/14/97 Sun Microsystems, Inc. All Rights Reserved
      package javasoft/sqe/tests/vm/invokevirtual/invokevirtual003/invokevirtual00304;

      interface SomeInterface
      {
      public abstract Method m1:"()I";
      public abstract Method m2:"()I";
      } // end Class SomeInterface

      class SomeClss
              implements SomeInterface
      {
      public Method m1:"()I"
              stack 1 locals 1
      {
                      sipush 10;
                      ireturn;
      }

      public Method m2:"()I"
              stack 1 locals 1
      {
                      sipush 20;
                      ireturn;
      }

      Method <init>:"()V"
              stack 1 locals 1
      {
                      aload_0;
                      invokespecial Method java/lang/Object.<init>:"()V";
                      return;
      }

      } // end Class SomeClss

      class invokevirtual00304
      {
      public static Method run:"([Ljava/lang/String;Ljava/io/PrintStream;)I"
              stack 2 locals 3
      {
              new class SomeClss;
              dup;
              invokespecial Method SomeClss.<init>:"()V";
              astore_2;
              try t16;
              aload_2;
      // wrong
              invokevirtual Method SomeInterface.m1:"()I";
      // end wrong
              pop;
              endtry t16;
              goto L19;
              catch t16 java/lang/Throwable;
              pop;
              iconst_0;
              ireturn;
      L19: iconst_2;
              ireturn;
      }

      public static Method main:"([Ljava/lang/String;)V"
              stack 2 locals 1
      {
                      aload_0;
                      getstatic Field java/lang/System.out:"Ljava/io/PrintStream;";
                      invokestatic Method run:"([Ljava/lang/String;Ljava/io/PrintStream;)I";
                      bipush 95;
                      iadd;
                      invokestatic Method java/lang/System.exit:"(I)V";
                      return;
      }

      public Method <init>:"()V"
              stack 1 locals 1
      {
                      aload_0;
                      invokespecial Method java/lang/Object.<init>:"()V";
                      return;
      }

      } // end Class invokevirtual00304
      -----------------------------------------------------------------
      To reproduce bug:

      % uname -a
      SunOS novo62 5.5.1 Generic_103640-08 sun4u sparc SUNW,Ultra-1
      % cd ~/tmp
      % ls
      invokevirtual00304.jasm
      % java -version
      java version "1.2_EA2"
      % java -fullversion
      java full version "JDK1.2H"
      % echo $CLASSPATH
      .:/export/ld32/sqe/harness_release/classes
      % java javasoft.sqe.jasm.Main -strict -d . invokevirtual00304.jasm; echo "status=$status"
      status=0
      % java -verify javasoft.sqe.tests.vm.invokevirtual.invokevirtual003.invokevirtual00304.invokevirtual00304 ; echo "status=$status"
      SIGSEGV 11* segmentation violation
          si_signo [11]: SIGSEGV 11* segmentation violation
          si_errno [0]: Error 0
          si_code [1]: SEGV_MAPERR [addr: 0x38]

      stackbase=F0000000, stackpointer=EFFFF3F0

      Full thread dump:
          "Finalizer" (TID:0xee3004f8, sys_thread_t:0x5d238, state:R) prio=1
          "Ref handler" (TID:0xee3005a8, sys_thread_t:0x5e0b8, state:CW) prio=10
      at java.lang.Object.wait(Native Method)
      at java.lang.Object.wait(Object.java:315)
      at java.lang.Ref$RefHandler.run(Ref.java:129)
          "Async Garbage Collector" (TID:0xee300360, sys_thread_t:0x4a2e8, state:R) prio=1
          "Idle thread" (TID:0xee3003a8, sys_thread_t:0x48d48, state:R) prio=0
          "Clock" (TID:0xee3002a8, sys_thread_t:0xa8b80, state:CW) prio=12
          "main" (TID:0xee3002d8, sys_thread_t:0x209f8, state:R) prio=5 *current thread*
      at javasoft.sqe.tests.vm.invokevirtual.invokevirtual003.invokevirtual00304.invokevirtual00304.run(invokevirtual00304.jasm)
      at javasoft.sqe.tests.vm.invokevirtual.invokevirtual003.invokevirtual00304.invokevirtual00304.main(invokevirtual00304.jasm)
      Monitor Cache Dump:
      Registered Monitor Dump:
          utf8 hash table: <unowned>
          JNI pinning lock: <unowned>
          JNI global reference lock: <unowned>
          BinClass lock: <unowned>
          Class linking lock: <unowned>
          Code rewrite lock: <unowned>
          Heap lock: <unowned>
          Monitor IO lock: <unowned>
          Child death monitor: <unowned>
          Event monitor: <unowned>
          I/O monitor: <unowned>
          Alarm monitor: <unowned>
      Waiting to be notified:
      "Clock"
          Sbrk lock: <unowned>
          Monitor cache expansion lock: <unowned>
          Thread queue lock: <unowned>
          Monitor registry: owner "main" (0x209f8, 1 entry)
      Thread Alarm Q:
      Abort
      status=-2147483642
      %
      -----------------------------------------------------------------
      ======================================================================

            sliangsunw Sheng Liang (Inactive)
            ichebykisunw Igor Chebykin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: