ugorji / go

idiomatic codec and rpc lib for msgpack, cbor, json, etc. msgpack.org[Go]
MIT License
1.85k stars 295 forks source link

Msgpack: Decoding time errors between arm64 and x86 #294

Closed hsanjuan closed 5 years ago

hsanjuan commented 5 years ago

Hello, some of our users are reporting errors when go-godec decodes time objects in arm64 that have been encoding in x86 and vice-versa (https://github.com/ipfs/ipfs-cluster/issues/756#issuecomment-484276008). To my knowledge they are using the exactly the same version of this library.

Is this maybe a bug? Or should we using TimeNotBuitIn ?

ugorji commented 5 years ago

I will be surprised if it is an arm64 vs amd64 issue. The encodings do not care about endianness, and explicitly define that BigEndian is used for the formats.

I think it is probably a difference in libraries, where one is using a recent library with the "corrections" for time.Time handling.

Your options are either to ensure they have the same library, or use TimeNotBuiltIn to explicitly define how you want time.Time to be encoded and decoded. If my call, I would go towards ensuring they have the same libraries versions (e.g. 1.1.4)

ugorji commented 5 years ago

@hsanjuan

I looked through the code, to confirm that we don't depend on endian-ness of the system in any form. These formats are not affected by that either, and the code doesn't depend on it.

Also, from looking at ipfs/ipfs-cluster#756 , it seems that this is a case of different versions of the library, and the accompanying change in time encoding/decoding. To manage that, either enforce same versions of the lib, or use TimeNotBuiltin.

I will close now. Please ping here if you see this different, and I can look again.