Project

General

Profile

Actions

Bug #5258

closed

SizedQueueにBug #5195と同様のバグ

Added by Glass_saga (Masaki Matsushita) over 12 years ago. Updated over 11 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.4dev (2011-09-01 trunk 33157) [x86_64-linux]
Backport:
[ruby-dev:44448]

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

patch.diff (399 Bytes) patch.diff Glass_saga (Masaki Matsushita), 09/01/2011 10:23 PM
queue.patch (2.35 KB) queue.patch nagachika (Tomoyuki Chikanaga), 09/03/2011 08:08 PM

Related issues 2 (0 open2 closed)

Related to Ruby master - Bug #5195: Queue#popでsleepしているthreadをwakeupさせるとQueueの@waitingにそのthreadがpushされてしまうClosedkosaki (Motohiro KOSAKI)08/16/2011Actions
Related to Ruby master - Bug #5355: Sync_mにBug #5195やBug #5258と同様のバグClosedkosaki (Motohiro KOSAKI)09/23/2011Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0