Skip to content

Commit defff97

Browse files
committed
Fix missing strbuf
In CI (and locally) we were seeing a failed assertion for the `test_gem_remote_fetcher` test. After much debugging it was clear that for this test the strbuf was missing on `shared` so when `orig` moved, `shared` didn't follow`. This caused the offset to be very off. ``` Assertion Failed: string.c:1805:str_new_frozen_buffer:ofs >= 0 ruby 3.4.0dev (2024-08-09T19:42:38Z reproduction-for-s.. a5b29b5277) +MMTk(Immix) [arm64-darwin23] ``` With a `GC_ASSERT` we tracked down a missing `rb_mmtk_str_set_strbuf` in `rb_str_tmp_frozen_no_embed_acquire`. After fixing that case a standard string like `"hi"` would still fail the `GC_ASSERT`. This is because we also need to return early if the `new_root` of a shared object has the `STR_NOFREE` flag. In those cases, the object does not have a strbuf to copy. After these changes, both the `test_string.rb` and `test_gem_remote_fetcher.rb` tests pass. Fixes: #85
1 parent cd5e356 commit defff97

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

string.c

+5
Original file line numberDiff line numberDiff line change
@@ -1671,6 +1671,11 @@ rb_str_tmp_frozen_no_embed_acquire(VALUE orig)
16711671
RSTRING(str)->as.heap.ptr = RSTRING(orig)->as.heap.ptr;
16721672
RBASIC(str)->flags |= RBASIC(orig)->flags & STR_NOFREE;
16731673
RBASIC(orig)->flags &= ~STR_NOFREE;
1674+
#if USE_MMTK
1675+
if (rb_mmtk_enabled_p()) {
1676+
rb_mmtk_str_set_strbuf(str, RSTRING_EXT(orig)->strbuf);
1677+
}
1678+
#endif
16741679
STR_SET_SHARED(orig, str);
16751680
}
16761681

0 commit comments

Comments
 (0)