saibing / bingo

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

On create new file, bingo server is crashed #37

Closed marlonfan closed 5 years ago

marlonfan commented 5 years ago

Q

bingo server crashed on create a blank file.

Use IDE:

Crashed log

[Info  - 17:50:20] cached module demo.com/team/project package demo.com/team/project
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=
0x141aae1]

goroutine 2303 [running]:
go/token.(*File).Name(...)
    /usr/local/Cellar/go/1.11.2/libexec/src/go/token/position.go:110
github.com/saibing/bingo/langserver/internal/cache.(*View).parse(0xc000122720, 0xc0130aa420, 0x58, 0x0, 0x0)
    /Users/marlonfan/Dev/code/go/bingo/langserver/internal/cache/view.go:92 +0x281
github.com/saibing/bingo/langserver/internal/cache.(*File).GetPackage(0xc0130996d0, 0x0, 0x0, 0x0)
    /Users/marlonfan/Dev/code/go/bingo/langserver/internal/cache/file.go:106 +0xc1
github.com/saibing/bingo/langserver.diagnostics(0x1604120, 0xc0130996d0, 0xc00004b900, 0x1590a10, 
0xc000465ef0)
    /Users/marlonfan/Dev/code/go/bingo/langserver/diagnostics.go:21 +0x4c
github.com/saibing/bingo/langserver.(*overlay).cacheAndDiagnoseFile.func1(
0xc0130996d0, 0xc0130aa420, 0x58, 0xc000122740, 0x1603ee0, 0xc0000260c0)

/Users/marlonfan/Dev/code/go/bingo/langserver/fs.go:124 +0x4c
created by github.com/saibing/bingo/langserver.(*overlay).cacheAndDiagnoseFile
    /Users/marlonfan/Dev/code/go/bingo/langserver/fs.go:123 +
0x110
[Error  - 17:50:20] Connection to server got closed. Server will not be restarted.
[Error  - 17:50:20] [object Object] exited with code: 2

To Reproduce

  1. create a new file, name is *.go, don't write nothing
  2. will get a server send crashed info
marlonfan commented 5 years ago

i think should be ignore invalid document in here

saibing commented 5 years ago

@marlonfan

thank your reporting.