[MacRuby-devel] [MacRuby] #511: GCD crash with indirect method access

MacRuby ruby-noreply at macosforge.org
Sat Jan 23 22:30:10 PST 2010


#511: GCD crash with indirect method access
---------------------------------------+------------------------------------
 Reporter:  joshua.ballanco@…          |       Owner:  lsansonetti@…        
     Type:  defect                     |      Status:  new                  
 Priority:  blocker                    |   Milestone:                       
Component:  MacRuby                    |    Keywords:  GCD                  
---------------------------------------+------------------------------------

Comment(by joshua.ballanco@…):

 A day of Yak shaving later, and it seems that the root cause is calling
 "invalidate_method_cache" as part of method resolution when another thread
 already has the cached method in use. As suggested by Laurent, first
 calling the methods once on the main thread fixes the issue:

 {{{
 class Foo
   def doit
     puts "hi there!"
   end
 end

 class Bar
   def initialize
     @foo = Foo.new
   end

   def step
     100.times{ @foo.doit }
   end
 end

 @bars = []
 1000.times { @bars << Bar.new }
 @bars.each(&:step)

 steps = Dispatch::Group.new
 @bars.each do |bar|
   Dispatch::Queue.concurrent.async(steps) { bar.step }
 end
 steps.wait
 }}}

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/511#comment:9>
MacRuby <http://macruby.org/>



More information about the MacRuby-devel mailing list