THRIFT-6105: Preserve partial MemoryBufferTransport read progress#3646
Open
kpumuk wants to merge 1 commit into
Open
THRIFT-6105: Preserve partial MemoryBufferTransport read progress#3646kpumuk wants to merge 1 commit into
kpumuk wants to merge 1 commit into
Conversation
5 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes the Ruby native extension implementation of MemoryBufferTransport#read_into_buffer so it preserves transport read progress for bytes that were successfully copied before an exception is raised. This aligns the native behavior with the pure-Ruby implementation, preventing situations where the destination buffer contains copied bytes but the transport still considers them unread.
Changes:
- Update the native
read_into_bufferloop to (a) avoid consuming input bytes when the destination is exhausted and (b) persist the updated transport index before raisingEOFError/IndexError. - Add Ruby specs covering frozen destination buffers, zero-length reads, and partial-progress consumption semantics for both destination exhaustion and input exhaustion.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/rb/spec/base_transport_spec.rb | Adds regression tests for frozen buffers, zero-length reads, and partial-progress consumption behavior. |
| lib/rb/ext/memory_buffer.c | Persists read progress before raising and avoids consuming an extra input byte when the destination is out of capacity. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Client: rb Co-Authored-By: OpenAI Codex (GPT-5.4) <codex@openai.com>
kpumuk
force-pushed
the
rb-short-destination
branch
from
July 20, 2026 15:58
40de1de to
6749ac8
Compare
Comment on lines
+144
to
146
| char byte = RSTRING_PTR(buf)[index++]; | ||
| ((char*)RSTRING_PTR(buffer_value))[i] = byte; | ||
| i++; |
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 delayed recording its transport position until the whole request completed. If input or destination capacity ran out after bytes had been copied, the destination contained those bytes while the transport still treated them as unread.This change preserves the progress of successfully copied bytes before raising, so native retry and recovery behavior matches the pure-Ruby implementation.
[skip ci]anywhere in the commit message to free up build resources.