* 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).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2013-11-28 00:22:45 +00:00
parent 8c91dfb91b
commit d7df3e2830
2 changed files with 16 additions and 1 deletions

View file

@ -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);
}