Bug #11683
Updated by nobu (Nobuyoshi Nakada) about 9 years ago
I get the following failure. This is a multi-threaded autoload and defined? method test. If I add wait queue code introduced at r52332 to `rb_const_defined_0` function, the test is not failed. I attached the patch. ```diff ``` diff --git a/test/ruby/test_autoload.rb b/test/ruby/test_autoload.rb index a672e0b..c71668e 100644 --- a/test/ruby/test_autoload.rb +++ b/test/ruby/test_autoload.rb @@ -234,6 +234,28 @@ p Foo::Bar end end + def test_defined_with_autoload + ruby_impl_require do |called_with| + Tempfile.create(%w(autoload .rb)) do |file| + file.puts "class AutoloadTest; module B; end; end" + file.flush + add_autoload(file.path) + begin + thrs = [] + 2.times do + thrs << Thread.new do + Thread.pass; assert_equal("constant", defined? Object::AutoloadTest::B) + end + end + thrs.each(&:join) + ensure + remove_autoload_constant + end + assert_equal [file.path], called_with.uniq + end + end + end + def add_autoload(path) (@autoload_paths ||= []) << path ::Object.class_eval {autoload(:AutoloadTest, path)} ``` ``` $ while [ $? -eq 0 ]; do make test-all TESTS="-v ruby/test_autoload.rb -n test_defined_with_autoload"; done (snip) 1) Failure: TestAutoload#test_defined_with_autoload [/home/shirosaki/src/ruby/test/ruby/test_autoload.rb:247]: <"constant"> expected but was <nil>. ```