Bug #5258
closedSizedQueueにBug #5195と同様のバグ
Description
=begin
[Bug #5195][ruby-dev:44400]と同様ですが、SizedQueue#pushでsleepしているthreadをwakeupさせると、SizedQueueの@queue_waitにそのthreadがpushされてしまいます。
require 'thread'
sq = SizedQueue.new(1)
sq.push(0)
t1 = Thread.start { sq.push(1) ; sleep }
nil until t1.stop?
t1.wakeup
nil until t1.stop?
t2 = Thread.start { sq.push(2) }
nil until t1.stop? && t2.stop?
p t1, t2
sq.instance_eval{ p @queue_wait }
3.times{ sq.pop }
t2.join
上記のコードを実行すると、
#<Thread:0x00000000b1a198 sleep>
#<Thread:0x00000000b1a120 sleep>
[#<Thread:0x00000000b1a198 sleep>, #<Thread:0x00000000b1a198 sleep>, #<Thread:0x00000000b1a120 sleep>]
/usr/local/lib/ruby/1.9.1/thread.rb:185:in sleep': deadlock detected (fatal) from /usr/local/lib/ruby/1.9.1/thread.rb:185:in
block in pop'
from internal:prelude:10:in synchronize' from /usr/local/lib/ruby/1.9.1/thread.rb:180:in
pop'
from /usr/local/lib/ruby/1.9.1/thread.rb:324:in pop' from sized_queue.rb:19:in
block in '
from sized_queue.rb:19:in times' from sized_queue.rb:19:in
'
となります。
場当たり的なものですが[Bug #5195][ruby-dev:44400]の時と同様なpatchを添付します。適用後もtest/thread/test_queue.rbをパスします。
=end
Files