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
Labels
FrozenDueToAge Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@aod
Copy link

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 This label describes issues relating to any tools in the x/tools repository. label Jun 25, 2020
@gopherbot gopherbot added this to the Unreleased milestone Jun 25, 2020
@annirudh
Copy link

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 commented Jun 25, 2020

I'm experiencing the same problem

@bentcoder
Copy link

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

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

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

the same problem

@prashant1rana
Copy link

+1

@heschi
Copy link
Contributor

heschi 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.

@heschi heschi closed this as completed Jun 25, 2020
@golang golang locked and limited conversation to collaborators Jun 25, 2021
@rsc rsc unassigned heschi Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

8 participants