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

[BUG] - Go test fails due to int overflows on 32 bits arches #147

Open
eclipseo opened this issue May 30, 2021 · 1 comment
Open

[BUG] - Go test fails due to int overflows on 32 bits arches #147

eclipseo opened this issue May 30, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@eclipseo
Copy link

While running the tests on 32 bits arches such at armv!7hl and i686, the following errors occur:

Testing    in: /builddir/build/BUILD/govultr-2.5.1/_build/src
         PATH: /builddir/build/BUILD/govultr-2.5.1/_build/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin
       GOPATH: /builddir/build/BUILD/govultr-2.5.1/_build:/usr/share/gocode
  GO111MODULE: off
      command: go test -buildmode pie -compiler gc -ldflags " -X github.com/vultr/govultr/v2/version=2.5.1 -extldflags '-Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld  '"
      testing: github.com/vultr/govultr/v2
github.com/vultr/govultr/v2
# github.com/vultr/govultr/v2 [github.com/vultr/govultr/v2.test]
./backup_test.go:50:4: constant 42949672960 overflows int
./backup_test.go:145:3: constant 42949672960 overflows int
./bare_metal_server_test.go:65:3: constant 2199756823533 overflows int
./bare_metal_server_test.go:306:4: constant 2199756823533 overflows int
./snapshot_test.go:33:3: constant 42949672960 overflows int
./snapshot_test.go:62:3: constant 42949672960 overflows int
./snapshot_test.go:91:3: constant 42949672960 overflows int
./snapshot_test.go:136:4: constant 42949672960 overflows int
FAIL	github.com/vultr/govultr/v2 [build failed]
@eclipseo eclipseo added the bug Something isn't working label May 30, 2021
@dswarbrick
Copy link

The overflows in backup_test.go and snapshot_test.go are fairly self-explanatory, as the Backup and Snapshot structs use an untyped int for the Size member. This should be changed to an int64, or even better, uint64 if there is no need to hold "magic" negative values.

The bare_metal_test.go is a bit more of an odd one. The Go struct is using an untyped int to hold a MAC address, as the Vultr API apparently returns it as such, e.g. "mac_address": 2199756823533. Since ethernet MAC addresses are 48-bit, and most of them will have bits set in the "high" bytes, I would expect a very large majority of MAC addresses to overflow a 32-bit int.

A custom JSON unmarshaller would handle this more elegantly, and unmarshal the address into a Go https://pkg.go.dev/net#HardwareAddr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants