Closed
Description
What version of Go are you using (go version
)?
$ go version go version go1.12.6 linux/amd64 $ gopls version golang.org/x/tools/gopls v0.1.1 golang.org/x/tools/gopls@v0.1.2-0.20190706070813-72ffa07ba3db h1:jEzcdhR4g/qmRjnefU4bjKYInYeXwZRsQqqcnUrVSxk=
Does this issue reproduce with the latest release?
Of gopls, yes
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GOARCH="amd64" GOBIN="" GOCACHE="/home/mmacnair/.cache/go-build" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home/mmacnair/go" GOPROXY="" GORACE="" GOROOT="/snap/go/3947" GOTMPDIR="" GOTOOLDIR="/snap/go/3947/pkg/tool/linux_amd64" GCCGO="gccgo" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/home/mmacnair/pkg/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-build501054748=/tmp/go-build -gno-record-gcc-switches"
What did you do?
Tried to rename a type defined at package level
What did you expect to see?
The type and all references to it be renamed
What did you see instead?
No changes, and a crash:
[Error - 11:44:32 AM] 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=0x40 pc=0x8d92b9]
goroutine 3907 [running]:
golang.org/x/tools/internal/lsp/source.(*renamer).checkInPackageBlock(0xc0005acc60, 0xb9a8a0, 0xc005fe2af0)
/home/mmacnair/go/pkg/mod/golang.org/x/tools@v0.0.0-20190706070813-72ffa07ba3db/internal/lsp/source/rename_check.go:116 +0xf9
golang.org/x/tools/internal/lsp/source.(*renamer).check(0xc0005acc60, 0xb9a8a0, 0xc005fe2af0)
/home/mmacnair/go/pkg/mod/golang.org/x/tools@v0.0.0-20190706070813-72ffa07ba3db/internal/lsp/source/rename_check.go:42 +0x39c
golang.org/x/tools/internal/lsp/source.(*IdentifierInfo).Rename(0xc004182410, 0xb8f900, 0xc0061f8de0, 0xc0057928a4, 0x4, 0x0, 0x0, 0x0)
/home/mmacnair/go/pkg/mod/golang.org/x/tools@v0.0.0-20190706070813-72ffa07ba3db/internal/lsp/source/rename.go:76 +0x70b
golang.org/x/tools/internal/lsp.(*Server).rename(0xc000136d20, 0xb8f900, 0xc0061f8de0, 0xc0061f8e10, 0x0, 0x0, 0xc000542140)
/home/mmacnair/go/pkg/mod/golang.org/x/tools@v0.0.0-20190706070813-72ffa07ba3db/internal/lsp/rename.go:34 +0x295
golang.org/x/tools/internal/lsp.(*Server).Rename(0xc000136d20, 0xb8f900, 0xc0061f8de0, 0xc0061f8e10, 0xc0061f8e10, 0x0, 0x0)
/home/mmacnair/go/pkg/mod/golang.org/x/tools@v0.0.0-20190706070813-72ffa07ba3db/internal/lsp/server.go:244 +0x49
golang.org/x/tools/internal/lsp/protocol.serverHandler.func1(0xb8f900, 0xc0061f8de0, 0xc0060bd5c0)
/home/mmacnair/go/pkg/mod/golang.org/x/tools@v0.0.0-20190706070813-72ffa07ba3db/internal/lsp/protocol/tsserver.go:415 +0x1291
golang.org/x/tools/internal/jsonrpc2.(*Conn).Run.func1(0xc00002acc0, 0xc0060bd5c0, 0xc00016e3f0, 0xb8f900, 0xc0061f8de0, 0xc00600a960, 0xc000b029f0)
/home/mmacnair/go/pkg/mod/golang.org/x/tools@v0.0.0-20190706070813-72ffa07ba3db/internal/jsonrpc2/jsonrpc2.go:441 +0x117
created by golang.org/x/tools/internal/jsonrpc2.(*Conn).Run
/home/mmacnair/go/pkg/mod/golang.org/x/tools@v0.0.0-20190706070813-72ffa07ba3db/internal/jsonrpc2/jsonrpc2.go:428 +0x6fc
Unfortunately the code isn't public and I don't have a minimal reproducer. I did do a quick test of adding a new package level type and variable definition, that weren't used anywhere else, and got the same result for each of them - the stack trace ends on the same line.
If this isn't enough info to diagnose, feel free to close it. I'm sure someone else will hit this at some point with an open source project!
Metadata
Metadata
Assignees
Type
Projects
Relationships
Development
No branches or pull requests
Activity
suzmue commentedon Jul 8, 2019
@mykter Are both the use and the type definition in the same package? Could you also post the line declaring the package level type and a variable definition? Thanks!
suzmue commentedon Jul 9, 2019
Do you have any test files? If so, https://go-review.googlesource.com/c/tools/+/185277 should fix it.
The following produces a similar trace:
Rename x
hello.go
hello_test.go
error:
mykter commentedon Jul 9, 2019
I do have tests for that package, yes - looks like you've found it!
Thanks.
[-]x/tools/cmd/gopls: Crash on rename[/-][+]x/tools/cmd/gopls: nil pointer on rename[/+][-]x/tools/cmd/gopls: nil pointer on rename[/-][+]x/tools/gopls: nil pointer on rename[/+]gopherbot commentedon Jul 9, 2019
Change https://golang.org/cl/185277 mentions this issue:
internal/lsp: rename identifiers in test packages
internal/lsp: rename identifiers in test packages