From: Heesob Park Date: 2010-07-23T13:55:33+09:00 Subject: [ruby-core:31454] [Bug #3606] Thread.stop and puts fail to work as documented. Bug #3606: Thread.stop and puts fail to work as documented. http://redmine.ruby-lang.org/issues/show/3606 Author: Heesob Park Status: Open, Priority: Normal Category: core, Target version: 1.9.x ruby -v: ruby 1.9.3dev (2010-07-22 trunk 28707) [i686-linux] I have tested following three codes which are the sample code in RDoc Documentation. t1.rb ==================================================== a = Thread.new { puts "a"; Thread.stop; puts "c" } Thread.pass puts "Got here" a.run a.join sleep 1 ==================================================== t2.rb ==================================================== a = Thread.new { print "a"; Thread.stop; print "c" } Thread.pass print "b" a.run a.join sleep 1 ==================================================== t3.rb ==================================================== c = Thread.new { Thread.stop; puts "hey!" } c.wakeup sleep 1 ==================================================== Expected output t1.rb a Got here c t2.rb abc t3.rb hey! on Ruby 1.8.6 $ ruby -v ruby 1.8.6 (2009-06-08 patchlevel 369) [i686-linux] $ ruby -v t1.rb a Got here c $ ruby -v t2.rb abc$ ruby -v t3.rb hey! $ Result t1.rb ==> success t2.rb ==> success t3.rb ==> success on Ruby 1.9.1 $ ruby -v ruby 1.9.1p378 (2010-01-10 revision 26273) [i686-linux] $ ruby t1.rb aGot here c $ ruby t2.rb $ ruby t3.rb $ Result t1.rb ==> fail t2.rb ==> success t3.rb ==> fail On Ruby 1.9.3dev duometis02@Duo02:~$ ruby -v ruby 1.9.3dev (2010-07-22 trunk 28707) [i686-linux] $ ruby t1.rb Got herea t1.rb:5:in `join': deadlock detected (fatal) from t1.rb:5:in `
' $ ruby t2.rb bat2.rb:5:in `join': deadlock detected (fatal) from t2.rb:5:in `
' $ ruby t3.rb $ Result t1.rb ==> fail t2.rb ==> fail t3.rb ==> fail Interesingly, the following code sometimes works and sometimes failed on Ruby 1.9.3.dev. t4.rb ==================================================== c = Thread.new { Thread.stop; puts "hey!" } puts "Hi!" c.wakeup sleep 1 ==================================================== $ ruby -v ruby 1.9.3dev (2010-07-22 trunk 28707) [i686-linux] $ ruby t4.rb Hi! $ ruby t4.rb Hi! hey! $ ruby t4.rb Hi! hey! $ ruby t4.rb Hi! $ ---------------------------------------- http://redmine.ruby-lang.org