[#69084] [Ruby trunk - Feature #11124] [Open] [PATCH] lib/*: use monotonic clock for timeouts — normalperson@...
Issue #11124 has been reported by Eric Wong.
5 messages
2015/05/06
[#69138] [Ruby trunk - Feature #11136] [PATCH] webrick: avoid fcntl module — nobu@...
Issue #11136 has been updated by Nobuyoshi Nakada.
3 messages
2015/05/12
[#69160] [Ruby trunk - Feature #11146] [PATCH] variable.c: initialize generic_iv_tbl at start — nobu@...
Issue #11146 has been updated by Nobuyoshi Nakada.
4 messages
2015/05/13
[#69175] Re: [Ruby trunk - Feature #11146] [PATCH] variable.c: initialize generic_iv_tbl at start
— Eric Wong <normalperson@...>
2015/05/13
nobu@ruby-lang.org wrote:
[ruby-core:69182] [Ruby trunk - Bug #11153] [Open] Defining singleton methods using `class << self` sometimes fails when using threads
From:
redmine@...
Date:
2015-05-14 04:30:05 UTC
List:
ruby-core #69182
Issue #11153 has been reported by Matt Brictson.
----------------------------------------
Bug #11153: Defining singleton methods using `class << self` sometimes fails when using threads
https://bugs.ruby-lang.org/issues/11153
* Author: Matt Brictson
* Status: Open
* Priority: Normal
* Assignee:
* ruby -v: ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
Defining singleton methods using this syntax occasionally produces unexpected results when run in parallel with multiple threads:
~~~
class << obj
def method_one
end
def method_two
end
end
~~~
Sometimes not all of the methods are defined, leading to this result:
~~~
obj.respond_to?(:method_one) # => true
obj.respond_to?(:method_two) # => false
~~~
Here is a short script that demonstrates the bug.
~~~
require "thread"
def define_singleton_methods_in_thread
Thread.new do
100_000.times do
obj = Object.new
class << obj
def one
end
def two
end
def three
end
end
puts "FAIL" unless obj.respond_to?(:three)
end
end
end
# Test with 2 threads
2.times.map { define_singleton_methods_in_thread }.map(&:join)
~~~
On my machine this script prints "FAIL" 3 times.
I am able to reproduce this bug in 2.0.0-p451, 2.1.6, 2.2.2, and the current ruby_2_2 branch. I *cannot* reproduce in trunk.
More information here: https://github.com/net-ssh/net-ssh/pull/240
--
https://bugs.ruby-lang.org/