[#47409] [ruby-trunk - Feature #6973][Open] Add an #integral? method to Numeric to test for whole-number values — "regularfry (Alex Young)" <alex@...>

12 messages 2012/09/03

[#47481] [ruby-trunk - Bug #7008][Open] rake is crashing when trying to compile ffi gem — "drookie (Eugene M. Zheganin Eugene M. Zheganin)" <eugene@...>

10 messages 2012/09/12

[#47505] [ruby-trunk - Feature #7019][Open] allow `private` and `protected` keywords to take blocks — "alexeymuranov (Alexey Muranov)" <redmine@...>

15 messages 2012/09/13

[#47582] [ruby-trunk - Bug #7037][Open] float formatting inconsistently rounds half to even — "headius (Charles Nutter)" <headius@...>

14 messages 2012/09/19

[#47638] [ruby-trunk - Bug #7046][Open] ERB#run and ERB#result are not safe for concurrent use — "headius (Charles Nutter)" <headius@...>

11 messages 2012/09/21

[#47655] [ruby-trunk - Feature #7051][Open] Extend caller_locations API to include klass and bindings. Allow caller_locations as a method hanging off Thread. — "sam.saffron (Sam Saffron)" <sam.saffron@...>

13 messages 2012/09/23

[#47657] [ruby-trunk - Feature #7055][Open] Allow `.foo=` as a synonym of `self.foo=` — "alexeymuranov (Alexey Muranov)" <redmine@...>

11 messages 2012/09/23

[#47730] [ruby-trunk - Bug #7085][Open] Subversion → GitHub gateway stops. — "shyouhei (Shyouhei Urabe)" <shyouhei@...>

27 messages 2012/09/29

[#47735] [ruby-trunk - Bug #7087][Open] ::ConditionVariable#wait does not work with Monitor because Monitor#sleep does not exist — "rklemme (Robert Klemme)" <shortcutter@...>

10 messages 2012/09/29

[#47759] [ruby-trunk - Bug #7092][Open] StringScanner start-of-line matches false positives, while lookbehind for a newline gives false negatives — "jayferd (Jay Adkisson)" <jjmadkisson@...>

8 messages 2012/09/30

[ruby-core:47643] [ruby-trunk - Bug #4285] Ruby don't have asynchrounous exception safe syntax and It should have.

From: "ko1 (Koichi Sasada)" <redmine@...>
Date: 2012-09-22 00:14:33 UTC
List: ruby-core #47643
Issue #4285 has been updated by ko1 (Koichi Sasada).


I don't follow all of discussion about it, this is solved by [ruby-trunk - Feature #6762]?


----------------------------------------
Bug #4285: Ruby don't have asynchrounous exception safe syntax and It should have.
https://bugs.ruby-lang.org/issues/4285#change-29657

Author: kosaki (Motohiro KOSAKI)
Status: Assigned
Priority: Normal
Assignee: ko1 (Koichi Sasada)
Category: lib
Target version: 2.0.0
ruby -v: ruby 1.9.3dev (2010-12-22 trunk 30291) [x86_64-linux]


=begin
 This issue was discovered during [Bug#4266] discussion.
 Current timeout is racy.
 
 Now, timeout module has following code.
 -------------------------------------------------------------------------------
   def timeout()
     begin
       x = Thread.current
       y = Thread.start {
         begin
           sleep sec
         rescue => e
           x.raise e
         else
           x.raise exception, "execution expired" if x.alive?
         end
       }
       return yield(sec)
     rescue exception => e
       raise Error, e.message, e.backtrace
     ensure
       if y and y.alive?
         y.kill
         y.join # make sure y is dead.
       end
     end
   end
 ---------------------------------------------------------------
 
 Unfortunatelly, 
 
    y = Thread.start {}
 
 is not an atomic operation. Then, A following race can occur.
 
 
   CPU0(thread x)                     CPU1(thread y)         remark
 ---------------------------------------------------------------------------
   enter begin block
   [thread construct]                                        but no assign y yet
                                      sleep sec
                                      wakeup from sleep
                                      x.raise
   if y                                                      return false. (see above)
 
 
 Therefore, CPU0 don't call y.join and leak y's thread resource. C# have solved
 this two-step-construction vs asynchrounous exception race by RAII.
 (Plus, C#'s finally block is async exception safe automatically)
 
 But unfortunately, Ruby don't have such language feature. So, We can't write
 async-exception-safe code. One of solution is to move timeout module from ruby code
 into c code as JRuby does. But I don't think timeout is only asynchrounos exception user.
 we also have Interrupt class (for Ctrl-C) and I think we need to allow to write async 
 exception safe code by ruby.
 
 So, My proposal is,
  o for 1.9.x
      => Reimplement timeout.rb by C (as JRuby)
 
  o for 2.0
      => Aim new feature for writing async exception safe code.
 
 
 Or, Am I missing something?
=end



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

In This Thread

Prev Next