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

An un-initialized object can be monitored

XMLWordPrintable

    • x86_64
    • linux

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      Test the next program (a monitored object is not initizlied) on HotSpot and IBM's J9. J9 throw out a verifier error, while HotSpot does not. It seems that HotSpot's verifier forgets to check whether a monitored object is initialized.

      Besides, I tested the program on HotSpot for Java 9. The problem is also there.





      THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: Did not try

      THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Did not try

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Throws a verify error, similar to J9's report.

      Exception in thread "main" java.lang.VerifyError: JVMVRFY012 stack shape inconsistent; class=Search, method=main([Ljava/lang/String;)V, pc=6
      Exception Details:
        Location:
          Search.main([Ljava/lang/String;)V @6: JBmonitorenter
        Reason:
          Type 'uninitialized' (current frame, stack[1]) is not assignable to 'java/lang/Object'
        Current Frame:
          bci: @6
          flags: { }
          locals: { 'Search', '[Ljava/lang/String;' }
          stack: { 'uninitialized', 'uninitialized' }
      at T.main(T.java:4)



      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class Search
        minor version: 0
        major version: 52
        flags: ACC_PUBLIC, ACC_SUPER
      Constant pool:
         #1 = Utf8 Search
         #2 = Class #1 // Search
         #3 = Utf8 java/lang/Object
         #4 = Class #3 // java/lang/Object
         #5 = Utf8 <clinit>
         #6 = Utf8 ()V
         #7 = Utf8 <init>
         #8 = NameAndType #7:#6 // "<init>":()V
         #9 = Methodref #4.#8 // java/lang/Object."<init>":()V
        #10 = Utf8 main
        #11 = Utf8 ([Ljava/lang/String;)V
        #12 = Utf8 java/lang/Exception
        #13 = Class #12 // java/lang/Exception
        #14 = Utf8 Code
        #15 = Utf8 Exceptions
      {
        public static {};
          descriptor: ()V
          flags: ACC_PUBLIC, ACC_STATIC
          Code:
            stack=0, locals=0, args_size=0
               0: return

        public Search();
          descriptor: ()V
          flags: ACC_PUBLIC
          Code:
            stack=1, locals=1, args_size=1
               0: aload_0
               1: invokespecial #9 // Method java/lang/Object."<init>":()V
               4: return

        public void main(java.lang.String[]) throws java.lang.Exception;
          descriptor: ([Ljava/lang/String;)V
          flags: ACC_PUBLIC
          Code:
            stack=3, locals=2, args_size=2
               0: new #2 // class Search
               3: dup
               4: aload_0
               5: monitorenter
               6: monitorenter
               7: monitorexit
               8: aload_0
               9: monitorexit
              10: return
          Exceptions:
            throws java.lang.Exception
      }
      ---------- END SOURCE ----------

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: