Closed lggomez closed 5 years ago
You said you cannot come up with a reproducible test case.
Can you share the output when you run bingo
with -trace
enabled?
I'm seeing some of these as well - I'm looking through the trace output here now and my findings are:
The first occurence of the false posistive happens after a save after editing for a while:
--> notif: textDocument/didSave: {"textDocument":{"uri":"file:///Users/REDACTED/myapp/moderate/service_test.go","version":524}}
<-- notif: textDocument/publishDiagnostics: {"uri":"file:///Users/REDACTED/myapp/moderate/service_test.go","diagnostics":[{"range":{"start":{"line":103,"character":27},"end":{"line":103,"character":27}},"severity":1,"source":"LSP: Go compiler","message":"cannot use (func(topicID myapp.TopicID, postID myapp.PostID) (*myapp.Post, error) literal) (value of type func(topicID gitlab.com/REDACTED/myapp.TopicID, postID gitlab.com/REDACTED/myapp.PostID) (*gitlab.com/REDACTED/myapp.Post, error)) as func(topicID gitlab.com/REDACTED/myapp.TopicID, id gitlab.com/REDACTED/myapp.PostID) (*gitlab.com/REDACTED/myapp.Post, error) value in assignment"},{"range":{"start":{"line":108,"character":29},"end":{"line":108,"character":29}},"severity":1,"source":"LSP: Go compiler","message":"cannot use (func(_ *myapp.Post) error literal) (value of type func(_ *gitlab.com/REDACTED/myapp.Post) error) as func(in1 *gitlab.com/REDACTED/myapp.Post) error value in assignment"},{"range":{"start":{"line":44,"character":34},"end":{"line":44,"character":34}},"severity":1,"source":"LSP: Go compiler","message":"cannot use (func(topicID myapp.TopicID, postID myapp.PostID) error literal) (value of type func(topicID gitlab.com/REDACTED/myapp.TopicID, postID gitlab.com/REDACTED/myapp.PostID) error) as func(topicID gitlab.com/REDACTED/myapp.TopicID, postID gitlab.com/REDACTED/myapp.PostID) error value in assignment"}]}
After this starts occuring I start seeing some panics in my logs - but it happens quite a lot later so I don't know if they are neccessarily related:
--> notif: textDocument/didChange: {"textDocument":{"uri":"file:///Users/REDACTED/myapp/write/service.go","version":4},"contentChanges":[{"range":{"start":{"line":0,"character":2},"end":{"line":0,"character":2}},"rangeLength":0,"text":"c"}]}
invalid position for file
panic serving textDocument/completion: runtime error: invalid memory address or nil pointer dereference
goroutine 6388 [running]:
github.com/saibing/bingo/langserver/internal/util.Panicf(0x451f8e0, 0x49eae00, 0x45b080c, 0x2, 0xc007e1b7f8, 0x1, 0x1, 0xc007e1b808, 0x405ba66)
/opt/bingo/359e4f9a910dd1949e4419d41d39ba9057fc675c/langserver/internal/util/util.go:116 +0x93
github.com/saibing/bingo/langserver.(*LangHandler).Handle.func1(0xc00a4359a0, 0xc007e1be60)
/opt/bingo/359e4f9a910dd1949e4419d41d39ba9057fc675c/langserver/handler.go:110 +0xc4
panic(0x451f8e0, 0x49eae00)
/usr/local/Cellar/go/1.11.5/libexec/src/runtime/panic.go:513 +0x1b9
go/token.(*File).Size(...)
/usr/local/Cellar/go/1.11.5/libexec/src/go/token/position.go:120
github.com/saibing/bingo/langserver.lineStart(0x0, 0x1, 0xc0165ebce0)
/opt/bingo/359e4f9a910dd1949e4419d41d39ba9057fc675c/langserver/position.go:76 +0x37
github.com/saibing/bingo/langserver.fromProtocolPosition(0x0, 0x0, 0x2, 0xc01133c4c0)
/opt/bingo/359e4f9a910dd1949e4419d41d39ba9057fc675c/langserver/position.go:49 +0x38
github.com/saibing/bingo/langserver.(*LangHandler).handleTextDocumentCompletion(0xc0000e2420, 0x4668e20, 0xc0146267c0, 0x4667220, 0xc00012a500, 0xc00a4359a0, 0xc01133c480, 0x39, 0x0, 0x2, ...)
/opt/bingo/359e4f9a910dd1949e4419d41d39ba9057fc675c/langserver/completion.go:34 +0x10a
github.com/saibing/bingo/langserver.(*LangHandler).Handle(0xc0000e2420, 0x4668e20, 0xc0146267c0, 0x4667220, 0xc00012a500, 0xc00a4359a0, 0x0, 0x0, 0x0, 0x0)
/opt/bingo/359e4f9a910dd1949e4419d41d39ba9057fc675c/langserver/handler.go:268 +0x267a
github.com/saibing/bingo/langserver.(*LangHandler).handle(0xc0000e2420, 0x4668e60, 0xc0000ac008, 0xc00012a500, 0xc00a4359a0, 0xc013cf2540, 0x3a, 0x0, 0x0)
/opt/bingo/359e4f9a910dd1949e4419d41d39ba9057fc675c/langserver/handler.go:100 +0x66
github.com/saibing/bingo/langserver.(*LangHandler).handle-fm(0x4668e60, 0xc0000ac008, 0xc00012a500, 0xc00a4359a0, 0x0, 0x0, 0x0, 0x0)
/opt/bingo/359e4f9a910dd1949e4419d41d39ba9057fc675c/langserver/handler.go:26 +0x52
github.com/sourcegraph/jsonrpc2.(*HandlerWithErrorConfigurer).Handle(0xc0000a33d0, 0x4668e60, 0xc0000ac008, 0xc00012a500, 0xc00a4359a0)
/Users/REDACTED/go/pkg/mod/github.com/sourcegraph/jsonrpc2@v0.0.0-20180831160525-549eb959f029/handler_with_error.go:21 +0x73
created by github.com/saibing/bingo/langserver.lspHandler.Handle
/opt/bingo/359e4f9a910dd1949e4419d41d39ba9057fc675c/langserver/handler.go:50 +0xfb
<-- error #420: textDocument/completion: {"code":0,"message":"unexpected panic: runtime error: invalid memory address or nil pointer dereference","data":null}
[Error - 2:59:13 PM] Request textDocument/completion failed.
Message: unexpected panic: runtime error: invalid memory address or nil pointer dereference
Code: 0
I've tried anonymizing the output here a little bit, hopefully I haven't done anything that removes any important information from it. As mentiond by @lggomez the project builds successfully and restarting VSCode (and thus Bingo) solves the problem for a little while.
It's quite reproducible for me, happening 5-10 times per day. Is there any info I could provide to help pinpoint the issue?
Thanks.
I just updated to the recent master
version and I'm still seeing the same issue. For me it seems to be quite consistently croaking when passing around mocks to functions requiring interfaces; for example:
app.MyInterface
interface, and a mocks.MyInterfaceMock
mock generated via moqapp.NewMyService
func that takes in an instance of app.MyInterface
mocks.MyInterfaceMock
and pass it to the app.NewMyService
functionThis seems to start creating the issue more or less the first time I save a file as it is now.
It, however, does not seem to happen if I run bingo with -cache-style=none
; might this be some cache corruption issue of some sort?
@tanordheim yeah, this is pretty much my case
I notice similar issues when working with mocks. I will try to put together a full reproduction test case in a repository to demonstrate the issue. If anyone has already done so, please share it.
I am using https://github.com/mockery/mockery.
It seems that the latest version from master
has fixed this issue!
Can someone confirm this, or am I seeing things? :)
I don't think I've seen it since updating 5 days ago either; however, I've been working on a different project for the last few days with a different code structure (no generated mocks, which have been a source of problems before) so I can't fully say which one is the source of things working better. I'm moving back to that other project that were causing issues multiple times a day for me later this week, I can report back if I see any there.
Yup, I see it in my other project as well with the same problems.
I'm seeing this in some projects here still, after upgrading to the latest commit in master as of 24 hours ago. I'm struggling to reproduce it in a small self contained project I could give as a reproduction, but I'm happy to offer any information you'd need and test any work in progress changes with one of our code bases here where it happens quite regularly.
Still having this problem:
@saibing
I've made a lot of changes in this branch https://github.com/banaio/bingo/tree/fix_issues_with_textDocument/publishDiagnostics but I believe the core fix is in either or both of the below:
instant
or onsave
.The rest of the changes are just refactoring. The entire diff of the branch is https://github.com/saibing/bingo/compare/master...banaio:fix_issues_with_textDocument/publishDiagnostics. I've tried to make the commits atomic so you can see changes incrementally. The tests do not pass hence the commit message saying it is a breaking change, run gotest -count=1 -v -json ./...
to see where it gets stuck.
Also, I don't know if this makes a difference but I run a build with race detector enabled:
$ go build -o $GOPATH/bin/bingo_dev -race
If anyone wants to try the branch and report back that'd be great.
Edit:
h.diagnosetics(ctx, f)
, i.e., don't do go h.diagnosetics(ctx, f)
. Actually the errors disappear after some time but (not 100% certain) after I open the file that it says is in error.lspHandler.Handle
, i.e., without the go routine the tests get stuck:// Handle implements jsonrpc2.Handler
func (h lspHandler) Handle(ctx context.Context, conn *jsonrpc2.Conn, req *jsonrpc2.Request) {
// if isFileSystemRequest(req.Method) {
// h.Handler.Handle(ctx, conn, req)
// return
// }
go h.Handler.Handle(ctx, conn, req) // tests don't get stuck
// h.Handler.Handle(ctx, conn, req) // tests get stuck
}
Unfortunately I couldn't come up with a simple repro, this happens at work (VS Code):
This builds successfully from console