Bug #5259

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

Added by Masaki Matsushita almost 4 years ago. Updated almost 4 years ago.

[ruby-dev:44449]
Status:Closed
Priority:Normal
Assignee:Tomoyuki Chikanaga
ruby -v:ruby 1.9.4dev (2011-09-01 trunk 33157) [x86_64-linux] Backport:

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

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

Associated revisions

Revision 33170
Added by Tomoyuki Chikanaga almost 4 years ago

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

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

Revision 33170
Added by Tomoyuki Chikanaga almost 4 years ago

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

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

History

#1 Updated by Tomoyuki Chikanaga almost 4 years ago

  • Status changed from Open to Assigned
  • Assignee set to Tomoyuki Chikanaga

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

#2 Updated by Tomoyuki Chikanaga almost 4 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.
    [Bug #5259]

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

Also available in: Atom PDF