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

x/tools/cmd/goimports: panic on usage #39862

Closed
aod opened this issue Jun 25, 2020 · 7 comments
Closed

x/tools/cmd/goimports: panic on usage #39862

aod opened this issue Jun 25, 2020 · 7 comments
Assignees
Labels
Milestone

Comments

@aod
Copy link

@aod aod commented Jun 25, 2020

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

$ go version
go version go1.14.3 linux/amd64

Does this issue reproduce with the latest release?

Not related.

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/oktay/.cache/go-build"
GOENV="/home/oktay/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/oktay/go"
GOPRIVATE=""
GOPROXY="direct"
GOROOT="/usr/lib/golang"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/oktay/Code/elver/go.mod"
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-build278188456=/tmp/go-build -gno-record-gcc-switches"

What did you do?

  1. go get -u golang.org/x/tools/cmd/goimports
  2. goimports

What did you expect to see?

Not a panic.

What did you see instead?

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

goroutine 1 [running]:
main.init.0()
        /home/oktay/go/src/golang.org/x/tools/cmd/goimports/goimports.go:51 +0x85
@gopherbot gopherbot added the Tools label Jun 25, 2020
@gopherbot gopherbot added this to the Unreleased milestone Jun 25, 2020
@annirudh
Copy link

@annirudh annirudh commented Jun 25, 2020

I believe this was introduced by this PR: golang/tools@e31c80b#diff-5e717961381d0f3730aa5f9ee4e11ebc

Env is no longer specified, leading to a panic when trying to parse command line flags.

@imander
Copy link

@imander imander commented Jun 25, 2020

I'm experiencing the same problem

@BentCoder
Copy link

@BentCoder BentCoder commented Jun 25, 2020

go get golang.org/x/tools/cmd/goimports
go: finding golang.org/x/tools latest
goimports -w .
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x11cda35]

goroutine 1 [running]:
flag.newStringValue(...)
	/usr/local/Cellar/go/1.13/libexec/src/flag/flag.go:226
flag.StringVar(...)
	/usr/local/Cellar/go/1.13/libexec/src/flag/flag.go:757
main.init.0()
	/Users/me/Server/Go/pkg/mod/golang.org/x/tools@v0.0.0-20200625173320-e31c80b82c03/cmd/goimports/goimports.go:51 +0x85
make: *** [style] Error 2
@annirudh
Copy link

@annirudh annirudh commented Jun 25, 2020

Here's a PR that fixes the issue: golang/tools#239

@heschik heschik self-assigned this Jun 25, 2020
@ihladush
Copy link

@ihladush ihladush commented Jun 25, 2020

the same problem

@prashant1rana
Copy link

@prashant1rana prashant1rana commented Jun 25, 2020

+1

@heschik
Copy link
Contributor

@heschik heschik commented Jun 25, 2020

Apologies for the breakage, and thanks @annirudh for the diagnosis and fix. The bug is now fixed; module mode users may need to wait ~half an hour for proxy.golang.org to update, or explicitly update to 7480c7b.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
8 participants
You can’t perform that action at this time.