ruby-changes:33474
From: ko1 <ko1@a...>
Date: Thu, 10 Apr 2014 19:16:29 +0900 (JST)
Subject: [ruby-changes:33474] ko1:r45553 (trunk): * array.c (rb_ary_modify): remember shared array owner if a shared
ko1 2014-04-10 19:16:24 +0900 (Thu, 10 Apr 2014) New Revision: 45553 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45553 Log: * array.c (rb_ary_modify): remember shared array owner if a shared array owner is promoted and a shared array is not promoted. Now, shared array is WB-unprotected so that shared arrays are not promoted. All objects referred from shared array should be marked correctly. [ruby-core:61919] [ruby-trunk - Bug #9718] * test/ruby/test_array.rb: add a test for above. Modified files: trunk/ChangeLog trunk/array.c trunk/test/ruby/test_array.rb Index: array.c =================================================================== --- array.c (revision 45552) +++ array.c (revision 45553) @@ -343,6 +343,11 @@ rb_ary_modify(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L343 ARY_SET_CAPA(ary, len); ARY_SET_PTR(ary, ptr); } + + /* TODO: age2 promotion, OBJ_PROMOTED() checks not infant. */ + if (OBJ_PROMOTED(ary) && !OBJ_PROMOTED(shared)) { + rb_gc_writebarrier_remember_promoted(ary); + } } } Index: ChangeLog =================================================================== --- ChangeLog (revision 45552) +++ ChangeLog (revision 45553) @@ -1,3 +1,16 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Apr 10 19:11:11 2014 Koichi Sasada <ko1@a...> + + * array.c (rb_ary_modify): remember shared array owner if a shared + array owner is promoted and a shared array is not promoted. + + Now, shared array is WB-unprotected so that shared arrays are not + promoted. All objects referred from shared array should be marked + correctly. + + [ruby-core:61919] [ruby-trunk - Bug #9718] + + * test/ruby/test_array.rb: add a test for above. + Thu Apr 10 18:57:12 2014 Koichi Sasada <ko1@a...> * gc.c (gc_verify_internal_consistency): move lines and enable Index: test/ruby/test_array.rb =================================================================== --- test/ruby/test_array.rb (revision 45552) +++ test/ruby/test_array.rb (revision 45553) @@ -2389,7 +2389,7 @@ class TestArray < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_array.rb#L2389 assert_equal([], a.rotate!(13)) assert_equal([], a.rotate!(-13)) a = [].freeze - assert_raise_with_message(RuntimeError, /can't modify frozen/) {a.rotate!} + assert_raise_with_message(RuntimeError, /can\'t modify frozen/) {a.rotate!} a = [1,2,3] assert_raise(ArgumentError) { a.rotate!(1, 1) } end @@ -2428,4 +2428,27 @@ class TestArray < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_array.rb#L2428 assert_include([4, 7], a.bsearch {|x| (2**100).coerce((1 - x / 4) * (2**100)).first }) end + + def test_shared_marking + assert_normal_exit <<-EOS, '[Bug #9718]' + begin + require 'timeout' + timeout(5) do + queue = [] + i = 0 + srand(0) + loop do + if (i+=1) > rand(100_000) + GC.verify_internal_consistency + queue.shift.call + i = 0 + end + queue << lambda{} + end + end + rescue TimeoutError + assert(true) + end + EOS + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/