Project

General

Profile

Actions

Bug #5768

closed

TestRequire#test_race_exceptionで競合するケースがまだある

Added by naruse (Yui NARUSE) about 13 years ago. Updated about 12 years ago.

Status:
Closed
Target version:
ruby -v:
-
Backport:
[ruby-dev:45002]

Description

まだrequireで競合するケースが残っています。
現在のテストだと確率的にしか起きませんが、以下の通り変更すると確実に起きるようになります。

diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb
index 9186a6f..262a5ef 100644
--- a/test/ruby/test_require.rb
+++ b/test/ruby/test_require.rb
@@ -352,7 +352,7 @@ class TestRequire < Test::Unit::TestCase
TestRequire.scratch << :pre
Thread.pass until t2 = TestRequire.scratch[1]
Thread.pass until t2.stop?
-open(FILE, "w") {|f| f.puts "TestRequire.scratch << :post"}
+open(FILE, "w") {|f| f.puts "TestRequire.scratch << :post"; f.puts "t1,t2=TestRequire.scratch[1, 2];if Thread.current == t2; Thread.pass until t1.stopped?; end"}
raise "con1"
EOS
tmp.close
@@ -364,6 +364,7 @@ raise "con1"
t2_res = nil

 t1 = Thread.new do
  •  scratch << t1
     begin
       require(path)
     rescue RuntimeError
    

@@ -389,8 +390,8 @@ raise "con1"
assert_nothing_raised(ThreadError, bug5754) {t1.join}
assert_nothing_raised(ThreadError, bug5754) {t2.join}

  • assert_equal(true, (t1_res ^ t2_res), bug5754)
  • assert_equal([:pre, t2, :post, :t2, :t1], scratch, bug5754)
  • assert_equal(true, (t1_res ^ t2_res), bug5754 + " t1:#{t1_res} t2:#{t2_res}")
  • assert_equal([:pre, t1, t2, :post, :t2, :t1], scratch, bug5754)
    ensure
    tmp.close(true) if tmp
    end

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #5754: Double require bug in 1.9.3Closednobu (Nobuyoshi Nakada)12/13/2011Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0