[MacRuby] #556: Subsequent calls to dispatch apply improperly access incorrect "self"
#556: Subsequent calls to dispatch apply improperly access incorrect "self" ---------------------------------------+------------------------------------ Reporter: joshua.ballanco@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: GCD ---------------------------------------+------------------------------------ The following code: {{{ class Array def pmap(priority = :default, &block) results = [] results_queue = Dispatch::Queue.new("#{results.object_id}_access_queue") Dispatch::Queue.concurrent(priority).apply(size) do |idx| print "self.object_id #=> #{self.object_id}\n" print "self[idx] #=> #{self[idx]}\n" result = block[self[idx]] print "result #=> #{result}\n" results_queue.async do results[idx] = result end end results_queue.sync {} results end end test_ary = ('a'..'j').to_a p test_ary print "test_ary.object_id #=> #{test_ary.object_id}\n" p test_ary.pmap {|i| i.upcase } test_ary = (1..10).to_a p test_ary print "test_ary.object_id #=> #{test_ary.object_id}\n" p test_ary.pmap {|i| i**2 } }}} ...generates this output: {{{ ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"] test_ary.object_id #=> 8594638688 self.object_id #=> 8594638688 self[idx] #=> a result #=> A self.object_id #=> 8594638688 self[idx] #=> e result #=> E self.object_id #=> 8594638688 self[idx] #=> f result #=> F self.object_id #=> 8594638688 self[idx] #=> g result #=> G self.object_id #=> 8594638688 self[idx] #=> h result #=> H self.object_id #=> 8594638688 self[idx] #=> i self.object_id #=> 8594638688 result #=> I self[idx] #=> b self.object_id #=> 8594638688 self[idx] #=> j result #=> J result #=> B self.object_id #=> 8594638688 self[idx] #=> c result #=> C self.object_id #=> 8594638688 self[idx] #=> d result #=> D ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"] [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] test_ary.object_id #=> 8591101024 self.object_id #=> 8594638688 self[idx] #=> a result #=> A self.object_id #=> 8591101024 self.object_id #=> 8591101024 self[idx] #=> 2 self[idx] #=> 3 result #=> 9 self.object_id #=> 8594638688 result #=> 4 self.object_id #=> 8591101024 self[idx] #=> f self.object_id #=> 8591101024 self[idx] #=> 4 self.object_id #=> 8591101024 self[idx] #=> 5 result #=> F self[idx] #=> 8 self.object_id #=> 8591101024 result #=> 16 self.object_id #=> 8591101024 self.object_id #=> 8591101024 result #=> 25 result #=> 64 self[idx] #=> 9 self[idx] #=> 10 self[idx] #=> 7 result #=> 81 result #=> 100 result #=> 49 [nil, 4, 9, 16, 25, nil, 49, 64, 81, 100] }}} Notice that, in the second call to #pmap, some of the iterations of Dispatch::Queue#apply evaluate "self" as the "self" from the first call to #pmap -- Ticket URL: <http://www.macruby.org/trac/ticket/556> MacRuby <http://macruby.org/>
#556: Subsequent calls to dispatch apply improperly access incorrect "self" ---------------------------------------+------------------------------------ Reporter: joshua.ballanco@… | Owner: ernest.prabhakar@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: GCD ---------------------------------------+------------------------------------ Changes (by ernest.prabhakar@…): * owner: lsansonetti@… => ernest.prabhakar@… Comment: Whoops, probably my bad. I assume this is with the latest nightly? If you could write this failure up as a spec, that would be awesome. If not, I'll try to get to it tomorrow. -- Ticket URL: <http://www.macruby.org/trac/ticket/556#comment:1> MacRuby <http://macruby.org/>
#556: Subsequent calls to dispatch apply improperly access incorrect "self" ---------------------------------------+------------------------------------ Reporter: joshua.ballanco@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: GCD ---------------------------------------+------------------------------------ Changes (by lsansonetti@…): * owner: ernest.prabhakar@… => lsansonetti@… Comment: The problem is in RoxorVM::uncache_or_dup_block(). I will investigate this later. Possibly related to #511. -- Ticket URL: <http://www.macruby.org/trac/ticket/556#comment:2> MacRuby <http://macruby.org/>
#556: Subsequent calls to dispatch apply improperly access incorrect "self" ---------------------------------------+------------------------------------ Reporter: joshua.ballanco@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: blocker | Milestone: MacRuby 0.5 Component: MacRuby | Resolution: fixed Keywords: GCD | ---------------------------------------+------------------------------------ Changes (by lsansonetti@…): * status: new => closed * resolution: => fixed * milestone: => MacRuby 0.5 Comment: Should be fixed in r3272. -- Ticket URL: <http://www.macruby.org/trac/ticket/556#comment:3> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby