Skip to content

Commit 2a9680c

Browse files
hsbtclaude
andcommitted
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 <noreply@anthropic.com>
1 parent 9417ce3 commit 2a9680c

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎test/zlib/test_zlib.rb‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,10 @@ def test_read0
12821282
end
12831283

12841284
def test_gets_separator_modified_by_io
1285-
rs = "-" * 1000
1285+
# grown from an empty string so that the content lives in a separate
1286+
# buffer even with a GC that embeds 1000 bytes in the object (mmtk)
1287+
rs = "".dup
1288+
rs << "-" * 1000
12861289
src = StringIO.new(Zlib.gzip(Random.new(0).bytes(200_000).tr("-", "x") + rs))
12871290
n = 0
12881291
io = Object.new

0 commit comments

Comments
 (0)