Skip to content

cmd/compile: 32-bit random data corruption  #43570

Closed
@erikwilson

Description

@erikwilson

What version of Go are you using (go version)?

$ go version
go version go1.15.6 linux/arm

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="arm"
GOBIN=""
GOCACHE="/home/pi-star/.cache/go-build"
GOENV="/home/pi-star/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="arm"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/pi-star/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/pi-star/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_arm"
GCCGO="gccgo"
GOARM="6"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/pi-star/go/src/github.com/golang/32bit-bug/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -marm -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build227798987=/tmp/go-build -gno-record-gcc-switches"

What did you do?

While running a 32-bit golang executable random data corruption may occur. Here is an example Kubernetes issue which is able to reproduce the problem with 32-bit arm and 386:
kubernetes/kubernetes#97685

The unit test is compiled and attached as a standalone example here:
32bit-bug.tar.gz

Test code, commands, armv6 binaries, and relevant objdump data is available in above tarball.

If the test is compiled without optimizations the test will pass (on arm at least).

(edit: remove link to aarch64 issue)

What did you expect to see?

$ ./passing-arm32-test 
PASS

What did you see instead?

$ ./failing-arm32-test 
--- FAIL: TestSampler (1.06s)
    sample_and_watermark_test.go:48: t0=2021-01-07 11:24:28.746138334 -0700 MST m=+0.016036811
panic: that was a bad year!: 0011-12-20 14:41:53.017034732 -0728 LMT [recovered]
	panic: that was a bad year!: 0011-12-20 14:41:53.017034732 -0728 LMT

goroutine 19 [running]:
testing.tRunner.func1.1(0x374e38, 0x122d068)
	/usr/local/go/src/testing/testing.go:1072 +0x264
testing.tRunner.func1(0x1082380)
	/usr/local/go/src/testing/testing.go:1075 +0x364
panic(0x374e38, 0x122d068)
	/usr/local/go/src/runtime/panic.go:969 +0x158
github.com/golang/32bit-bug.(*sampleAndWaterMarkObserverGenerator).quantize(0x10a6150, 0x103edec, 0x103ed78, 0x14a13f43, 0x0, 0x654a80, 0x80c40200, 0x434e01)
	/home/pi-star/go/src/github.com/golang/32bit-bug/sample_and_watermark.go:99 +0x164
github.com/golang/32bit-bug.(*sampleAndWaterMarkHistograms).innerSet.func1(0x10b8080, 0x103edec, 0x103edd0, 0x103ee00, 0x103edc4, 0x103ee48)
	/home/pi-star/go/src/github.com/golang/32bit-bug/sample_and_watermark.go:175 +0xb4
github.com/golang/32bit-bug.(*sampleAndWaterMarkHistograms).innerSet(0x10b8080, 0x103ee48)
	/home/pi-star/go/src/github.com/golang/32bit-bug/sample_and_watermark.go:204 +0x70
github.com/golang/32bit-bug.(*sampleAndWaterMarkHistograms).Set(0x10b8080, 0x0, 0x3ff00000)
	/home/pi-star/go/src/github.com/golang/32bit-bug/sample_and_watermark.go:155 +0x54
github.com/golang/32bit-bug.TestSampler(0x1082380)
	/home/pi-star/go/src/github.com/golang/32bit-bug/sample_and_watermark_test.go:57 +0x454
testing.tRunner(0x1082380, 0x3ea0c4)
	/usr/local/go/src/testing/testing.go:1123 +0xbc
created by testing.(*T).Run
	/usr/local/go/src/testing/testing.go:1168 +0x220

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions