From 2a9680ccbf4d545ea6f1f04270ad6d4616f7e4f2 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 26 Nov 2026 18:11:12 +0900 Subject: [PATCH] Keep the separator out of the object in a test for mmtk mmtk can embed a String of any length in its object, so `"-" * 1000` keeps its content there and `replace` copies the new content into the same place. The pointer never changes and the test always fails with mmtk. Grow `rs` from an empty string so that its content lives in a separate buffer with any GC. Co-Authored-By: Claude Opus 5.5 --- test/zlib/test_zlib.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/zlib/test_zlib.rb b/test/zlib/test_zlib.rb index 2e4f83c..cfe1537 100644 --- a/test/zlib/test_zlib.rb +++ b/test/zlib/test_zlib.rb @@ -1282,7 +1282,10 @@ def test_read0 end def test_gets_separator_modified_by_io - rs = "-" * 1000 + # grown from an empty string so that the content lives in a separate + # buffer even with a GC that embeds 1000 bytes in the object (mmtk) + rs = "".dup + rs << "-" * 1000 src = StringIO.new(Zlib.gzip(Random.new(0).bytes(200_000).tr("-", "x") + rs)) n = 0 io = Object.new