[ 
https://issues.apache.org/jira/browse/THRIFT-1804?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13585149#comment-13585149
 ] 

Elias Karakoulakis commented on THRIFT-1804:
--------------------------------------------

added some extra logging in lib/rb/ext/compact_protocol.c, and:
{panel}{code}
#line 359
static char read_byte_direct(VALUE self) {
  VALUE byte = rb_funcall(GET_TRANSPORT(self), read_byte_method_id, 0);
  printf("ekarak: read_byte_direct byte=%d\n", (FIX2INT(byte)));
  return (char)(FIX2INT(byte));
}

#line 515
VALUE rb_thrift_compact_proto_read_byte(VALUE self) {
printf("ekarak: rb_thrift_compact_proto_read_byte self=%s\n", 
RSTRING_PTR(rb_inspect(self)));
  return INT2FIX(read_byte_direct(self));
}
{code}{panel}

{noformat}
Thrift::CompactProtocol
ekarak: rb_thrift_compact_proto_read_byte 
self=#<Thrift::CompactProtocol:0x414e0bc8 
@trans=#<Thrift::MemoryBufferTransport:0x414e0d00 @buf="\x81", @index=0>, 
@last_field=[0], @boolean_value=nil, @rbuf="\0\0\0\0\0\0\0\0">
ekarak: read_byte_direct byte=129
  should encode and decode naked primitives correctly (FAILED - 3)
ekarak: read_byte_direct byte=243
ekarak: rb_thrift_compact_proto_read_byte 
self=#<Thrift::CompactProtocol:0x412b5eb0 
@trans=#<Thrift::MemoryBufferTransport:0x412b6570 @buf="\xF3\x81", @index=1>, 
@last_field=[15], @boolean_value=nil, @rbuf="\0\0\0\0\0\0\0\0">
ekarak: read_byte_direct byte=129
  should encode and decode primitives in fields correctly (FAILED - 4)
{noformat}

So, -127 maps to 0x81 which then maps back to (unsigned) 129. Hmmm sounds like 
a Ruby issue to me...
                
> Binary+compact protocol byte corruption in Ruby library (ARM architecture)
> --------------------------------------------------------------------------
>
>                 Key: THRIFT-1804
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1804
>             Project: Thrift
>          Issue Type: Bug
>          Components: Build Process
>    Affects Versions: 0.9
>         Environment: - Debian/ARM Squeeze 6.0.6 native armv5te, compiler: gcc 
> (Debian 4.4.5-8) 4.4.5
> QEMU emulated debian hosts:
> - Debian Squeeze 6.0.6 emulated armvtejl, compiler: gcc (Debian 4.4.5-8) 
> - Debian Sid 7.0 on QEMU ARM versatilepb, compiler: gcc (Debian 4.6.3-14)
>            Reporter: Elias Karakoulakis
>
> These compilation tests fail when compiling for ARM:
>   1) BinaryProtocolAccelerated it should behave like a binary protocol should 
> read a byte
>      Failure/Error: @prot.read_byte.should == i
>        {*}expected: -128{*}
>             {*}got: 128 (using ==){*}
>      Shared Example Group: "a binary protocol" called from 
> ./spec/binary_protocol_accelerated_spec.rb:28
>      # ./spec/binary_protocol_spec_shared.rb:291:in `block (3 levels) in <top 
> (required)>'
>      # ./spec/binary_protocol_spec_shared.rb:289:in `each'
>      # ./spec/binary_protocol_spec_shared.rb:289:in `block (2 levels) in <top 
> (required)>'
>   2) BinaryProtocolAccelerated it should behave like a binary protocol should 
> perform a complete rpc with a struct return type
>      Failure/Error: result.should == Fixtures::COMPACT_PROTOCOL_TEST_STRUCT
>        expected: <CompactProtoTestStruct ... {*}byte_list:[-127, -1, 0, 1, 
> 127]{*}, ....
>             got: <CompactProtoTestStruct ... {*}byte_list:[129, 255, 0, 1, 
> 127]{*}, ...  (using ==)
> (***) only byte_list gets corrupted
>      Shared Example Group: "a binary protocol" called from 
> ./spec/binary_protocol_accelerated_spec.rb:28
>      # ./spec/binary_protocol_spec_shared.rb:375:in `block (3 levels) in <top 
> (required)>'
>      # ./spec/binary_protocol_spec_shared.rb:406:in `call'
>      # ./spec/binary_protocol_spec_shared.rb:406:in `srv_test'
>      # ./spec/binary_protocol_spec_shared.rb:370:in `block (2 levels) in <top 
> (required)>'
>   3) Thrift::CompactProtocol should encode and decode naked primitives 
> correctly
>      Failure/Error: read_back.should == value
>        {*}expected: -127{*}
>             {*}got: 129 (using ==){*}
>      # ./spec/compact_protocol_spec.rb:45:in `block (4 levels) in <top 
> (required)>'
>      # ./spec/compact_protocol_spec.rb:37:in `each'
>      # ./spec/compact_protocol_spec.rb:37:in `block (3 levels) in <top 
> (required)>'
>      # ./spec/compact_protocol_spec.rb:36:in `each_pair'
>      # ./spec/compact_protocol_spec.rb:36:in `block (2 levels) in <top 
> (required)>'
>   4) Thrift::CompactProtocol should encode and decode primitives in fields 
> correctly
>      Failure/Error: read_back.should == value
>        {*}expected: -127{*}
>             {*}got: 129 (using ==){*}
>      # ./spec/compact_protocol_spec.rb:68:in `block (4 levels) in <top 
> (required)>'
>      # ./spec/compact_protocol_spec.rb:55:in `each'
>      # ./spec/compact_protocol_spec.rb:55:in `block (3 levels) in <top 
> (required)>'
>      # ./spec/compact_protocol_spec.rb:51:in `each_pair'
>      # ./spec/compact_protocol_spec.rb:51:in `block (2 levels) in <top 
> (required)>'
> Finished in 5.87 seconds
> 364 examples, 4 failures, 1 pending

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to