Cross compiling for GOARCH=arm int overflow

following issues when compiling for 32 bit arch:

../../go/pkg/mod/github.com/dgraph-io/ristretto@v0.0.4-0.20201007164332-9739cfa2564b/z/buffer.go:73:35: constant 274877906944 overflows int
../../go/pkg/mod/github.com/dgraph-io/badger/v2@v2.0.1-rc1.0.20201007220711-3b5f17cee813/y/bloom.go:122:35: constant 3332679571 overflows int

First i fixed with math.MaxInt32 (Uint32 also overflowed).

We use the constant 256<<30 to initialize the buffer size in ristretto.

In Go, the size of int defaults to the word size of a machine. So on a 32 bit ARM machine, int would be 32 bits. It’s clear that 256 <<30 overflows that.

The fix should be architecture specific files containing architecture specific constants. So, this is a bug. I’m filing as a bug.

Tagging @martinmr

Related Issues (Badger): Fix badger builds on 32 bit machines

Any news on this issue?

Hey @maddie, we haven’t started working on this. This looks like a simple fix. Feel free to send a PR for it.

@maddie This issue has been resolved now.
See https://github.com/dgraph-io/ristretto/pull/238 and https://github.com/dgraph-io/badger/pull/1627
Thanks @jawr for reporting.