Project

General

Profile

Actions

Backport #9206

closed

protect FL_MARK at rb_obj_clone()

Added by authorNari (Narihiro Nakamura) about 11 years ago. Updated almost 11 years ago.

Status:
Closed
[ruby-dev:47840]

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

Files

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

Updated by authorNari (Narihiro Nakamura) about 11 years ago

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

Actions #2

Updated by usa (Usaku NAKAMURA) almost 11 years 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]
Actions

Also available in: Atom PDF

Like0
Like0Like0