THRIFT-6100: Respect frozen Ruby MemoryBufferTransport destinations#3641
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aligns the native Ruby MemoryBufferTransport#read_into_buffer behavior with the pure-Ruby implementation by respecting Ruby’s frozen-string immutability rules, ensuring frozen destination buffers raise FrozenError before any input is consumed or the destination is modified.
Changes:
- Add spec coverage ensuring reads into frozen destination strings raise
FrozenErrorwithout consuming input, while zero-length reads remain no-ops. - Update the native
memory_buffer.cimplementation to callrb_str_modifyfor positive-length reads, triggeringFrozenErroron frozen destinations.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/rb/spec/base_transport_spec.rb | Adds regression tests covering frozen destination behavior for read_into_buffer (including zero-length reads). |
| lib/rb/ext/memory_buffer.c | Ensures positive-length read_into_buffer requests require a mutable destination string via rb_str_modify. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…tion buffers Client: rb Co-Authored-By: OpenAI Codex (GPT-5.4) <codex@openai.com>
Member
Code reviewNo issues found. Checked for bugs, AGENTS.md compliance, and security implications. 🤖 Generated with Claude Code |
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The native
MemoryBufferTransport#read_into_bufferimplementation bypassed Ruby’s frozen-string checks. A positive-length read could therefore overwrite a frozen destination and consume transport input, while the pure-Ruby implementation raisedFrozenError.This change asks Ruby to make positive-length destination strings mutable before reading from the transport. Frozen destinations now raise
FrozenErrorbefore either the destination or transport is modified, while zero-length reads remain no-ops.[skip ci]anywhere in the commit message to free up build resources.