Issue #5342 has been reported by Mike Perham.

----------------------------------------
Bug #5342: ConditionVariable can wake a Thread that is no longer waiting on it
http://redmine.ruby-lang.org/issues/5342

Author: Mike Perham
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]


See gist at https://gist.github.com/1228184 for a reproducible test case.

Sequence is like this:

* Main thread spawns Thread 1.  Thread 1 pauses 0.5 seconds and then signals cond variable 1.
* Main thread waits on cond variable 1 and times out after 0.3 seconds
* Main thread spawns Thread 2.  Thread 2 pauses 0.5 seconds and then signals cond variable 2.
* Main thread waits on cond variable 2 with a timeout of 1.0 seconds.

I would expect this test to take 0.8 seconds.  Instead the main thread is woken by the original cond variable 1 after 0.5 seconds total.

The code works as expected on JRuby 1.6.4.


-- 
http://redmine.ruby-lang.org