Skip to content

Preserve returned read buffer ownership - #72

Closed
OskarEichler wants to merge 1 commit into
ruby:masterfrom
OskarEichler:codex/returned-buffer-ownership-protocol
Closed

OskarEichler wants to merge 1 commit into
ruby:masterfrom
OskarEichler:codex/returned-buffer-ownership-protocol

Conversation

@OskarEichler

Copy link
Copy Markdown
Contributor

BufferedIO appends a String returned by read_nonblock and then clears that returned object. A custom/nonstandard IO that retains the returned String observes unexpected caller-side mutation, even though BufferedIO only needs its copied bytes. Removing the redundant clear preserves ownership and output.

The external ownership model fails on current master and passes after this change on Ruby 4.0.6 and 3.2.11. The unchanged suite passes 30 tests / 66 assertions on both Rubies; syntax and diff checks pass. No repository tests were changed.

@hsbt

hsbt commented Sep 17, 2026

Copy link
Copy Markdown
Member

rv.clear is deliberate. ed3c639 added it to cut memory from 120MB to 50MB on a parallel Net::HTTP download.

@hsbt hsbt closed this Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants