[ 
https://issues.apache.org/jira/browse/THRIFT-6105?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Dmytro Shteflyuk updated THRIFT-6105:
-------------------------------------
    Fix Version/s: 0.25.0

> Ruby native MemoryBufferTransport should retain partial read progress
> ---------------------------------------------------------------------
>
>                 Key: THRIFT-6105
>                 URL: https://issues.apache.org/jira/browse/THRIFT-6105
>             Project: Thrift
>          Issue Type: Bug
>          Components: Ruby - Library
>            Reporter: Dmytro Shteflyuk
>            Assignee: Dmytro Shteflyuk
>            Priority: Major
>             Fix For: 0.25.0
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> h3. Problem
> The native {{MemoryBufferTransport#read_into_buffer}} implementation keeps 
> the read position in a local variable until the entire operation completes. 
> If it raises after copying one or more bytes, the destination has been 
> modified but the transport still reports those copied bytes as available. The 
> pure-Ruby implementation records each successfully copied byte before a later 
> failure.
> h3. Client impact
> Clients that recover from {{IndexError}} or {{EOFError}} can receive input a 
> second time even though it was already copied into their destination buffer. 
> The observable behavior also depends on whether {{thrift_native}} is loaded.
> h3. Reproduction
> {code:ruby}
> transport = Thrift::MemoryBufferTransport.new("ab")
> destination = +"x"
> begin
>   transport.read_into_buffer(destination, 2)
> rescue IndexError
> end
> p [destination, transport.available]
> # Pure Ruby: ["a", 1]
> # Native extension before this change: ["a", 2]
> {code}
> The same mismatch occurs when input ends after a successful partial copy.
> h3. Expected behavior
> Once a byte has been copied to the destination, both implementations should 
> treat it as consumed even if a later destination-boundary or 
> input-availability check raises an exception.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to