I filed a bug report https://github.com/google/protobuf/issues/2217.

And it happens on ARM as well. Nexus 6P, Android 7

Regards

On Wednesday, March 11, 2015 at 2:09:30 AM UTC+1, Patrick Linehan wrote:
>
> Nearly 5 years later, I found myself having the same problem. 
>  Perfectly-valid serialized protobufs generated in C++ for message types 
> with no required fields suddenly started throwing 
> "InvalidProtocolBufferException: Message was missing required fields." 
> exceptions in Java.
>
> The problem is, as far as I can tell, a bug in the Dalvik JIT.  I've never 
> seen in in ARM devices, but have seen it in x86 on Android 4.4.4. 
>  Disabling the JIT (setting "android:vmSafeMode" to true in the 
> AndroidManifest.xml) resolves the problem.
>
> It all comes down to a sign extension bug in the following code:
>
>  private byte memoizedIsInitialized = -1;
>     public final boolean isInitialized() {
>       byte isInitialized = memoizedIsInitialized;
>       if (isInitialized != -1) return isInitialized == 1;
>
>       memoizedIsInitialized = 1;
>       return true;
>     }
>
> The value of isInitialized will be implicitly converted to an int (for 
> comparison to -1 and 1) and, in certain cases, won't be sign extended, 
> giving a value of 255.  This in turn causes the function to return false. 
>  This bug appears to be completely random, and doesn't require racing 
> threads.  I don't know if this bug is during the initial store of the field 
> or in the subsequent load, exactly.
>
> A simple workaround is to modify the compiler output to make both 
> memoizedIsInitialized and isInitalized into ints. This avoids any need for 
> casting or sign extension.
>
> On Monday, April 19, 2010 at 10:51:14 AM UTC-7, Kenton Varda wrote:
>>
>> If Henner's answer didn't help, you'll need to provide a small, 
>> self-contained example which reproduces the problem.
>>
>> On Fri, Apr 16, 2010 at 11:05 AM, SyRenity <stas....@gmail.com> wrote:
>>
>>> Hi.
>>>
>>> I'm getting occasionally the following error below in my Java app:
>>>
>>> com.google.protobuf.InvalidProtocolBufferException: Message was
>>> missing required fields.  (Lite runtime could not determine which
>>> fields were missing).
>>>        at
>>>
>>> com.google.protobuf.UninitializedMessageException.asInvalidProtocolBufferException(UninitializedMessageException.java:
>>> 81)
>>>        at classes.cameraInfoProto$camera
>>> $Builder.buildParsed(cameraInfoProto.java:242)
>>>        at classes.cameraInfoProto$camera$Builder.access
>>> $11(cameraInfoProto.java:238)
>>>        at classes.cameraInfoProto
>>> $camera.parseFrom(cameraInfoProto.java:133)
>>>        at app.jSockets.FetcherSockets
>>> $ResponseThread.readMessage(FetcherSockets.java:386)
>>>        at app.jSockets.FetcherSockets
>>> $ResponseThread.run(FetcherSockets.java:268)
>>>
>>>
>>> I double-checked my code, but I have only a single required field, and
>>> I'm always filling it up in the C++ app.
>>>
>>> Any idea how to diagnose it?
>>>
>>> Thanks.
>>>
>>> --
>>> You received this message because you are subscribed to the Google 
>>> Groups "Protocol Buffers" group.
>>> To post to this group, send email to prot...@googlegroups.com.
>>> To unsubscribe from this group, send email to 
>>> protobuf+u...@googlegroups.com.
>>> For more options, visit this group at 
>>> http://groups.google.com/group/protobuf?hl=en.
>>>
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Protocol Buffers" group.
>> To post to this group, send email to prot...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> protobuf+u...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/protobuf?hl=en.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to