[kaffe] Bug Report

Timothy Stack stack at cs.utah.edu
Thu Apr 25 10:50:25 PDT 2002


hi,

> Hi,
> 
> I have possible bug report with threading and nested locks.

its definitely a bug.

> When two threads are nested on the same lock and one (or both) of 
> them sleeps inside the nest, an IllegalMonitorStateException will be 
> thrown.  The lock in question is allocated as a fast lock, however, 
> when the sleep method is called it enters the slow lock code, and 
> gets corrupted.
> 
> A simple test program is included below
> 
> This program works under Java(TM) 2 Runtime Environment, Standard 
> Edition (build 1.3.1-b24), Java HotSpot(TM) Client VM (build 1.3.1-
> b24, mixed mode).
> 
> It fails under kaffe-1.0.6.

The problem is that kaffe uses the stack to keep track of locks/unlocks,
so something like:

  synchronized( lock )
  {
    synchronized( lock )
    {
    }
  }

will break because the top of the stack doesn't change between the first
and second lock.  Therefore, the first unlock will completely free the
lock since the vm can't tell the difference between the two.  So, other
than pushing something on the stack on every synchronized, i don't think
theres much you can do without rewriting the whole locking system.

tim stack




More information about the kaffe mailing list