Skip to content

Commit e3fe53d

Browse files
committed
Pin str content holder while enumerating lines
The content holder may be a imemo:mmtk_strbuf, and may be moved if not pinned.
1 parent d30a2d3 commit e3fe53d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

string.c

+10
Original file line numberDiff line numberDiff line change
@@ -9621,6 +9621,12 @@ rb_str_enumerate_lines(int argc, VALUE *argv, VALUE str, VALUE ary)
96219621
if (!RSTRING_LEN(str)) goto end;
96229622
str = rb_str_new_frozen(str);
96239623
ptr = subptr = RSTRING_PTR(str);
9624+
#if USE_MMTK
9625+
volatile VALUE str_content_holder = 0;
9626+
if (rb_mmtk_enabled_p()) {
9627+
str_content_holder = rb_mmtk_string_content_holder(str);
9628+
}
9629+
#endif
96249630
pend = RSTRING_END(str);
96259631
len = RSTRING_LEN(str);
96269632
StringValue(rs);
@@ -9722,6 +9728,10 @@ rb_str_enumerate_lines(int argc, VALUE *argv, VALUE str, VALUE ary)
97229728
RB_GC_GUARD(str);
97239729
}
97249730

9731+
#if USE_MMTK
9732+
RB_GC_GUARD(str_content_holder);
9733+
#endif
9734+
97259735
end:
97269736
if (ary)
97279737
return ary;

0 commit comments

Comments
 (0)