Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: go mod edit -json panics on empty go.mod file #31623

Closed
fhs opened this issue Apr 23, 2019 · 2 comments

Comments

Projects
None yet
3 participants
@fhs
Copy link
Contributor

commented Apr 23, 2019

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

$ go version
go version devel +f0e9754696 Tue Apr 23 00:58:08 2019 +0000 linux/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
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/fhs/.cache/go-build"
GOENV="/home/fhs/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/fhs/go"
GOPROXY=""
GOROOT="/home/big/go"
GOTMPDIR=""
GOTOOLDIR="/home/big/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build834544503=/tmp/go-build -gno-record-gcc-switches"

What did you do?

mkdir /tmp/test
cd /tmp/test
touch go.mod
go mod edit -json

What did you expect to see?

Not panic

What did you see instead?

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x8c6c82]

goroutine 1 [running]:
cmd/go/internal/modcmd.editPrintJSON(0xc000070360)
	/home/big/go/src/cmd/go/internal/modcmd/edit.go:388 +0x52
cmd/go/internal/modcmd.runEdit(0xe5c960, 0xc0000200f0, 0x0, 0x0)
	/home/big/go/src/cmd/go/internal/modcmd/edit.go:204 +0x530
main.main()
	/home/big/go/src/cmd/go/main.go:188 +0x580

@fhs fhs changed the title cmd/go: go mod edit crashes on empty go.mod file cmd/go: go mod edit panics on empty go.mod file Apr 23, 2019

@agnivade agnivade changed the title cmd/go: go mod edit panics on empty go.mod file cmd/go: go mod edit -json panics on empty go.mod file Apr 23, 2019

@agnivade agnivade added the NeedsFix label Apr 23, 2019

@agnivade agnivade added this to the Go1.13 milestone Apr 23, 2019

@agnivade

This comment has been minimized.

Copy link
Member

commented Apr 23, 2019

Happens with 1.12 also.

@bcmills @jayconrod

@agnivade agnivade added the modules label Apr 23, 2019

@gopherbot

This comment has been minimized.

Copy link

commented Apr 23, 2019

Change https://golang.org/cl/173397 mentions this issue: cmd/go/internal/modcmd: assign module's path and version to fileJSON when modFile's module statement exists

@gopherbot gopherbot closed this in de05071 Apr 24, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.