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/gopls: rename crashes on builtin types #32992

Closed
suzmue opened this issue Jul 8, 2019 · 1 comment
Closed

x/tools/gopls: rename crashes on builtin types #32992

suzmue opened this issue Jul 8, 2019 · 1 comment
Labels
Milestone

Comments

@suzmue
Copy link
Contributor

@suzmue suzmue commented Jul 8, 2019

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

$ go version
go version go1.12.5 darwin/amd64

$ gopls version
golang.org/x/tools/gopls v0.1.1

also reproduces at master:
$ gopls version
golang.org/x/tools/gopls v0.1.1
    golang.org/x/tools/gopls@v0.1.2-0.20190708200955-c93f28baaae0


Does this issue reproduce with the latest release?

Yes. Reproduces at master as well.

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

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/suzmue/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/suzmue/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/suzmue/go/src/golang.org/x/tools/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/q0/0bxb5hrs08l_vhzptkl5gd2400fkl_/T/go-build594969232=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Call rename on "int"

package hello

var x int

What did you expect to see?

An error.

What did you see instead?

gopls crashed with:

[Error - 2:09:07 PM] Request textDocument/rename failed.
Message: method "textDocument/rename" did not reply
Code: -32603
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x14d2cc8]

goroutine 162 [running]:
go/types.(*Package).Name(...)
/usr/local/go/src/go/types/package.go:33
golang.org/x/tools/internal/lsp/source.(*IdentifierInfo).Rename(0xc000420a90, 0x1785220, 0xc0003f1170, 0xc0003e8d7a, 0x3, 0xc000304640, 0x2c34, 0xc000420a90)
/Users/suzmue/go/pkg/mod/golang.org/x/tools@v0.0.0-20190628153133-6cdbf07be9d0/internal/lsp/source/rename.go:49 +0x798
golang.org/x/tools/internal/lsp.(*Server).rename(0xc0001b4900, 0x1785220, 0xc0003f1170, 0xc0003f11a0, 0x0, 0x0, 0xc0003e6460)
/Users/suzmue/go/pkg/mod/golang.org/x/tools@v0.0.0-20190628153133-6cdbf07be9d0/internal/lsp/rename.go:34 +0x292
golang.org/x/tools/internal/lsp.(*Server).Rename(0xc0001b4900, 0x1785220, 0xc0003f1170, 0xc0003f11a0, 0xc0003f11a0, 0x0, 0x0)
/Users/suzmue/go/pkg/mod/golang.org/x/tools@v0.0.0-20190628153133-6cdbf07be9d0/internal/lsp/server.go:241 +0x49
golang.org/x/tools/internal/lsp/protocol.serverHandler.func1(0x1785220, 0xc0003f1170, 0xc0003e4240)
/Users/suzmue/go/pkg/mod/golang.org/x/tools@v0.0.0-20190628153133-6cdbf07be9d0/internal/lsp/protocol/tsserver.go:415 +0x1291
golang.org/x/tools/internal/jsonrpc2.(*Conn).Run.func1(0xc00044a060, 0xc0003e4240, 0xc00020a000, 0x1785220, 0xc0003f1170, 0xc00041e460, 0xc000406750)
/Users/suzmue/go/pkg/mod/golang.org/x/tools@v0.0.0-20190628153133-6cdbf07be9d0/internal/jsonrpc2/jsonrpc2.go:441 +0x117
created by golang.org/x/tools/internal/jsonrpc2.(*Conn).Run
/Users/suzmue/go/pkg/mod/golang.org/x/tools@v0.0.0-20190628153133-6cdbf07be9d0/internal/jsonrpc2/jsonrpc2.go:428 +0x6fc

@gopherbot gopherbot added this to the Unreleased milestone Jul 8, 2019
@gopherbot gopherbot added the gopls label Jul 8, 2019
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Jul 8, 2019

Change https://golang.org/cl/185246 mentions this issue: internal/lsp: return an error when renaming a builtin

movie-travel-code added a commit to movie-travel-code/tools that referenced this issue Jul 11, 2019
Return an error when attempting to rename a builtin identifier.

Fixes golang/go#32992

Change-Id: I7fb0f9cc9499e5afdfb14805c49c820e4da3b601
Reviewed-on: https://go-review.googlesource.com/c/tools/+/185246
Run-TryBot: Suzy Mueller <suzmue@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
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
2 participants
You can’t perform that action at this time.