[concurrency-interest] ReentrantLock bug?

Dr Heinz M. Kabutz heinz at javaspecialists.eu
Thu Mar 19 17:17:23 EDT 2015

Hi Dmitry,

is it possible to send me a sanitized stack trace of what state the 
thread would be in if RL caused a hang?  Someone reported a very strange 
behaviour a long time ago on Linux with JDK 7, where you could sometimes 
get a thread that was waiting for a lock, even though it was Unlocked.  
The lock they used was a direct copy of ReentrantLock, with the only 
difference being that it had been not been loaded in the system class 
loader.  I managed to reproduce it, although not sure of the exact 
version of Java 7.  After several day of chasing it, I ran out of time 
and left it, but I've always had the niggling suspicion that it might be 
a bug that lives fine and well in the ReentrantLock.

This was for Java 1.7.0_40, -server.  I thus do not share Aleksey's 
optimism that moving over to that version is going to make the problem 
go away.  I could not reproduce it on 1.8, but that might have just been 
a coincidence.  It was quite difficult to reproduce.

BTW, not a silly report / question at all.  Very important indeed, 
especially considering how many classes in JDK use ReentrantLock 
internally :-(((


Dr Heinz M. Kabutz (PhD CompSci)
Author of "The Java(tm) Specialists' Newsletter"
Sun/Oracle Java Champion since 2005
JavaOne Rock Star Speaker 2012
Tel: +30 69 75 595 262
Skype: kabutz

Dmitry Zaslavsky wrote:
> Apologies for such a silly report / question.
>     I have an application that out 100s of machines, every couple of runs would get into a state that’s only possible if ReentrantLock has a bug.
>     While it would be hard to repro locally. On the grid it’s quite easy to repeat.
>     Of course it’s possible I am doing something something very wrong.
>     One time I saw RL in a locked state but the owner was null.
>     I replaced all the uses of _lock.lock() try {} finally { _lock.unlock(); } with synchronized(_lock) and the problem went away.
>    Still using jdk 7 u21
>    Any suggestions?
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest

More information about the Concurrency-interest mailing list