Backport #9132
closedMutex error while using EM.defer with Ruby 2.0.0
Description
We are in process of migrating our gem from ruby-1.9.3 to ruby-2.0.0. While running rspec examples with v2.0.0
sometimes the following error happens:
/usr/local/lib/ruby/2.0.0/thread.rb:188:in synchronize': Attempt to unlock a mutex which is locked #by another thread (ThreadError) from /usr/local/lib/ruby/2.0.0/thread.rb:188:in
block in pop'
from /usr/local/lib/ruby/2.0.0/thread.rb:187:in handle_interrupt' from /usr/local/lib/ruby/2.0.0/thread.rb:187:in
pop'
from /usr/local/lib/ruby/gems/2.0.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:1036:in #`block in spawn_threadpool'
Initially, I thought that might be related to this EnventMachine issue: https://github.com/eventmachine/eventmachine/issues/457.
But more detailed analysis shows that it might be ruby-2.0.0:
- mutex error never been observed with ruby-1.9.3-p448, ruby 2.1.0dev(2013-11-20 trunk 43737), and rbx-2.1.1
- error happens with ruby-2.0.0-p247, and stable snapshot ruby 2.0.0p350 (2013-11-20 revision 43733)
How to reproduce it: see gist https://gist.github.com/shurab/7472793
Environment: ruby-2.0.0-427, eventmachine (1.0.3), rspec (2.14.1)