procfs icon indicating copy to clipboard operation
procfs copied to clipboard

TestProcStatLimits: Int overflow on 32 bits arches

Open eclipseo opened this issue 3 years ago • 2 comments

On both i686 and armv7hl, TestProcStatLimits overflows:

# github.com/prometheus/procfs [github.com/prometheus/procfs.test]
./proc_stat_test.go:97:49: cannot use math.MinInt64 (untyped int constant -9223372036854775808) as int value in struct literal (overflows)
./proc_stat_test.go:98:51: cannot use math.MaxInt64 (untyped int constant 9223372036854775807) as int value in struct literal (overflows)

eclipseo avatar Jan 14 '22 17:01 eclipseo

Linking to PR #404 which introduced this regression.

The crux of the issue is that the shipped testdata fixtures will overflow ints in the ProcStat struct on 32-bit archs.

dswarbrick avatar Sep 06 '22 12:09 dswarbrick

In terms of fixing this, we ran into a pretty similar situation before, which I fixed in #314, i.e. split the tests into 32-bit and 64-bit variants, using Go build tags to conditionally perform the right test on the right arch.

I guess it boils down to how imperative it is that we ship testdata fixtures which exercise the full range of machine-native ints / uints.

dswarbrick avatar Sep 06 '22 12:09 dswarbrick