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: nil pointer in LookupBuiltin #36975

Closed
bearmingo opened this issue Feb 2, 2020 · 5 comments
Closed

x/tools/gopls: nil pointer in LookupBuiltin #36975

bearmingo opened this issue Feb 2, 2020 · 5 comments
Labels
Milestone

Comments

@bearmingo
Copy link

@bearmingo bearmingo commented Feb 2, 2020

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

go version go1.13.7 darwin/amd64

Does this issue reproduce with the latest release?

Yes

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

O111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/xxxxx/Library/Caches/go-build"
GOENV="/Users/xxxxx/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/xxxxx/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.13.7/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.13.7/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/xxxx/Work/Projects/sport-service-golang/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/5_/v16pjnbx43g1j0z61f5h2z5w0000gn/T/go-build931873177=/tmp/go-build -gno-record-gcc-switches -fno-commo

What did you do?

When coding in VSCode, gopls crash repeatly
[Trace - 13:26:20.641 PM] Sending request 'textDocument/completion - (75)'.
Params: {"textDocument":{"uri":"file:///Users/xxxxx/Work/Projects/xxxxxxxxx/app/social/handlers/conversation.go"},"position":{"line":54,"character":3},"context":{"triggerKind":1}}

[Error - 13:26:20.655 PM] Received #75 method "textDocument/completion" did not reply

[Error - 1:26:20 PM] Request textDocument/completion failed.
Message: method "textDocument/completion" did not reply
Code: -32603
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1714c6f]

goroutine 7804 [running]:
golang.org/x/tools/internal/lsp/cache.(*view).LookupBuiltin(0xc00036c000, 0x1a550e0, 0xc001cfc8d0, 0x18f67d7, 0x4, 0x0, 0x0, 0x0)
/Users/xxxxxxx/go/pkg/mod/golang.org/x/tools@v0.0.0-20200130224948-02f1738cbe39/internal/lsp/cache/view.go:209 +0x4f
golang.org/x/tools/internal/lsp/source.(*completer).formatBuiltin(0xc003304000, 0x1a68fc0, 0xc0000c4eb0, 0x3fed871fe1a40385, 0x18f67d7, 0x4, 0x0, 0x0, 0x0, 0x0, ...)
/Users/xxxxxxx/go/pkg/mod/golang.org/x/tools@v0.0.0-20200130224948-02f1738cbe39/internal/lsp/source/completion_format.go:247 +0x2a5
golang.org/x/tools/internal/lsp/source.(*completer).item(0xc003304000, 0x1a68fc0, 0xc0000c4eb0, 0x3fed871fe1a40385, 0x18f67d7, 0x4, 0x0, 0x0, 0x0, 0x0, ...)
/Users/xxxxxxx/go/pkg/mod/golang.org/x/tools@v0.0.0-20200130224948-02f1738cbe39/internal/lsp/source/completion_format.go:32 +0x187f
golang.org/x/tools/internal/lsp/source.(*completer).found(0xc003304000, 0x1a68fc0, 0xc0000c4eb0, 0x3fed871fe1a40385, 0x18f67d7, 0x4, 0x0, 0x0)
/Users/xxxxxxx/go/pkg/mod/golang.org/x/tools@v0.0.0-20200130224948-02f1738cbe39/internal/lsp/source/completion.go:352 +0x2c4
golang.org/x/tools/internal/lsp/source.(*completer).lexical(0xc003304000, 0x0, 0x0)
/Users/xxxxxxx/go/pkg/mod/golang.org/x/tools@v0.0.0-20200130224948-02f1738cbe39/internal/lsp/source/completion.go:873 +0x72a
golang.org/x/tools/internal/lsp/source.Completion(0x1a550e0, 0xc001cfc8d0, 0x1a651a0, 0xc001a5b200, 0x1a53120, 0xc001a5b1a0, 0x404b000000000000, 0x4008000000000000, 0x0, 0x0, ...)
/Users/xxxxxxx/go/pkg/mod/golang.org/x/tools@v0.0.0-20200130224948-02f1738cbe39/internal/lsp/source/completion.go:536 +0xc3a
golang.org/x/tools/internal/lsp.(*Server).completion(0xc000229e30, 0x1a550e0, 0xc000c18930, 0xc002f04840, 0x0, 0x0, 0xc00df33970)
/Users/xxxxxxx/go/pkg/mod/golang.org/x/tools@v0.0.0-20200130224948-02f1738cbe39/internal/lsp/completion.go:34 +0x744
golang.org/x/tools/internal/lsp.(*Server).Completion(0xc000229e30, 0x1a550e0, 0xc000c18930, 0xc002f04840, 0xc002f04840, 0x0, 0x0)
/Users/xxxxxxx/go/pkg/mod/golang.org/x/tools@v0.0.0-20200130224948-02f1738cbe39/internal/lsp/server_gen.go:24 +0x49
golang.org/x/tools/internal/lsp/protocol.serverHandler.Deliver(0x1a730e0, 0xc000229e30, 0x1a550e0, 0xc000c18930, 0xc002007440, 0xc000c18900, 0xc00189cb90)
/Users/xxxxxxx/go/pkg/mod/golang.org/x/tools@v0.0.0-20200130224948-02f1738cbe39/internal/lsp/protocol/tsserver.go:345 +0x241c
golang.org/x/tools/internal/jsonrpc2.(*Conn).Run.func1(0xc00bf8a240, 0xc002007440, 0xc000287800, 0x1a550e0, 0xc000c18930, 0x0, 0x0, 0xc004dbec50)
/Users/xxxxxxx/go/pkg/mod/golang.org/x/tools@v0.0.0-20200130224948-02f1738cbe39/internal/jsonrpc2/jsonrpc2.go:370 +0x170
created by golang.org/x/tools/internal/jsonrpc2.(*Conn).Run
/Users/xxxxxxx/go/pkg/mod/golang.org/x/tools@v0.0.0-20200130224948-02f1738cbe39/internal/jsonrpc2/jsonrpc2.go:354 +0x877
[Error - 1:26:20 PM] Connection to server got closed. Server will not be restarted.

