[#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:47637] [ruby-trunk - Bug #6822][Closed] Race Condition with Fiber and Process

From: "ko1 (Koichi Sasada)" <redmine@...>
Date: 2012-09-21 22:44:32 UTC
List: ruby-core #47637
Issue #6822 has been updated by ko1 (Koichi Sasada).

Category changed from YARV to core
Status changed from Assigned to Closed

In general, you can sync with variables because Fibers are not changed automatically.  In other words, you can completely control Fiber transition.

----------------------------------------
Bug #6822: Race Condition with Fiber and Process
https://bugs.ruby-lang.org/issues/6822#change-29651

Author: MartinBosslet (Martin Bosslet)
Status: Closed
Priority: Normal
Assignee: ko1 (Koichi Sasada)
Category: core
Target version: 2.0.0
ruby -v: ruby 2.0.0dev (2012-05-07 trunk 35550) [x86_64-linux]


If I run the following code

    $stdout.sync = true
    objects = [1, 2, 3]

    fiber = Fiber.new do
      loop do
        objects.each { |obj| Fiber.yield(obj) }
      end
    end

    def run(obj)
      fork do
        puts obj
      end
    end

    def on_child_exit(obj)
      begin
        while Process.wait(-1, Process::WNOHANG)
          run(obj)
        end
      rescue Errno::ECHILD
      end
    end

    trap(:CHLD) { on_child_exit(fiber.resume) }
    4.times { run(fiber.resume) }
    sleep

I get
 
    fiber_process.rb:26:in `resume': double resume (FiberError)

or

    fiber_process.rb:26:in `resume': fiber called across stack rewinding barrier (FiberError)

There is a race condition when two or more children exit. Now I know I can implement
this differently, but this still made me curious. Is this a bug? Let's say I would 
need to use a Fiber, then there is no way how I can do the synchronization manually,
or is there? Using a Mutex to synchronize the Fiber#resume will fail due to the 
non-reentrant behaviour of Mutex#lock (I'll get "in `lock': deadlock; recursive 
locking (ThreadError)"). Is there a way to do this or should Fibers not be used in
this context? 





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

In This Thread