saibing / bingo

Bingo is a Go language server that speaks Language Server Protocol.
MIT License
495 stars 25 forks source link

Panic on hover (non-regular) #100

Closed inliquid closed 5 years ago

inliquid commented 5 years ago

I'm getting this with VS Code, not regularly, and not sure what exactly causes this panic. This happens after some editing.

default

panic serving textDocument/hover: runtime error: invalid memory address or nil pointer dereference
goroutine 3420 [running]:
github.com/saibing/bingo/langserver/internal/util.Panicf(0x917f40, 0xdc9b10, 0x9a7d6b, 0x2, 0xc0004f1510, 0x1, 0x1, 0xc0004f1520, 0x45adb6)
    C:/Users/*******/go/src/github.com/saibing/bingo/langserver/internal/util/util.go:116 +0x9a
github.com/saibing/bingo/langserver.(*LangHandler).Handle.func1(0xc00c15a0f0, 0xc0004f1e60)
    C:/Users/*******/go/src/github.com/saibing/bingo/langserver/handler.go:107 +0xcb
panic(0x917f40, 0xdc9b10)
    C:/Go/src/runtime/panic.go:513 +0x1c7
go/token.(*FileSet).file(0x0, 0x23ee6b, 0x82a23f)
    C:/Go/src/go/token/position.go:437 +0x2d
go/token.(*FileSet).PositionFor(0x0, 0x23ee6b, 0xffffffffffffff01, 0x0, 0x0, 0x0, 0x0, 0x0)
    C:/Go/src/go/token/position.go:477 +0x71
go/token.(*FileSet).Position(0x0, 0x23ee6b, 0x0, 0x0, 0x0, 0x0, 0x0)
    C:/Go/src/go/token/position.go:488 +0x67
github.com/saibing/bingo/langserver/internal/goast.GetPathNodes(0xc00bc1bb30, 0x23ee6b, 0x23ee6b, 0xc00bc1bb30, 0x0, 0x0, 0xa57a00, 0xc00ecb9270)
    C:/Users/*******/go/src/github.com/saibing/bingo/langserver/internal/goast/path_node.go:109 +0xad
github.com/saibing/bingo/langserver/internal/goast.GetObjectPathNode(0xc00ed31d10, 0xa61c20, 0xc00519eaa0, 0x447245, 0xc001ada0f0, 0xc00356a2c0, 0x2c, 0xc001ada0f0, 0xc0004f1948)
    C:/Users/*******/go/src/github.com/saibing/bingo/langserver/internal/goast/path_node.go:141 +0x1cc
github.com/saibing/bingo/langserver.(*LangHandler).findComments(0xc0001bc0c0, 0xc00ed31d10, 0xa61c20, 0xc00519eaa0, 0xc00d1d48c0, 0x9, 0xc0004f19d8, 0x829533, 0xc00ed31d10, 0xc0004f19b0)
    C:/Users/*******/go/src/github.com/saibing/bingo/langserver/hover.go:195 +0x1fe
github.com/saibing/bingo/langserver.(*LangHandler).hoverIdent(0xc0001bc0c0, 0xc00ed31d10, 0xc00ec3c900, 0x9, 0x10, 0xc0006b7dc0, 0x36, 0x14, 0x7f5b5c, 0x0, ...)
    C:/Users/*******/go/src/github.com/saibing/bingo/langserver/hover.go:145 +0x17b
github.com/saibing/bingo/langserver.(*LangHandler).handleHover(0xc0001bc0c0, 0xa5e380, 0xc00edbcc40, 0xa5c8c0, 0xc0001b0200, 0xc00c15a0f0, 0xc009f023c0, 0x5c, 0x36, 0x14, ...)
    C:/Users/*******/go/src/github.com/saibing/bingo/langserver/hover.go:49 +0x2a4
github.com/saibing/bingo/langserver.(*LangHandler).Handle(0xc0001bc0c0, 0xa5e380, 0xc00edbcc40, 0xa5c8c0, 0xc0001b0200, 0xc00c15a0f0, 0x0, 0x0, 0x0, 0x0)
    C:/Users/*******/go/src/github.com/saibing/bingo/langserver/handler.go:224 +0x165e
github.com/saibing/bingo/langserver.(*LangHandler).handle(0xc0001bc0c0, 0xa5e3c0, 0xc00006a0f0, 0xc0001b0200, 0xc00c15a0f0, 0xc00e257780, 0x0, 0xc000374000, 0x0)
    C:/Users/*******/go/src/github.com/saibing/bingo/langserver/handler.go:97 +0x6d
github.com/saibing/bingo/langserver.(*LangHandler).handle-fm(0xa5e3c0, 0xc00006a0f0, 0xc0001b0200, 0xc00c15a0f0, 0xc00041ff28, 0x7add7b08fc84d576, 0x0, 0x0)
    C:/Users/*******/go/src/github.com/saibing/bingo/langserver/handler.go:24 +0x59
github.com/sourcegraph/jsonrpc2.(*HandlerWithErrorConfigurer).Handle(0xc000190140, 0xa5e3c0, 0xc00006a0f0, 0xc0001b0200, 0xc00c15a0f0)
    C:/Users/*******/go/pkg/mod/github.com/sourcegraph/jsonrpc2@v0.0.0-20180831160525-549eb959f029/handler_with_error.go:21 +0x7a
created by github.com/saibing/bingo/langserver.lspHandler.Handle
    C:/Users/*******/go/src/github.com/saibing/bingo/langserver/handler.go:48 +0x102
[Error - 2:43:09] Request textDocument/hover failed.
  Message: unexpected panic: runtime error: invalid memory address or nil pointer dereference
  Code: 0