Issue #5768 has been updated by Yui NARUSE.


Nobuyoshi Nakada wrote:
>  rb_barrier_release/rb_barrier_destroy?????若?違??????????鴻?с??mutex???????????
>  ?????????????????????????с?????с??緇???????Barrier??????????眼???????у??????????????????
>  ??????

??????????????腴??????障????????

?????????鴻?????????????t1 ??? t2.stop? == true ???緇???c?????????箴?紊???????c?? require ???????????障?????
荐?????????????????t2 ??? rb_barrier_wait ?????? rb_mutex_lock ?????? native_cond_wait ???育????????????緇???c?????????
箴?紊???????c?? require ???箴?紊??????????????????????c?????障?????
???篏??????ゃ?潟????????mutex->cond_waiting++ ????????????????????????????????障????????

???????t2 ?????????? rb_mutex_lock ??с????????
thread.c ??? 3481茵????? th->status = THREAD_STOPPED_FOREVER ???????茵????????????障?????
??????篁ラ?????Thread#stop????true???菴?????????????????障??????????障?? GVL ????c??????鴻????????????????????уぇ筝?紊?с?????
????????????10茵???祉??????????GVL_UNLOCK_BEGIN();???????茵????????????障?????
????????????篁????鴻???????????????????????????????障???????障????????鴻????????? STOP ?????????????
t1 ?????????倶????у????????箴?紊????????????? require ????????????load_unlock ?????若?違????障?????
??ゃ?障???????????鴻?у???????經?????障?????
????????? rb_barrier_release ?????若?潟????障?? 0 ???障?障??mutex->cond_waiting ???荀???? Qfalse ???菴?????????????
loading_tbl ??????綵?荅蚊????鴻?????ゃ???????????障????障?????
筝???鴻??t1 ?????????綛活??????? lock_func???ャ??????????c??mutex->cond_waiting++?????障?????
30茵???祉?????c???native_cond_wait??у????<?障????????筝?荐????宴?若?鴻??翫??????????????????????????????c?????障?????

??障??????????GVL_UNLOCK_BEGIN?????????mutex->cond_waiting++????????篁????鴻???????????????????
mutex->cond_waiting???荀????????0???障?障?с????????緇???c???篋冴???????????????????с??
緇???>査?????????????翫?????????????????????緇???c???篋冴????榊???????????
??隙??????????load.c ??? load_unlock ??? rb_barrier_destroy/rb_barrier_destroy ????st_delete ??????????????????????????с?????

>  > diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb
>  > index 9186a6f..f1d8d12 100644
>  > --- a/test/ruby/test_require.rb
>  > +++ b/test/ruby/test_require.rb
>  > @@ -350,9 +350,18 @@ class TestRequire < Test::Unit::TestCase
>  >      path = tmp.path
>  >      tmp.print <<-EOS
>  >  TestRequire.scratch << :pre
>  > -Thread.pass until t2 = TestRequire.scratch[1]
>  > +TestRequire.scratch << Thread.current
>  > +Thread.pass until t2 = TestRequire.scratch[2]
>  >  Thread.pass until t2.stop?
>  > -open(__FILE__, "w") {|f| f.puts "TestRequire.scratch << :post"}
>  > +open(__FILE__, "w") do |f|
>  > +  f.puts "t1, t2 = TestRequire.scratch[1, 2]"
>  > +  f.puts "if Thread.current == t2"
>  > +  f.puts "  TestRequire.scratch << :post"
>  > +  f.puts "  until t1.stop?"
>  > +  f.puts "    Thread.pass"
>  > +  f.puts "  end"
>  > +  f.puts "end"
>  > +end
>  >  raise "con1"
>  
>  ?????????眼?с??t2??с??若????????????????????喝???????????障?????????????????require???箴?紊?
>  ??т賢??????????????t1,t2????<?????絎????????若????????????????????????絎??????
>  ??с?????

???????????????祉?????????? :post ??????障????????宴?若?鴻??????????????????????c?????障????????
----------------------------------------
Bug #5768: TestRequire#test_race_exception??х???????????宴?若?鴻????障????????
https://bugs.ruby-lang.org/issues/5768

Author: Yui NARUSE
Status: Assigned
Priority: Normal
Assignee: Motohiro KOSAKI
Category: core
Target version: 2.0.0
ruby -v: -


??障??require??х???????????宴?若?鴻??罧???c?????障?????
???????鴻???????腆?????????????莎激????障???????????篁ヤ?????????紊???眼???????腆阪???莎???????????????????障?????

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