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

ruby-changes:35108

From: ko1 <ko1@a...>
Date: Fri, 15 Aug 2014 19:37:49 +0900 (JST)
Subject: [ruby-changes:35108] ko1:r47190 (trunk): * string.c (setup_fake_str): fake strings should not set class by

ko1	2014-08-15 19:37:42 +0900 (Fri, 15 Aug 2014)

  New Revision: 47190

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

  Log:
    * string.c (setup_fake_str): fake strings should not set class by
      RBASIC_SET_CLASS() because it insert write barriers to fake
      (non-RVALUE) structure.
      It can cause unexpected behaviour.
      Ruby 2.1 also have a same problem (setup_fake_str() in parse.y).
    * symbol.c (setup_fake_str): ditto.

  Modified files:
    trunk/ChangeLog
    trunk/string.c
    trunk/symbol.c
Index: symbol.c
===================================================================
--- symbol.c	(revision 47189)
+++ symbol.c	(revision 47190)
@@ -414,7 +414,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/symbol.c#L414
 setup_fake_str(struct RString *fake_str, const char *name, long len)
 {
     fake_str->basic.flags = T_STRING|RSTRING_NOEMBED;
-    RBASIC_SET_CLASS((VALUE)fake_str, rb_cString);
+    RBASIC_SET_CLASS_RAW((VALUE)fake_str, rb_cString);
     fake_str->as.heap.len = len;
     fake_str->as.heap.ptr = (char *)name;
     fake_str->as.heap.aux.capa = len;
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 47189)
+++ ChangeLog	(revision 47190)
@@ -1,3 +1,15 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Aug 15 19:34:33 2014  Koichi Sasada  <ko1@a...>
+
+	* string.c (setup_fake_str): fake strings should not set class by
+	  RBASIC_SET_CLASS() because it insert write barriers to fake
+	  (non-RVALUE) structure.
+
+	  It can cause unexpected behaviour.
+
+	  Ruby 2.1 also have a same problem (setup_fake_str() in parse.y).
+
+	* symbol.c (setup_fake_str): ditto.
+
 Fri Aug 15 19:27:25 2014  Koichi Sasada  <ko1@a...>
 
 	* array.c (rb_ary_tmp_new): added.
Index: string.c
===================================================================
--- string.c	(revision 47189)
+++ string.c	(revision 47190)
@@ -240,7 +240,7 @@ setup_fake_str(struct RString *fake_str, https://github.com/ruby/ruby/blob/trunk/string.c#L240
 
     ENCODING_SET_INLINED((VALUE)fake_str, encidx);
 
-    RBASIC_SET_CLASS((VALUE)fake_str, rb_cString);
+    RBASIC_SET_CLASS_RAW((VALUE)fake_str, rb_cString);
     fake_str->as.heap.len = len;
     fake_str->as.heap.ptr = (char *)name;
     fake_str->as.heap.aux.capa = len;

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

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