You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Luca Sacchi (JIRA)" <ji...@apache.org> on 2015/03/06 14:33:39 UTC

[jira] [Comment Edited] (THRIFT-2180) Integer types issues in Cocoa lib on ARM64

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

Luca Sacchi edited comment on THRIFT-2180 at 3/6/15 1:33 PM:
-------------------------------------------------------------

This patch broke TBinaryProtocol at cocoa side
Inspecting generated messages, i found that version and size field in versioned_size union are created in wrong order.

I tested against a Java server with TBinaryProtocol encapsulated in HTTP.

attached a simple patch that resolve the issue

diff --git a/lib/cocoa/src/protocol/TBinaryProtocol.m b/lib/cocoa/src/protocol/TBinaryProtocol.m
index e79bd57..d64db26 100644
--- a/lib/cocoa/src/protocol/TBinaryProtocol.m
+++ b/lib/cocoa/src/protocol/TBinaryProtocol.m
@@ -26,8 +26,8 @@ static const uint16_t VERSION_1 = 0x8001;
 union versioned_size {
   int32_t i32;
   struct {
-    uint16_t version;
-    int16_t size;
+      int16_t size;
+      uint16_t version;
   } packed;
 };
 
@@ -394,7 +394,7 @@ static TBinaryProtocolFactory * gSharedFactory = nil;
                         sequenceID: (int) sequenceID
 {
   if (mStrictWrite) {
-    int version = VERSION_1 | messageType;
+    int version = (VERSION_1 << 16) | messageType;
     [self writeI32: version];
     [self writeString: name];
     [self writeI32: sequenceID];


was (Author: gurubook):
This patch broke TBinaryProtocol at cocoa side
Inspecting generated messages, i found that version and size field in versioned_size union are created in wrong order.

I tested against a Java server with TBinaryProtocol encapsulated in HTTP.

attached a simple pathc that resolve the issue

diff --git a/lib/cocoa/src/protocol/TBinaryProtocol.m b/lib/cocoa/src/protocol/TBinaryProtocol.m
index e79bd57..d64db26 100644
--- a/lib/cocoa/src/protocol/TBinaryProtocol.m
+++ b/lib/cocoa/src/protocol/TBinaryProtocol.m
@@ -26,8 +26,8 @@ static const uint16_t VERSION_1 = 0x8001;
 union versioned_size {
   int32_t i32;
   struct {
-    uint16_t version;
-    int16_t size;
+      int16_t size;
+      uint16_t version;
   } packed;
 };
 
@@ -394,7 +394,7 @@ static TBinaryProtocolFactory * gSharedFactory = nil;
                         sequenceID: (int) sequenceID
 {
   if (mStrictWrite) {
-    int version = VERSION_1 | messageType;
+    int version = (VERSION_1 << 16) | messageType;
     [self writeI32: version];
     [self writeString: name];
     [self writeI32: sequenceID];

> Integer types issues in Cocoa lib on ARM64
> ------------------------------------------
>
>                 Key: THRIFT-2180
>                 URL: https://issues.apache.org/jira/browse/THRIFT-2180
>             Project: Thrift
>          Issue Type: Bug
>          Components: Cocoa - Library
>    Affects Versions: 0.9.1
>         Environment: ARM64, iOS, xcode5
>            Reporter: Sébastien martini
>
> When compiling the Cocoa library (using the current master) for iOS on ARM64, xcode5 highlights several integer types warnings.
> Several of these instances are originated from the issue that the [NSData length] method returns an NSUInteger which is an unsigned long on ARM64 and is often assigned to an int (int32) in the Cocoa lib.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)