[#44925] [Backport93 - Backport #5702][Open] backport r33935 — Yusuke Endoh <mame@...>

19 messages 2011/12/03
[#44929] [Backport93 - Backport #5702] backport r33935 — Tomoyuki Chikanaga <nagachika00@...> 2011/12/05

[#44931] Re: [Backport93 - Backport #5702] backport r33935 — Yusuke Endoh <mame@...> 2011/12/05

遠藤です。

[#44940] Re: [ruby-cvs:41134] naruse:r33956 (trunk): Comment out tests which fails with GDBM-DBM compat mode. — Tanaka Akira <akr@...>

2011/12/6 <naruse@ruby-lang.org>:

9 messages 2011/12/05
[#44941] Re: [ruby-cvs:41134] naruse:r33956 (trunk): Comment out tests which fails with GDBM-DBM compat mode. — KOSAKI Motohiro <kosaki.motohiro@...> 2011/12/05

2011年12月5日16:56 Tanaka Akira <akr@fsij.org>:

[#44942] Re: [ruby-cvs:41134] naruse:r33956 (trunk): Comment out tests which fails with GDBM-DBM compat mode. — KOSAKI Motohiro <kosaki.motohiro@...> 2011/12/05

> おかしいな。gdbmは勝手にcreateフラグを立ててしまうので当該2つの

[#44985] [ruby-trunk - Bug #5757][Open] main threadがreadやselectで待っていると、^C でなかなか死なない — Yui NARUSE <naruse@...>

12 messages 2011/12/13

[#45021] [ruby-trunk - Bug #5786][Open] LoadError: cannot load such file -- openssl — Kazuhiro NISHIYAMA <redmine@...>

11 messages 2011/12/21

[#45057] [ruby-trunk - Feature #5820][Assigned] Merge Onigmo to Ruby 2.0 — Yui NARUSE <naruse@...>

21 messages 2011/12/28

[ruby-dev:45006] [ruby-trunk - Bug #5768] TestRequire#test_race_exceptionで競合するケースがまだある

From: Tomoyuki Chikanaga <nagachika00@...>
Date: 2011-12-19 01:58:19 UTC
List: ruby-dev #45006
Issue #5768 has been updated by Tomoyuki Chikanaga.


bug5754 .rb の中で t2 が Thread.current になっているようだったのと、scratch の配列の順序が
違っているようだったので少し変更してみました。

diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb
index 9186a6f..02f7efe 100644
--- a/test/ruby/test_require.rb
+++ b/test/ruby/test_require.rb
@@ -349,10 +349,11 @@ class TestRequire < Test::Unit::TestCase
     tmp = Tempfile.new(%w"bug5754 .rb")
     path = tmp.path
     tmp.print <<-EOS
+Thread.pass until TestRequire.scratch[1]
 TestRequire.scratch << :pre
-Thread.pass until t2 = TestRequire.scratch[1]
+t2 = TestRequire.scratch[0,2].reject{|t| t == Thread.current}[0]
 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[0, 2];if Thread.current == t2; Thread.pass until t1.stopped?; end"}
 raise "con1"
     EOS
     tmp.close
@@ -364,6 +365,8 @@ raise "con1"
     t2_res = nil

     t1 = Thread.new do
+      Thread.pass until t1
+      scratch << t1
       begin
         require(path)
       rescue RuntimeError
@@ -376,6 +379,7 @@ raise "con1"
     end

     t2 = Thread.new do
+      Thread.pass until t2
       Thread.pass until scratch[0]
       begin
         scratch << t2
@@ -389,8 +393,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([t1, t2, :pre, :post, :t2, :t1], scratch, bug5754)
   ensure
     tmp.close(true) if tmp
   end

この状態で test_race_exception を実行すると以下のように ThreadError が(require のところで)発生するようになりました。

  1) Failure:
test_race_exception(TestRequire) [/home/nagachika/opt/ruby-trunk/src/ruby/test/ruby/test_require.rb:386]:
[ruby-core:41618].
Exception raised:
<#<ThreadError: Attempt to unlock a mutex which is locked by another thread>>.

とり急ぎご報告まで。
----------------------------------------
Bug #5768: TestRequire#test_race_exceptionで競合するケースがまだある
https://bugs.ruby-lang.org/issues/5768

Author: Yui NARUSE
Status: Assigned
Priority: Normal
Assignee: Nobuyoshi Nakada
Category: 
Target version: 
ruby -v: ruby 2.0.0dev (2011-12-16 trunk 34058) [x86_64-freebsd9.0]


まだ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


-- 
http://redmine.ruby-lang.org

In This Thread