Backport #9206

protect FL_MARK at rb_obj_clone()

Added by Narihiro Nakamura 5 months ago. Updated 4 months ago.

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

Description

=begin
rbobjclone()の時にコピー用に作成したオブジェクトにマークビットが付く可能性があり、そのマークを誤って消してしまうバグを修正しました。
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 @@ rbobjclone(VALUE obj)
}
clone = rbobjalloc(rbobjclass(obj));
RBASIC(clone)->klass = rbsingletonclassclone(obj);
- RBASIC(clone)->flags = (RBASIC(obj)->flags | FL
TEST(clone, FLTAINT) | FLTEST(clone, FLUNTRUSTED)) & ~(FLFREEZE|FLFINALIZE|FLMARK);
+ RBASIC(clone)->flags = (RBASIC(obj)->flags | FLTEST(clone, FLTAINT) | FLTEST(clone, FLUNTRUSTED)) & ~(FLFREEZE|FLFINALIZE|FLMARK) | (RBASIC(clone)->flags&FLMARK);
initcopy(clone, obj);
rb
funcall(clone, idinitclone, 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 4 months ago

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

History

#1 Updated by Narihiro Nakamura 5 months ago

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

#2 Updated by Usaku NAKAMURA 4 months 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 (rbobjclone): protect FLMARK of a dest object. A lazy sweeper free up a dest object if a marker is invoked immediately following allocate a dest object in rbobj_alloc(). [Backport #9206]

Also available in: Atom PDF