-
Notifications
You must be signed in to change notification settings - Fork 18k
encoding/gob: Platform-dependent int/uint size not decoding/transmitting correctly data when GOARCH mismatched #53366
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
Comments
The spec gives well defined overflow behaviour, it roll over following two's complement modulus arithmetic. 4294967295+21 = 20 is correct because there is an implicit modulus 2 power 32 (or 64 on 64bits arch) on all 32 bits operations. The spec also allows ints and uints to vary in size. This code does exactly what it is supposed to do. You should use uint64, safe math or big math librairies. |
This has nothing to do with gob, unsigned ints are defined to wrap when they overflow. closing as there is no bug |
@seankhliao @Jorropo |
@AlekseiLevykh it isn't a secure remote execution context. The remote server can answer with whatever it wants anyway.
I disagree, you should use Here it seems you care about the size, just use I would agree that a linter warning about using |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?I'm using Microsoft Windows WSL2/Ubuntu
go env
OutputWhat did you do?
Examples:
Server GOARCH=386
Client GOARCH=amd64
What did you expect to see?
4294967295+21=4294967316
Or overflow/out-of-range error
What did you see instead?
4294967295+21=20
The text was updated successfully, but these errors were encountered: