Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4414755
Votes 0
Synopsis Code gen'ed for synchronized(){} can cause VM to enter an infinite loop
Category java:compiler
Reported Against merlin-beta
Release Fixed
State 11-Closed, duplicate of 4414101, bug
Priority: 4-Low
Related Bugs 4414101
Submit Date 13-FEB-2001
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$ 
Work Around
N/A
Evaluation
Right. The second exception range should catch only ThreadDeath.

  xxxxx@xxxxx   2001-02-13
Comments
  
  Include a link with my name & email   

Submitted On 18-JUN-2002
davidholmes
Wrong evaluation. See 4414101



PLEASE NOTE: JDK6 is formerly known as Project Mustang