ruby-changes:54278
From: normal <ko1@a...>
Date: Sat, 22 Dec 2018 06:44:14 +0900 (JST)
Subject: [ruby-changes:54278] normal:r66487 (trunk): test/ruby/test_thread.rb: add diagnosis code for [Bug #15430]
normal 2018-12-22 06:44:09 +0900 (Sat, 22 Dec 2018) New Revision: 66487 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66487 Log: test/ruby/test_thread.rb: add diagnosis code for [Bug #15430] I can't find stderr in the test-all output of the CI machine, so maybe the assertion will show what's going on. http://rubyci.s3.amazonaws.com/centos7/ruby-trunk/log/20181221T170003Z.log.html.gz#test-all Modified files: trunk/test/ruby/test_thread.rb Index: test/ruby/test_thread.rb =================================================================== --- test/ruby/test_thread.rb (revision 66486) +++ test/ruby/test_thread.rb (revision 66487) @@ -1241,23 +1241,44 @@ q.pop https://github.com/ruby/ruby/blob/trunk/test/ruby/test_thread.rb#L1241 def test_fork_while_parent_locked skip 'needs fork' unless Process.respond_to?(:fork) + require 'tempfile' m = Thread::Mutex.new failures = 0 run = true - thrs = 50.times.map do - Thread.new do + errs = '' + nr = 50 + tmps = nr.times.map { Tempfile.new('Bug.15430.diagnosis') } + thrs = nr.times.map do |_i| + Thread.new(_i) do |i| + t = tmps[i] + t.sync = true while run - pid = fork { m.synchronize {} } + pid = fork do + STDERR.reopen(t.path) + tmps.each(&:close) + m.synchronize {} + end m.synchronize {} _, st = Process.waitpid2(pid) - m.synchronize { failures += 1 } unless st.success? + unless st.success? + m.synchronize do + failures += 1 + if errs.empty? + errs = st.inspect << t.read + t.rewind + end + end + end end end end sleep 0.5 run = false thrs.each(&:join) + assert_empty errs assert_equal 0, failures, '[ruby-core:90312] [Bug #15383]' + ensure + tmps&.each(&:close!) end def test_fork_while_mutex_locked_by_forker -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/