What did you expect to see?

What did you see instead?

@gopherbot gopherbot added this to the Unreleased milestone Feb 2, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Feb 2, 2020

Thank you for filing a gopls issue! Please take a look at the Troubleshooting guide, and make sure that you have provided all of the relevant information here.

@bearmingo bearmingo changed the title x/tools/gopls: <fill this in> x/tools/gopls: Crash When coding Feb 2, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Feb 2, 2020

Change https://golang.org/cl/217399 mentions this issue: internal/lsp: return error if there is no builtin package

@stamblerre stamblerre changed the title x/tools/gopls: Crash When coding x/tools/gopls: nil pointer in LookupBuiltin Feb 2, 2020
@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.3.1 Feb 2, 2020
@bearmingo
Copy link
Author

@bearmingo bearmingo commented Feb 3, 2020

After install gopls from master branch(https://go.googlesource.com/tools), this issue is gone

@gopherbot
Copy link

@gopherbot gopherbot commented Feb 4, 2020

Change https://golang.org/cl/217638 mentions this issue: internal/lsp: return error if there is no builtin package

gopherbot pushed a commit to golang/tools that referenced this issue Feb 4, 2020
When we stopped returning an error from awaitInitialized, we didn't
handle this case in LookupBuiltin.

Fixes golang/go#36975.

Change-Id: I9668a7148f60ca1f9cad953d46caf6ec5500541e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/217399
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
(cherry picked from commit 2de6fe5)
Reviewed-on: https://go-review.googlesource.com/c/tools/+/217638
Reviewed-by: Heschi Kreinick <heschi@google.com>
@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Feb 4, 2020

This has been cherry-picked onto gopls-release-branch.0.3 and will be in gopls/v0.3.1.

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
3 participants
You can’t perform that action at this time.