Skip to content

cmd/go: go tool panic when GOEXPERIMENT=jsonv2 #74862

@bmizerany

Description

@bmizerany

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

$ go version
go version go1.25rc2 darwin/arm64

Does this issue reproduce with the latest release?

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

go env Output
$ go env
AR='ar'
CC='clang'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='clang++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/bmizerany/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/bmizerany/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/db/svmm3t1x3yn4d1skpbq3ddv00000gn/T/go-build3403534159=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/Users/bmizerany/src/foo/go.mod'
GOMODCACHE='/Users/bmizerany/go/pkg/mod'
GONOPROXY='github.com/ollama/*'
GONOSUMDB='github.com/ollama/*'
GOOS='darwin'
GOPATH='/Users/bmizerany/go'
GOPRIVATE='github.com/ollama/*'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/bmizerany/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25rc2.darwin-arm64'
GOSUMDB='sum.golang.org'
GOTELEMETRY='on'
GOTELEMETRYDIR='/Users/bmizerany/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/bmizerany/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25rc2.darwin-arm64/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.25rc2'
GOWORK=''
PKG_CONFIG='pkg-config'
GOROOT/bin/go version: go version go1.25rc2 darwin/arm64
GOROOT/bin/go tool compile -V: compile version go1.25rc2
uname -v: Darwin Kernel Version 24.5.0: Tue Apr 22 19:52:00 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6031
ProductName:		macOS
ProductVersion:		15.5
BuildVersion:		24F74
lldb --version: lldb-1700.0.9.502
Apple Swift version 6.1.2 (swiftlang-6.1.2.1.2 clang-1700.0.13.5)

What did you do?

; go env -w GOEXPERIMENT=jsonv2
; go version

What did you expect to see?

The go version printed to stdout.

What did you see instead?

Given this package:

-- go.mod --
module example

go 1.25rc2
-- example.go --
package main

func main() { println("hello world") }

The panic is reproduced like:

; go env -w GOEXPERIMENT=jsonv2
; go version                        
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x3 pc=0x103246bf0]

goroutine 1 [running]:
cmd/go/internal/fips140.Init()
	cmd/go/internal/fips140/fips140.go:117 +0x120
cmd/go/internal/modload.Init()
	cmd/go/internal/modload/init.go:419 +0x38
cmd/go/internal/toolchain.Exec({0x14000196690, 0x9})
	cmd/go/internal/toolchain/select.go:356 +0x46c
cmd/go/internal/toolchain.Select()
	cmd/go/internal/toolchain/select.go:284 +0xf28
main.main()
	cmd/go/main.go:107 +0x58

NOTE: This also happens for go env, go build, etc..

If I unset the env var (using the toolchain of a previous version of Go), it fixes the issue:

; go1.23.4 env -w GOEXPERIMENT=
; go version
go version go1.25rc2 darwin/arm64

If I move outside of the package directory (say ~), I see, unsurprisingly:

; go version
go: unknown GOEXPERIMENT jsonv2

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions