Skip to content

Commit

Permalink
Pin str content holder while enumerating lines
Browse files Browse the repository at this point in the history
The content holder may be a imemo:mmtk_strbuf, and may be moved if not
pinned.
  • Loading branch information
wks committed Jun 19, 2024
1 parent d30a2d3 commit e3fe53d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions string.c
Original file line number Diff line number Diff line change
Expand Up @@ -9621,6 +9621,12 @@ rb_str_enumerate_lines(int argc, VALUE *argv, VALUE str, VALUE ary)
if (!RSTRING_LEN(str)) goto end;
str = rb_str_new_frozen(str);
ptr = subptr = RSTRING_PTR(str);
#if USE_MMTK
volatile VALUE str_content_holder = 0;
if (rb_mmtk_enabled_p()) {
str_content_holder = rb_mmtk_string_content_holder(str);
}
#endif
pend = RSTRING_END(str);
len = RSTRING_LEN(str);
StringValue(rs);
Expand Down Expand Up @@ -9722,6 +9728,10 @@ rb_str_enumerate_lines(int argc, VALUE *argv, VALUE str, VALUE ary)
RB_GC_GUARD(str);
}

#if USE_MMTK
RB_GC_GUARD(str_content_holder);
#endif

end:
if (ary)
return ary;
Expand Down

0 comments on commit e3fe53d

Please sign in to comment.