[ https://issues.apache.org/jira/browse/THRIFT-1632?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Nevo Hed updated THRIFT-1632: ----------------------------- Attachment: patch 1) I confirmed this problem to occur with 0.8.0 & trunk from svn 2) I also narrowed it down to rb_thrift_memory_buffer_read_into_buffer in lib/rb/ext/memory_buffer.c (disable binding this function and the test passes, i.e. the ruby implementation, rather than the native, is executed) 3) without actually trying to understand the actual code, I noticed a difference between the ruby & C versions where the "index" vs "GARBAGE_BUFFER_SIZE" comparison (and what I assume is a flush) was outside of the loop in Ruby, and inside the loop in "C". The attached patch makes the C side behave more like the well-behaving ruby side. It moves the the above mentioned comparison after the loop. Also note that I moved the initialization of index outside of the loop to resolve a compiler warning. > ruby: data corruption in thrift_native implementation of MemoryBufferTransport > ------------------------------------------------------------------------------ > > Key: THRIFT-1632 > URL: https://issues.apache.org/jira/browse/THRIFT-1632 > Project: Thrift > Issue Type: Bug > Components: Ruby - Library > Affects Versions: 0.7, 0.8, 0.9 > Environment: Tested on Linux/Centos 6.0, with thrift_native.so > installed > Reporter: Nevo Hed > Assignee: Nevo Hed > Labels: newbie, patch > Attachments: patch, test.rb, test.thrift > > > Detected a failure when serializing, then deserializing a specific object > (I think the object needs to be large enough, AND probably must have non zero > data at a specific offset) > $ /usr/bin/thrift --gen rb test.thrift && ruby test.rb > Caught Thrift::ProtocolException exception: Invalid value of field x1! > Trace: > ./gen-rb/test_types.rb:34:in `validate' > test.rb:15:in `read' > test.rb:15 -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira