[MacRuby] #511: GCD crash with indirect method access
#511: GCD crash with indirect method access ---------------------------------------+------------------------------------ Reporter: joshua.ballanco@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: GCD ---------------------------------------+------------------------------------ The following code will crash when I run it on my Mac Pro (8x2.26 GHz): {{{ #!/usr/local/bin/macruby class Foo def doit end end class Bar def initialize @foo = Foo.new end def step @foo.doit end end @bars = [] 1000.times { @bars << Bar.new } steps = Dispatch::Group.new @bars.each do |bar| Dispatch::Queue.concurrent.async(steps) { bar.step } end steps.wait }}} Commenting out the "@foo.doit" line prevents the crash. -- Ticket URL: <http://www.macruby.org/trac/ticket/511> MacRuby <http://macruby.org/>
#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 conradwt@…): The error is not produceable using r3126. -- Ticket URL: <http://www.macruby.org/trac/ticket/511#comment:1> MacRuby <http://macruby.org/>
#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@…): Replying to [comment:1 conradwt@…]:
The error is not produceable using r3126. What is the machine you were testing on? This seems to be a race, and I've only verified that the above example crashes on the machine specified.
-- Ticket URL: <http://www.macruby.org/trac/ticket/511#comment:2> MacRuby <http://macruby.org/>
#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 lsansonetti@…): I can't reproduce the crash either on my mac book pro, but I suspect it might repro on a machine with more CPU cores like a Mac Pro. -- Ticket URL: <http://www.macruby.org/trac/ticket/511#comment:3> MacRuby <http://macruby.org/>
#511: GCD crash with indirect method access ---------------------------------------+------------------------------------ Reporter: joshua.ballanco@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: GCD ---------------------------------------+------------------------------------ Old description:
The following code will crash when I run it on my Mac Pro (8x2.26 GHz):
{{{ #!/usr/local/bin/macruby
class Foo def doit end end
class Bar def initialize @foo = Foo.new end
def step @foo.doit end end
@bars = [] 1000.times { @bars << Bar.new }
steps = Dispatch::Group.new @bars.each do |bar| Dispatch::Queue.concurrent.async(steps) { bar.step } end steps.wait }}}
Commenting out the "@foo.doit" line prevents the crash.
New description: The following code will crash when I run it on my Mac Pro (8x2.26 GHz): {{{ #!/usr/local/bin/macruby class Foo def doit end end class Bar def initialize @foo = Foo.new end def step 100.times{ @foo.doit } end end @bars = [] 1000.times { @bars << Bar.new } steps = Dispatch::Group.new @bars.each do |bar| Dispatch::Queue.concurrent.async(steps) { bar.step } end steps.wait }}} Commenting out the "@foo.doit" line prevents the crash. -- Comment(by joshua.ballanco@…): Adding repetitions inside of "step" makes it crash more regularly. -- Ticket URL: <http://www.macruby.org/trac/ticket/511#comment:4> MacRuby <http://macruby.org/>
#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 lsansonetti@…): Josh, can you try to reproduce the problem with r3272? -- Ticket URL: <http://www.macruby.org/trac/ticket/511#comment:6> MacRuby <http://macruby.org/>
#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@…): Replying to [comment:6 lsansonetti@…]:
Josh, can you try to reproduce the problem with r3272? Still reproducing...
-- Ticket URL: <http://www.macruby.org/trac/ticket/511#comment:8> MacRuby <http://macruby.org/>
#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/>
#511: GCD crash with indirect method access ---------------------------------------+------------------------------------ Reporter: joshua.ballanco@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: blocker | Milestone: MacRuby 0.7 Component: MacRuby | Resolution: fixed Keywords: GCD | ---------------------------------------+------------------------------------ Changes (by joshua.ballanco@…): * status: new => closed * resolution: => fixed * milestone: => MacRuby 0.7 Comment: Appears to be fixed as of r4182. -- Ticket URL: <http://www.macruby.org/trac/ticket/511#comment:11> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby