Skip to content

x/tools/gopls: SIGSEGV when semantic token provider is enabled and typing after return of a void function #65952

Closed
@patrickpichler

Description

@patrickpichler

gopls version

v0.15.0

go env

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/patrickp/Library/Caches/go-build'
GOENV='/Users/patrickp/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/patrickp/.asdf/installs/golang/1.21.6/packages/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/patrickp/.asdf/installs/golang/1.21.6/packages'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/patrickp/.asdf/installs/golang/1.21.6/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/patrickp/.asdf/installs/golang/1.21.6/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.6'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/patrickp/tmp/go-playground/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/cp/jgzd29l5179c6nbllv2dx9dm0000gn/T/go-build4278098802=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

  • Ensure semantic token provider capability is enabled in LSP
  • Create a main.go file with the following content
func main() {
  return
}
  • Position cursor after return and start typing

What did you see happen?

LSP crashes with a SIGSEGV

goroutine 22695 [running]:
golang.org/x/tools/gopls/internal/golang.highlightFuncControlFlow({0x140004a6180, 0x5, 0x9?}, 0x14009dce4b0)
        /Users/patrickp/.asdf/installs/golang/1.21.6/packages/pkg/mod/golang.org/x/tools/gopls@v0.15.0/internal/golang/highlight.go:241 +0x350
golang.org/x/tools/gopls/internal/golang.highlightPath({0x140004a6180, 0x5, 0x8}, 0x140124e71d0?, 0x1400dedd7c0)
        /Users/patrickp/.asdf/installs/golang/1.21.6/packages/pkg/mod/golang.org/x/tools/gopls@v0.15.0/internal/golang/highlight.go:102 +0x274
golang.org/x/tools/gopls/internal/golang.Highlight({0x103726928?, 0x14009d02e10?}, 0x14001865440?, {0x103727be0, 0x14001865440}, {0x2760480?, 0x140?})
        /Users/patrickp/.asdf/installs/golang/1.21.6/packages/pkg/mod/golang.org/x/tools/gopls@v0.15.0/internal/golang/highlight.go:53 +0x208
golang.org/x/tools/gopls/internal/server.(*server).DocumentHighlight(0x14002760480?, {0x103726960, 0x14012c58870}, 0x14009d02bd0)
        /Users/patrickp/.asdf/installs/golang/1.21.6/packages/pkg/mod/golang.org/x/tools/gopls@v0.15.0/internal/server/highlight.go:32 +0x198
golang.org/x/tools/gopls/internal/protocol.serverDispatch({0x103726960, 0x14012c58870}, {0x103737d08, 0x14000f0da00}, 0x14009d02b70, {0x103726b20, 0x1400baf1000})
        /Users/patrickp/.asdf/installs/golang/1.21.6/packages/pkg/mod/golang.org/x/tools/gopls@v0.15.0/internal/protocol/tsserver.go:376 +0x4dd8
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.ServerHandler.func3({0x103726960, 0x14012c58870}, 0x14009d02b70, {0x103726b20, 0x1400baf1000})
        /Users/patrickp/.asdf/installs/golang/1.21.6/packages/pkg/mod/golang.org/x/tools/gopls@v0.15.0/internal/protocol/protocol.go:160 +0x74
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func4({0x103726960, 0x14012c58870}, 0x14009d02b70, {0x103726b20?, 0x1400baf1000?})
        /Users/patrickp/.asdf/installs/golang/1.21.6/packages/pkg/mod/golang.org/x/tools/gopls@v0.15.0/internal/lsprpc/lsprpc.go:509 +0x6d0
golang.org/x/tools/gopls/internal/protocol.Handlers.MustReplyHandler.func1({0x103726960, 0x14012c58870}, 0x1400b345308, {0x103726b20?, 0x1400baf1000?})
        /Users/patrickp/.asdf/installs/golang/1.21.6/packages/pkg/mod/golang.org/x/tools@v0.18.1-0.20240221145400-a220b3b5ba60/internal/jsonrpc2/handler.go:35 +0xdc
golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2.2()
        /Users/patrickp/.asdf/installs/golang/1.21.6/packages/pkg/mod/golang.org/x/tools@v0.18.1-0.20240221145400-a220b3b5ba60/internal/jsonrpc2/handler.go:103 +0x90
created by golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2 in goroutine 92
        /Users/patrickp/.asdf/installs/golang/1.21.6/packages/pkg/mod/golang.org/x/tools@v0.18.1-0.20240221145400-a220b3b5ba60/internal/jsonrpc2/handler.go:100 +0x1d0

What did you expect to see?

LSP not crashing

Editor and settings

No response

Logs

No response

Duplicates:

This stack aeuFyQ was reported by telemetry:

highlightFuncControlFlow:+93 is

for _, field := range funcType.Results.List {
crash/crash
runtime.gopanic:+69
runtime.panicmem:=261
runtime.sigpanic:+19
golang.org/x/tools/gopls/internal/golang.highlightFuncControlFlow:+93
golang.org/x/tools/gopls/internal/golang.highlightPath:+32
golang.org/x/tools/gopls/internal/golang.Highlight:+31
golang.org/x/tools/gopls/internal/server.(*server).DocumentHighlight:+14
golang.org/x/tools/gopls/internal/protocol.serverDispatch:+280
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.ServerHandler.func3:+5
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func4:+52
golang.org/x/tools/gopls/internal/protocol.Handlers.MustReplyHandler.func1:+2
golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2.2:+3
runtime.goexit:+0
golang.org/x/tools/gopls@v0.15.0 devel darwin/arm64 vscode (2)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

Also: oF1UWw

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.gopls/telemetry-wins

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions