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: fillstruct with anonymous structs panics #40980

Closed
leitzler opened this issue Aug 22, 2020 · 2 comments
Closed

x/tools/gopls: fillstruct with anonymous structs panics #40980

leitzler opened this issue Aug 22, 2020 · 2 comments
Labels
Milestone

Comments

@leitzler
Copy link
Contributor

@leitzler leitzler commented Aug 22, 2020

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

$ go version
go version go1.15 darwin/amd64

golang.org/x/tools v0.0.0-20200820180210-c8f393745106
golang.org/x/tools/gopls v0.0.0-20200820180210-c8f393745106

What did you do?

Called fillstruct at foo{} with a struct that contain an anonymous struct as field. Also added maps with anonymous struct and interface values since it behaves the same.

package main

type foo struct {
    a struct{}
    b map[string]interface{}
    c map[string]struct{}
}

func main() {
    _ = foo{}
}

What did you expect to see?

Struct filled.

What did you see instead?

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x13d437a]

goroutine 546 [running]:
golang.org/x/tools/internal/lsp/source.(*Command).SuggestedFix(0x1f03700, 0x1acc060, 0xc000206500, 0x1adc960, 0xc00043ac60, 0x1ad4060, 0xc00011a480, 0x4022000000000000, 0x4020000000000000, 0x4022000000000000, ...)
   /Users/leitzler/go/pkg/mod/golang.org/x/tools@v0.0.0-20200820180210-c8f393745106/internal/lsp/source/command.go:168 +0x1fa
golang.org/x/tools/internal/lsp.(*Server).executeCommand(0xc0000e5340, 0x1acc060, 0xc000206500, 0xc00016ae40, 0x0, 0x0, 0x0, 0x0)
   /Users/leitzler/go/pkg/mod/golang.org/x/tools@v0.0.0-20200820180210-c8f393745106/internal/lsp/command.go:77 +0x17fa
golang.org/x/tools/internal/lsp.(*Server).ExecuteCommand(0xc0000e5340, 0x1acc060, 0xc000206500, 0xc00016ae40, 0xc00016ae40, 0x0, 0x0, 0x0)
   /Users/leitzler/go/pkg/mod/golang.org/x/tools@v0.0.0-20200820180210-c8f393745106/internal/lsp/server_gen.go:80 +0x49
golang.org/x/tools/internal/lsp/protocol.serverDispatch(0x1acc060, 0xc000206500, 0x1adfde0, 0xc0000e5340, 0xc00025d290, 0x1acc2a0, 0xc000206480, 0x1ab99e0, 0xc0002546e0, 0x1acc120)
   /Users/leitzler/go/pkg/mod/golang.org/x/tools@v0.0.0-20200820180210-c8f393745106/internal/lsp/protocol/tsserver.go:388 +0x3872
golang.org/x/tools/internal/lsp/protocol.ServerHandler.func1(0x1acc060, 0xc000206500, 0xc00025d290, 0x1acc2a0, 0xc000206480, 0x1f1f9a0, 0x1aca520)
   /Users/leitzler/go/pkg/mod/golang.org/x/tools@v0.0.0-20200820180210-c8f393745106/internal/lsp/protocol/protocol.go:62 +0xc5
golang.org/x/tools/internal/lsp/lsprpc.handshaker.func1(0x1acc060, 0xc000206500, 0xc00025d290, 0x1acc2a0, 0xc000206480, 0x0, 0x0)
   /Users/leitzler/go/pkg/mod/golang.org/x/tools@v0.0.0-20200820180210-c8f393745106/internal/lsp/lsprpc/lsprpc.go:549 +0x432
golang.org/x/tools/internal/jsonrpc2.MustReplyHandler.func1(0x1acc060, 0xc000206500, 0xc0002ed3a0, 0x1acc2a0, 0xc000206480, 0x17505ae, 0xc000437088)
   /Users/leitzler/go/pkg/mod/golang.org/x/tools@v0.0.0-20200820180210-c8f393745106/internal/jsonrpc2/handler.go:35 +0xcf
golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1.2(0xc00020dbc0, 0xc000445830, 0xc0002cd1f0, 0x1acc060, 0xc000206500, 0xc0002ed3a0, 0x1acc2a0, 0xc000206480)
   /Users/leitzler/go/pkg/mod/golang.org/x/tools@v0.0.0-20200820180210-c8f393745106/internal/jsonrpc2/handler.go:103 +0x86
created by golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1
   /Users/leitzler/go/pkg/mod/golang.org/x/tools@v0.0.0-20200820180210-c8f393745106/internal/jsonrpc2/handler.go:100 +0x173
@gopherbot gopherbot added this to the Unreleased milestone Aug 22, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Aug 22, 2020

Change https://golang.org/cl/249999 mentions this issue: internal/analysisinternal: add anonymous structs & interfaces to

@leitzler
Copy link
Contributor Author

@leitzler leitzler commented Aug 22, 2020

(also see https://go-review.googlesource.com/c/tools/+/249998 that address the panic)

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.