x/tools/go/ssa: commit 75ff53bc introduced a race condition
Go version
go version go1.22.2 linux/arm64
Output of go env in your module/workspace:
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/home/ayke/.cache/go-build'
GOENV='/home/ayke/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/ayke/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/ayke'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go1.22.2'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go1.22.2/pkg/tool/linux_arm64'
GOVCS=''
GOVERSION='go1.22.2'
GCCGO='gccgo'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/ayke/src/tinygo/tinygo/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build553721638=/tmp/go-build -gno-record-gcc-switches'
What did you do?
I upgraded the x/tools package to v0.17.0.
What did you see happen?
Lots of infrequent crashes starting from https://github.com/golang/tools/commit/75ff53bc6b14b0a09f5d4b838ea47ae679d748ba (see https://github.com/tinygo-org/tinygo/issues/4206). The symptoms are all kinds of weird crashes, but in particular what I'm seeing often is functions that appear to be unfinished (no terminator in a basic block).
Interestingly, once I build the program using -race the race condition goes away. This makes it particularly difficult to pinpoint where exactly the bug is located.
I've also tried the master branch (https://github.com/golang/tools/commit/0b45163525d65fb3eda8170c40d6765eb98ddf4d) but sadly it still shows the same crashes.
I can try to work on a standalone reproducer, but with the nature of this crash it's difficult to find one. Still, if it's difficult to find the culprit just from the bisected commit I can try to work on a reproducer.
What did you expect to see?
No race condition.