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

Code gen'ed for synchronized(){} can cause VM to enter an infinite loop

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 1.4.0
    • Fix Version/s: None
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • CPU:
      generic
    • OS:
      solaris_7

      Description

      The code we generate for

      synchronized {
      f();
      }

      can cause the VM to enter an infinite loop if the monitor
      is in an inconsistent state at the monitorexit instruction.
      That is because we catch the IllegalMonitorStateException
      and retry the monitorexit. We should allow the
      IllegalMonitorStateException to propogate.

      The interesting case in the code below is an exception
      occurring at instruction 5 or 11.

      frog$ cat -n T.java
           1 class T {
           2 void f() {
           3 synchronized (this) {
           4 }
           5 }
           6 }
      frog$ javap -c T
      Compiled from T.java
      synchronized class T extends java.lang.Object
          /* ACC_SUPER bit set */
      {
          T();
          void f();
      }

      Method T()
         0 aload_0
         1 invokespecial #1 <Method java.lang.Object()>
         4 return

      Method void f()
         0 aload_0
         1 astore_1
         2 aload_1
         3 monitorenter
         4 aload_1
         5 monitorexit
         6 goto 14
         9 astore_2
        10 aload_1
        11 monitorexit
        12 aload_2
        13 athrow
        14 return
      Exception table:
         from to target type
           4 6 9 any
           9 12 9 any
      frog$

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              gafter Neal Gafter
              Reporter:
              gafter Neal Gafter
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: