You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Bryan Duxbury (JIRA)" <ji...@apache.org> on 2011/06/01 19:25:47 UTC
[jira] [Closed] (THRIFT-1183) Pure-ruby CompactProtocol raises
ArgumentError when deserializing under Ruby 1.9
[ https://issues.apache.org/jira/browse/THRIFT-1183?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Bryan Duxbury closed THRIFT-1183.
---------------------------------
Resolution: Fixed
Fix Version/s: 0.7
Assignee: Ilya Maykov
Ah, you're totally right. I just tested #ord in a ruby 1.8.6 irb without thinking about our extensions. I just committed this patch.
> Pure-ruby CompactProtocol raises ArgumentError when deserializing under Ruby 1.9
> --------------------------------------------------------------------------------
>
> Key: THRIFT-1183
> URL: https://issues.apache.org/jira/browse/THRIFT-1183
> Project: Thrift
> Issue Type: Bug
> Components: Ruby - Library
> Affects Versions: 0.6.1
> Environment: OS X 10.6 i686 / Ruby 1.9.2
> Reporter: Ilya Maykov
> Assignee: Ilya Maykov
> Fix For: 0.7
>
> Attachments: patch-THRIFT-1183.txt
>
>
> While testing my fix for THRIFT-1182 with various combinations of native/non-native ruby and binary/compact protocols, I stumbled upon a bug in the pure-ruby implementation of CompactProtocol.
> In lib/thrift/protocol/compact_protocol.rb line 306:
> ...
> val = dat[0]
> if (val > 0x7f)
> ...
> Here, dat is a string, so dat[0] returns a Fixnum in Ruby 1.8.7 but a string of size 1 in Ruby 1.9.2. The conditional compares dat[0] with 0x7f, which raises the following error in 1.9.2:
> /Users/ilyam/.rvm/gems/ruby-1.9.2-p180/gems/thrift-0.6.0/lib/thrift/protocol/compact_protocol.rb:307:in `>': comparison of String with 127 failed (ArgumentError)
> from /Users/ilyam/.rvm/gems/ruby-1.9.2-p180/gems/thrift-0.6.0/lib/thrift/protocol/compact_protocol.rb:307:in `read_byte'
> from /Users/ilyam/.rvm/gems/ruby-1.9.2-p180/gems/thrift-0.6.0/lib/thrift/protocol/compact_protocol.rb:243:in `read_field_begin'
> from /Users/ilyam/.rvm/gems/ruby-1.9.2-p180/gems/thrift-0.6.0/lib/thrift/struct.rb:86:in `block in read'
> from /Users/ilyam/.rvm/gems/ruby-1.9.2-p180/gems/thrift-0.6.0/lib/thrift/struct.rb:85:in `loop'
> from /Users/ilyam/.rvm/gems/ruby-1.9.2-p180/gems/thrift-0.6.0/lib/thrift/struct.rb:85:in `read'
> from /Users/ilyam/.rvm/gems/ruby-1.9.2-p180/gems/thrift-0.6.0/lib/thrift/serializer/deserializer.rb:29:in `deserialize'
> The solution is a one-line fix, patch will be attached shortly.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira