Go version
go version go1.24.4 linux/amd64 (doesn't affect 1.23)
Output of go env
in your module/workspace:
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/usr/local/google/home/mpratt/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/usr/local/google/home/mpratt/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1734346257=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/dev/null'
GOMODCACHE='/usr/local/google/home/mpratt/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/usr/local/google/home/mpratt/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/google/home/mpratt/sdk/go1.24.4'
GOSUMDB='sum.golang.org'
GOTELEMETRY='on'
GOTELEMETRYDIR='/usr/local/google/home/mpratt/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/google/home/mpratt/sdk/go1.24.4/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.24.4'
GOWORK=''
PKG_CONFIG='pkg-config'
What did you do?
Attempted to test the new Green Tea GC: https://tip.golang.org/doc/go1.25#new-experimental-garbage-collector
$ GOTOOLCHAIN=go1.25rc1 GOEXPERIMENT=greenteagc go1.24.4 version
What did you see happen?
$ GOTOOLCHAIN=go1.25rc1 GOEXPERIMENT=greenteagc go1.24.4 version
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x3 pc=0x81a081]
goroutine 1 [running]:
cmd/go/internal/fips140.Init()
cmd/go/internal/fips140/fips140.go:117 +0x101
cmd/go/internal/modload.Init()
cmd/go/internal/modload/init.go:419 +0x33
cmd/go/internal/toolchain.Exec({0xc000024114, 0x9})
cmd/go/internal/toolchain/select.go:356 +0x3fc
cmd/go/internal/toolchain.Select()
cmd/go/internal/toolchain/select.go:284 +0x11a5
main.main()
cmd/go/main.go:107 +0x4f
What did you expect to see?
$ GOTOOLCHAIN=go1.25rc1 GOEXPERIMENT=greenteagc go1.24.4 version
go version go1.25rc1 linux/amd64
Comment From: prattmic
The problem is that fips140.Init
looks at cfg.Experiment
without a nil-check. Normally cmd/go main fails if this is nil (because cfg.ExperimentErr
is set), but toolchain selection runs before erroring out (reasonably so, otherwise it wouldn't be possible to pass new GOEXPERIMENTS to the new toolchain version).
I'll send a CL.
Comment From: prattmic
@gopherbot Please backport to 1.24. This is a regression in passing GOEXPERIMENT to another version selected via GOTOOLCHAIN.
Comment From: prattmic
cc @matloob @FiloSottile
Comment From: gopherbot
Backport issue(s) opened: #74113 (for 1.24).
Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.
Comment From: gopherbot
Change https://go.dev/cl/680976 mentions this issue: cmd/go/internal/fips140: ignore GOEXPERIMENT on error
Comment From: gabyhelp
Related Issues
- cmd/go: panic when building a `main` package in GOPATH mode when a go.work file exists #58767 (closed)
- cmd/compile: invalid memory address or nil pointer dereference in gc.convlit1 #35621 (closed)
- cmd/compile: build -gcflags all="-N -l" nil pointer dereference #46386 (closed)
- runtime: AIX build broken with SIGSEGV #70483 (closed)
- gopls SEGV fault on startup. #70271 (closed)
- runtime: `SIGSEGV` via `go test ./...` on Fedora linux/amd64 with go1.19.7 #59372 (closed)
- cmd/go: local failure in TestScript/build_trimpath_cgo #70669 (closed)
- runtime: SIGSEGV: segmentation violation #69247 (closed)
- runtime: cgoCheckPointer fatal error: can't happen #70016 (closed)
- x/tools/go/packages, go/ast: NewPackage causes SIGSEGV #37202 (closed)
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)