diff --git a/ChangeLog b/ChangeLog index 4d42709f0c..449e122b59 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Thu Nov 28 09:18:39 2013 Koichi Sasada + + * 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 * st.c (st_keys): fix to use st_index_t for size of hash. diff --git a/string.c b/string.c index c6c1497ea4..231bb2f4fd 100644 --- a/string.c +++ b/string.c @@ -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); }