Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeserializeBinary() issue : Deserializing Signed vs Unsigned Array #6473

Closed
ahumay opened this issue Aug 3, 2019 · 1 comment
Closed

DeserializeBinary() issue : Deserializing Signed vs Unsigned Array #6473

ahumay opened this issue Aug 3, 2019 · 1 comment

Comments

@ahumay
Copy link

ahumay commented Aug 3, 2019

Version: master/v3.6.0/v3.5.0 etc.
Language: Java/Javascript
MacOS 10.14.6
protoc gcc compiler

** Main Issue **
I am creating a Proto message in Java/Kotlin and sending it to a NodeJS server.
Right before being sent from Java, I see the message payload ArrayBuffer is viewed/sent as signed (Int8Array).
Right after being received in Node, I view the message ArrayBuffer and see that it is saved as unsigned (Uint8Array).
The two's complement conversion from signed to unsigned is done correctly, so the underlying ArrayBuffer has the same bits stored on both Java and Node. Same length too.
However, running DeserializeBinary() in Node on the Uint8Array gives me a AssertionError: Assertion failed ... at Function.proto.myproject.schema.MyMessageType.deserializeBinary error.
When I run DeserializeBinary() in Java with the same Uint8Array as I received in Node, it works completely fine.
How can DeserializeBinary() fail when parsing the exact same bits? The only difference is one is being run in Java and one is being run in Node. The fact that one is viewed as signed and one is viewed as unsigned shouldn't change anything right?

Obviously DeserializeBinary() won't accept it if I just pass in the Int8Array.

**Additional context: **
Also, with some tweaks in Node I get AssertionError: Failure: Decoder hit an error error instead of the generic one. Not sure if that is significant. I just don't use Buffer.concat() before passing to DeserializeBinary().

When creating/sending the Proto message from Objective-C, the ArrayBuffer is sent as unsigned.
Running DeserializeBinary() in Node on this ArrayBuffer gives no errors and works perfectly.

The only issue is when sending from Java to NodeJS, and the only difference between that and the Objective-C scenario is that the bits are viewed in different ways. But the actual bits are not different.

@ahumay
Copy link
Author

ahumay commented Aug 5, 2019

I believe this issue stems from the known issue in #1701

@ahumay ahumay closed this as completed Aug 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant