Bug #1649

use of #send in MonitorMixin::extend_object fails for BasicSocket objects

Added by Young Hyun over 2 years ago. Updated 10 months ago.

[ruby-core:23907]
Status:Closed Start date:06/18/2009
Priority:Normal Due date:
Assignee:- % Done:

100%

Category:lib
Target version:1.9.1
ruby -v:ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-freebsd6.1]

Description

MonitorMixin::extend_object executes obj.send(:mon_initialize) with the intention of invoking Object#send.  However, this code fails when used on BasicSocket (and descendants), which has an unrelated #send.  MonitorMixin::extend_object should use __send__ or revert back to the old code: obj.instance_eval {mon_initialize()}.

Reproduce with:

>> require 'socket'
=> true
>> sock_pair = UNIXSocket.pair Socket::SOCK_STREAM, 0
=> [#<UNIXSocket:0x8401868>, #<UNIXSocket:0x840187c>]
>> require 'monitor'
=> true
>> sock_pair[1].extend MonitorMixin
ArgumentError: wrong number of arguments (1 for 2)
        from /foo/ruby-1.9.1-p129/lib/ruby/1.9.1/monitor.rb:140:in `send'
        from /foo/ruby-1.9.1-p129/lib/ruby/1.9.1/monitor.rb:140:in `extend_object'
        from (irb):7:in `extend'
        from (irb):7
        from /foo/ruby-1.9.1-p129/bin/irb:12:in `<main>'

Associated revisions

Revision 23754
Added by Yukihiro Matsumoto over 2 years ago

* lib/monitor.rb (MonitorMixin::extend_object): should use #__send__ instead of #send to avoid possible name conflict. [ruby-core:23907]

History

Updated by Yukihiro Matsumoto over 2 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100
Applied in changeset r23754.

Also available in: Atom PDF