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: invalid memory address or nil pointer dereference on highlight #68927

Closed
zchee opened this issue Aug 17, 2024 · 3 comments
Closed
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@zchee
Copy link
Contributor

zchee commented Aug 17, 2024

What did you do?

Open following file.

What did you expect to see?

test.go:

package test

func Test(t *testing.T) {
	tests := []struct {
		f func(err error)
	}{
		{
			f: (err error){ },
		},
	}
	_ = tests
}

Error:

[START][2024-08-18 07:24:09] LSP logging initiated
[ERROR][2024-08-18 07:24:09] .../vim/lsp/rpc.lua:772 "rpc" "/Users/zchee/go/bin/gopls" "stderr" "panic: runtime error: invalid memory address or nil pointer dereference\n"
[ERROR][2024-08-18 07:24:09] .../vim/lsp/rpc.lua:772 "rpc" "/Users/zchee/go/bin/gopls" "stderr" "[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x61acd11]\n\ngoroutine 142 gp=0xc000616fc0 m=34 mp=0xc000f42808 [running]:\npanic({0x6677960?, 0x6e4ee40?})\n\truntime/panic.go:804 +0x168 fp=0xc00616cd58 sp=0xc00616cca8 pc=0x58a1c88\nruntime.panicmem()\n\truntime/panic.go:262 +0x3e fp=0xc00616cd78 sp=0xc00616cd58 pc=0x586a69e\nruntime.sigpanic()\n\truntime/signal_unix.go:900 +0x245 fp=0xc00616cda8 sp=0xc00616cd78 pc=0x58a3e85\ngolang.org/x/tools/gopls/internal/golang.highlightIdentifier.func3({0x67b03c8?, 0xc00632b4c0})\n\tgolang.org/x/tools/gopls/internal/golang/highlight.go:563 +0x2b1 fp=0xc00616ce58 sp=0xc00616cda8 pc=0x61acd11\ngo/ast.inspector.Visit(0xc0062b71c0, {0x67b03c8?, 0xc00632b4c0?})\n\tgo/ast/walk.go:361 +0x2b fp=0xc00616ce78 sp=0xc00616ce58 pc=0x5c0344b\ngo/ast.Walk({0x67abe60?, 0xc0062b71c0?}, {0x67b03c8, 0xc00632b4c0})\n\tgo/ast/walk.go:34 +0x4c fp=0xc00616cfe8 sp=0xc00616ce78 pc=0x5bffa0c\ngo/ast.walkList[...](https://.../)\n\tgo/ast/walk.go:21\ngo/ast.Walk({0x67abe60?, 0xc0062b71c0?}, {"

What did you see instead?

Should not panic.

Build info

golang.org/x/tools/gopls v0.1.8-0.20240816163142-66adacf20fc4
    golang.org/x/tools/gopls@v0.1.8-0.20240816163142-66adacf20fc4
    github.com/BurntSushi/toml@v1.2.1
    github.com/google/go-cmp@v0.6.0
    golang.org/x/exp/typeparams@v0.0.0-20221212164502-fae10dda9338
    golang.org/x/mod@v0.20.0
    golang.org/x/sync@v0.8.0
    golang.org/x/telemetry@v0.0.0-20240712210958-268b4a8ec2d7
    golang.org/x/text@v0.17.0
    golang.org/x/tools@v0.21.1-0.20240508182429-e35e4ccd0d2d => ../
    golang.org/x/vuln@v1.0.4
    honnef.co/go/tools@v0.4.7
    mvdan.cc/gofumpt@v0.6.0
    mvdan.cc/xurls/v2@v2.5.0
go: devel go1.24-527610763b Thu Aug 15 23:43:00 2024 +0000 X:arenas,loopvar,cacheprog,newinliner,rangefunc,aliastypeparams,swissmap
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Aug 17, 2024
@gopherbot gopherbot added this to the Unreleased milestone Aug 17, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/606535 mentions this issue: gopls/internal/golang: make sure CompositeLit node is non-nil

@zchee
Copy link
Contributor Author

zchee commented Aug 17, 2024

dups: #68918

Close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants