Backport #9206

protect FL_MARK at rb_obj_clone()

Added by Narihiro Nakamura over 1 year ago. Updated over 1 year ago.

[ruby-dev:47840]
Status:Closed
Priority:Normal
Assignee:Usaku NAKAMURA

Description

=begin
rb_obj_clone()の時にコピー用に作成したオブジェクトにマークビットが付く可能性があり、そのマークを誤って消してしまうバグを修正しました。
flagsのコピー時にオリジナルのFL_MARKを守るようにしています。

Ruby 2.0.0についてはビットマップマーキングを利用しているためこのパッチを適用する必要はないと思います。

diff --git a/object.c b/object.c
index 0a0b260..1ab28a3 100644
--- a/object.c
+++ b/object.c
@@ -285,7 +285,7 @@ rb_obj_clone(VALUE obj)
}
clone = rb_obj_alloc(rb_obj_class(obj));
RBASIC(clone)->klass = rb_singleton_class_clone(obj);
- RBASIC(clone)->flags = (RBASIC(obj)->flags | FL_TEST(clone, FL_TAINT) | FL_TEST(clone, FL_UNTRUSTED)) & ~(FL_FREEZE|FL_FINALIZE|FL_MARK);
+ RBASIC(clone)->flags = (RBASIC(obj)->flags | FL_TEST(clone, FL_TAINT) | FL_TEST(clone, FL_UNTRUSTED)) & ~(FL_FREEZE|FL_FINALIZE|FL_MARK) | (RBASIC(clone)->flags&FL_MARK);
init_copy(clone, obj);
rb_funcall(clone, id_init_clone, 1, obj);
RBASIC(clone)->flags |= RBASIC(obj)->flags & FL_FREEZE;
=end

fix_to_unprotected_FL_MARK.patch Magnifier (1.2 KB) Narihiro Nakamura, 12/03/2013 08:13 PM

Associated revisions

Revision 44337
Added by Usaku NAKAMURA over 1 year ago

  • object.c (rb_obj_clone): protect FL_MARK of a dest object. A lazy sweeper free up a dest object if a marker is invoked immediately following allocate a dest object in rb_obj_alloc(). [Backport #9206]

History

#1 Updated by Narihiro Nakamura over 1 year ago

肝心のパッチを付けるのを忘れてました…。

#2 Updated by Usaku NAKAMURA over 1 year ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r44337.
Narihiro, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • object.c (rb_obj_clone): protect FL_MARK of a dest object. A lazy sweeper free up a dest object if a marker is invoked immediately following allocate a dest object in rb_obj_alloc(). [Backport #9206]

Also available in: Atom PDF