Project

General

Profile

Actions

Bug #5259

closed

SizedQueue#max=で正でない数を指定できてしまう

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

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

Description

=begin
SizedQueue#max=で正でない数を指定できてしまいます。

require 'thread'

sq = SizedQueue.new(1)
sq.max = -1
p sq.max #=> -1
sq.push(nil) #=> deadlock detected

SizedQueue.newでは引数が正の数であるかどうかチェックが行われていますが、SizedQueue#max=ではそのようなチェックが行われていません。
これはバグではないでしょうか。
patchを添付します。
=end


Files

patch.diff (356 Bytes) patch.diff Glass_saga (Masaki Matsushita), 09/01/2011 10:56 PM

Updated by nagachika (Tomoyuki Chikanaga) over 13 years ago

  • Status changed from Open to Assigned
  • Assignee set to nagachika (Tomoyuki Chikanaga)

おっしゃる通りだと思いますので、テストを追加してコミットしておきます。
報告ありがとうございました。

Actions #2

Updated by nagachika (Tomoyuki Chikanaga) over 13 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r33170.
Masaki, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • lib/thread.rb (SizedQueue#max=) raise ArgumentError if max is not
    positive number. patch by Masaki Matsushita.
    [ruby-dev:44449] [Bug #5259]

  • test/thread/test_queue.rb (test_sized_queue_initialize,
    test_sized_queue_assign_max): add tests for it.

Actions

Also available in: Atom PDF

Like0
Like0Like0