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

ruby-changes:31808

From: ko1 <ko1@a...>
Date: Thu, 28 Nov 2013 09:22:52 +0900 (JST)
Subject: [ruby-changes:31808] ko1:r43887 (trunk): * string.c (rb_fstring): fstrings should be ELTS_SHARED.

ko1	2013-11-28 09:22:45 +0900 (Thu, 28 Nov 2013)

  New Revision: 43887

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

  Log:
    * string.c (rb_fstring): fstrings should be ELTS_SHARED.
      If we resurrect dying objects (non-marked, but not swept yet),
      pointing shared string can be collected.
      To avoid such issue, fstrings (recorded to fstring_table)
      should not be ELTS_SHARED (should not have a shared string).

  Modified files:
    trunk/ChangeLog
    trunk/string.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43886)
+++ ChangeLog	(revision 43887)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Nov 28 09:18:39 2013  Koichi Sasada  <ko1@a...>
+
+	* string.c (rb_fstring): fstrings should be ELTS_SHARED.
+	  If we resurrect dying objects (non-marked, but not swept yet),
+	  pointing shared string can be collected.
+	  To avoid such issue, fstrings (recorded to fstring_table)
+	  should not be ELTS_SHARED (should not have a shared string).
+
 Thu Nov 28 01:35:08 2013  Masaki Matsushita  <glass.saga@g...>
 
 	* st.c (st_keys): fix to use st_index_t for size of hash.
Index: string.c
===================================================================
--- string.c	(revision 43886)
+++ string.c	(revision 43887)
@@ -148,7 +148,14 @@ rb_fstring(VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L148
 	rb_gc_resurrect(str);
     }
     else {
-	str = rb_str_new_frozen(str);
+	if (STR_SHARED_P(str)) {
+	    /* str should not be shared */
+	    str = rb_enc_str_new(RSTRING_PTR(str), RSTRING_LEN(str), STR_ENC_GET(str));
+	    OBJ_FREEZE(str);
+	}
+	else {
+	    str = rb_str_new_frozen(str);
+	}
 	RBASIC(str)->flags |= RSTRING_FSTR;
 	st_insert(frozen_strings, str, str);
     }

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

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