diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index 460dc96230..51dadc9819 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -2028,7 +2028,8 @@ rb_special_const_p(VALUE obj) 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); } diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb index 1e952533a6..e7d623283f 100644 --- a/test/ruby/test_object.rb +++ b/test/ruby/test_object.rb @@ -934,4 +934,14 @@ class TestObject < Test::Unit::TestCase 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