diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | string.c | 9 |
2 files changed, 16 insertions, 1 deletions
@@ -1,3 +1,11 @@ +Thu Nov 28 09:18:39 2013 Koichi Sasada <ko1@atdot.net> + + * 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@gmail.com> * st.c (st_keys): fix to use st_index_t for size of hash. @@ -148,7 +148,14 @@ rb_fstring(VALUE str) 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); } |