[前][次][番号順一覧][スレッド一覧]

ruby-changes:47341

From: ko1 <ko1@a...>
Date: Tue, 1 Aug 2017 11:10:26 +0900 (JST)
Subject: [ruby-changes:47341] ko1:r59457 (trunk): should not copy promoted flags.

ko1	2017-08-01 11:10:19 +0900 (Tue, 01 Aug 2017)

  New Revision: 59457

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59457

  Log:
    should not copy promoted flags.
    
    * include/ruby/ruby.h (rb_clone_setup): should not copy some flags
      (FL_PROMOTED0|FL_PROMOTED1|FL_FINALIZE).
      [Bug #13775]
    
    * test/ruby/test_object.rb: add a test (note that this test will fail
      only when RGENGC_CHECK_MODE >= 2).

  Modified files:
    trunk/include/ruby/ruby.h
    trunk/test/ruby/test_object.rb
Index: include/ruby/ruby.h
===================================================================
--- include/ruby/ruby.h	(revision 59456)
+++ include/ruby/ruby.h	(revision 59457)
@@ -2028,7 +2028,8 @@ rb_special_const_p(VALUE obj) https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L2028
 static inline void
 rb_clone_setup(VALUE clone, VALUE obj)
 {
-    rb_obj_setup(clone, rb_singleton_class_clone(obj), RBASIC(obj)->flags);
+    rb_obj_setup(clone, rb_singleton_class_clone(obj),
+                 RBASIC(obj)->flags & ~(FL_PROMOTED0|FL_PROMOTED1|FL_FINALIZE));
     rb_singleton_class_attached(RBASIC_CLASS(clone), clone);
     if (RB_FL_TEST(obj, RUBY_FL_EXIVAR)) rb_copy_generic_ivar(clone, obj);
 }
Index: test/ruby/test_object.rb
===================================================================
--- test/ruby/test_object.rb	(revision 59456)
+++ test/ruby/test_object.rb	(revision 59457)
@@ -934,4 +934,14 @@ class TestObject < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_object.rb#L934
       num.times {a.clone.set}
     end;
   end
+
+  def test_clone_object_should_not_be_old
+    assert_normal_exit <<-EOS, '[Bug #13775]'
+      b = proc { }
+      10.times do |i|
+        b.clone
+        GC.start
+      end
+    EOS
+  end
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]