[前][次][番号順一覧][スレッド一覧]

ruby-changes:40249

From: naruse <ko1@a...>
Date: Thu, 29 Oct 2015 03:58:54 +0900 (JST)
Subject: [ruby-changes:40249] naruse:r52330 (trunk): thread may leak if assert fails before join is finished

naruse	2015-10-29 03:58:34 +0900 (Thu, 29 Oct 2015)

  New Revision: 52330

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52330

  Log:
    thread may leak if assert fails before join is finished

  Modified files:
    trunk/test/ruby/test_thread.rb
Index: test/ruby/test_thread.rb
===================================================================
--- test/ruby/test_thread.rb	(revision 52329)
+++ test/ruby/test_thread.rb	(revision 52330)
@@ -637,7 +637,7 @@ class TestThread < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_thread.rb#L637
       th = Thread.start{
         Thread.handle_interrupt(Object => :on_blocking){
           begin
-            sleep 0.0001 until r == :wait
+            Thread.pass until r == :wait
             Thread.current.raise RuntimeError
             r = :ok
             sleep
@@ -647,8 +647,9 @@ class TestThread < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_thread.rb#L647
         }
       }
       assert_raise(e) {r = :wait; sleep 1}
-    ensure
       assert_raise(RuntimeError) {th.join(0)}
+    ensure
+      th.kill
     end
     assert_equal(:ok,r)
   end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]