Skip to content

Runtime Error when receiving textDocument/didChange #76

Open
@michaeljoelphillips

Description

@michaeljoelphillips

Bug Report

Current behavior

Any sketch that I open with the Language Server running fails during textDocument/didChange with the following error in the logs:

# inols-err.log

2021/03/27 20:55:46 IDE --> LS     CL: NOTIFICATION textDocument/didChange:
2021/03/27 20:55:46 IDE --> textDocument/didChange notif3  locked
2021/03/27 20:55:46 --> didChange(file:///home/nomad/Code/arduino/blink/blink.ino@4)
2021/03/27 20:55:46      > <nil> -> "void setup() {\n\tpinMode(12, OUTPUT);\n}\n\nvoid loop() {\n\tdigitalWrite(12, HIGH)\n\tdelay(1000);\n\n\tdigitalWrite(12, LOW);\n\tdelay(1000);\n}\n"
2021/03/27 20:55:46 IDE --> textDocument/didChange notif3  unlocked
2021/03/27 20:55:46 Panic: runtime error: invalid memory address or nil pointer dereference

goroutine 6 [running]:
runtime/debug.Stack(0xa3495f, 0x2, 0xc0003c0990)
    /usr/lib/go/src/runtime/debug/stack.go:24 +0x9f
github.com/arduino/arduino-language-server/streams.CatchAndLogPanic()
    /home/nomad/Code/arduino-language-server/streams/panics.go:14 +0xc7
panic(0x982d40, 0xe06270)
    /usr/lib/go/src/runtime/panic.go:971 +0x499
github.com/arduino/arduino-language-server/handler/textutils.ApplyLSPTextDocumentContentChangeEvent(0xc0000d20c0, 0xc000170500, 0x1, 0x4, 0x4, 0xc000028701, 0x0)
    /home/nomad/Code/arduino-language-server/handler/textutils/textutils.go:13 +0x7c
github.com/arduino/arduino-language-server/handler.(*InoHandler).didChange(0xc0001cf7c0, 0xae9820, 0xc000024108, 0xc0001418c0, 0x2, 0x22, 0xc000504000)
    /home/nomad/Code/arduino-language-server/handler/handler.go:894 +0x12a
github.com/arduino/arduino-language-server/handler.(*InoHandler).HandleMessageFromIDE(0xc0001cf7c0, 0xae9820, 0xc000024108, 0xc0001de900, 0xc000101e50, 0x0, 0x0, 0x0, 0x0)
    /home/nomad/Code/arduino-language-server/handler/handler.go:343 +0x68d
github.com/sourcegraph/jsonrpc2.(*HandlerWithErrorConfigurer).Handle(0xc00020a250, 0xae9820, 0xc000024108, 0xc0001de900, 0xc000101e50)
    /home/nomad/go/pkg/mod/github.com/sourcegraph/[email protected]/handler_with_error.go:21 +0x72
github.com/sourcegraph/jsonrpc2.(*Conn).readMessages(0xc0001de900, 0xae9820, 0xc000024108)
    /home/nomad/go/pkg/mod/github.com/sourcegraph/[email protected]/jsonrpc2.go:522 +0x57e
created by github.com/sourcegraph/jsonrpc2.NewConn
    /home/nomad/go/pkg/mod/github.com/sourcegraph/[email protected]/jsonrpc2.go:334 +0x1d5

textDocument/signatureHelp works fine, however. I have confirmed that the clangd Language Server is working on my system.

Expected behavior

textDocument/didChange should not crash the Language Server.

Environment

  • Language Server version (commit hash): 436276b
  • CLI version used (output of arduino-cli version): arduino-cli alpha Version: 0.17.0-arch Commit: ab58758347e10f22e07154d520d0223612674cab
  • OS and platform: Arch Linux / Arduino Uno

Additional context

My editor is the nightly build of Neovim (v0.5.0-893-ga1a4dd34e).

I have uploaded the server logs to this gist:
https://gist.github.com/michaeljoelphillips/85b51e740d11e0f9f7ce3f7bccf50add

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: imperfectionPerceived defect in any part of project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions