What version of Go are you using (go version
)?
$ go version go version go1.21.0 windows/amd64
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 set GO111MODULE=on set GOARCH=amd64 set GOBIN= set GOCACHE=C:\Users\Andrew\AppData\Local\go-build set GOENV=C:\Users\Andrew\AppData\Roaming\go\env set GOEXE=.exe set GOEXPERIMENT= set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOINSECURE= set GOMODCACHE=C:\Users\Andrew\go\pkg\mod set GONOPROXY= set GONOSUMDB= set GOOS=windows set GOPATH=C:\Users\Andrew\go set GOPRIVATE= set GOPROXY=https://proxy.golang.org set GOROOT=C:/Users/Andrew/go/go1.21.0 set GOSUMDB=sum.golang.org set GOTMPDIR= set GOTOOLCHAIN=auto set GOTOOLDIR=C:\Users\Andrew\go\go1.21.0\pkg\tool\windows_amd64 set GOVCS= set GOVERSION=go1.21.0 set GCCGO=gccgo set GOAMD64=v1 set AR=ar set CC=gcc set CXX=g++ set CGO_ENABLED=1 set GOMOD=NUL set GOWORK= set CGO_CFLAGS=-O2 -g set CGO_CPPFLAGS= set CGO_CXXFLAGS=-O2 -g set CGO_FFLAGS=-O2 -g set CGO_LDFLAGS=-O2 -g set PKG_CONFIG=pkg-config set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\Andrew\AppData\Local\Temp\go-build1748980101=/tmp/go-build -gno-record-gcc-switches
What did you do?
https://go.dev/play/p/k6MIftXQ3q7
//go:debug panicnil=1
//go:debug panicnil=1
package main
func main() {
}
What did you expect to see?
Build or compiler error message.
What did you see instead?
panic: runtime error: invalid memory address or nil pointer dereference [signal 0xc0000005 code=0x1 addr=0x20 pc=0x7ab2f7]
goroutine 36 [running]: bytes.(Buffer).Write(0xc00019a0d0?, {0xc000132120?, 0x38?, 0xc0001891f8?}) bytes/buffer.go:176 +0x17 fmt.Fprintf({0xe22e80, 0x0}, {0xd3c601, 0x38}, {0xc0001891f8, 0x3, 0x3}) fmt/print.go:225 +0x97 cmd/go/internal/work.(Builder).checkDirectives(0xc0000e2000, 0x497d5c6d09af60fa?) cmd/go/internal/work/exec.go:978 +0x4ed cmd/go/internal/work.(Builder).build(0xc0000e2000, {0xe28230?, 0x11f3e40?}, 0xc0003cde40) cmd/go/internal/work/exec.go:536 +0x71d cmd/go/internal/work.ActorFunc.Act(0xe28230?, 0x11f3e40?, {0xe28230?, 0x11f3e40?}, 0x7c206e6977726164?) cmd/go/internal/work/action.go:78 +0x2d cmd/go/internal/work.(Builder).Do.func3({0xe28230, 0x11f3e40}, 0xc0003cde40) cmd/go/internal/work/exec.go:151 +0x7e4 cmd/go/internal/work.(Builder).Do.func4() cmd/go/internal/work/exec.go:219 +0xa8 created by cmd/go/internal/work.(Builder).Do in goroutine 1 cmd/go/internal/work/exec.go:205 +0x405
Comment From: gopherbot
Change https://go.dev/cl/523836 mentions this issue: cmd/go/internal/work: avoid panic for a repeated //go:debug setting