Skip to content
This repository was archived by the owner on Oct 22, 2021. It is now read-only.
This repository was archived by the owner on Oct 22, 2021. It is now read-only.

Language Server crashes after upload on Arduino Zero #428

Closed
arduino/arduino-language-server
#62
@rsora

Description

@rsora

Describe the bug
When I open the IDE, After installing the Arduino SAMD Boards and connecting an Arduino Zero (Native Port) I open a Blink example.
Then I Click on the upload/arrow button and the upload goes fine but the Language Server crashes showing a popup in the bottom right corner.
Here the panic swhown by the LS logs

fatal error: sync: Unlock of unlocked RWMutex
goroutine 7 [running]:
runtime.throw(0xae9c5f, 0x20)
	C:/hostedtoolcache/windows/go/1.13.15/x64/src/runtime/panic.go:774 +0x79 fp=0xc00023d2e0 sp=0xc00023d2b0 pc=0x430f19
sync.throw(0xae9c5f, 0x20)
	C:/hostedtoolcache/windows/go/1.13.15/x64/src/runtime/panic.go:760 +0x3c fp=0xc00023d300 sp=0xc00023d2e0 pc=0x430e8c
sync.(*RWMutex).Unlock(0xc000131930)
	C:/hostedtoolcache/windows/go/1.13.15/x64/src/sync/rwmutex.go:129 +0xc6 fp=0xc00023d338 sp=0xc00023d300 pc=0x47c046
sync.(*Cond).Wait(0xc0001e2240)
	C:/hostedtoolcache/windows/go/1.13.15/x64/src/sync/cond.go:55 +0x8e fp=0xc00023d370 sp=0xc00023d338 pc=0x47894e
github.com/bcmi-labs/arduino-language-server/handler.(*InoHandler).waitClangdStart(0xc000131900, 0xc000207760, 0x13)
	D:/a/arduino-language-server/arduino-language-server/handler/handler.go:102 +0xfb fp=0xc00023d3d0 sp=0xc00023d370 pc=0x94943b
github.com/bcmi-labs/arduino-language-server/handler.(*InoHandler).HandleMessageFromIDE(0xc000131900, 0xbb3aa0, 0xc00001e198, 0xc0001807e0, 0xc000228050, 0x0, 0x0, 0x0, 0x0)
	D:/a/arduino-language-server/arduino-language-server/handler/handler.go:194 +0x402b fp=0xc00023dd60 sp=0xc00023d3d0 pc=0x94da9b
github.com/bcmi-labs/arduino-language-server/handler.(*InoHandler).HandleMessageFromIDE-fm(0xbb3aa0, 0xc00001e198, 0xc0001807e0, 0xc000228050, 0xa73720, 0xc00027a040, 0xc00004ec60, 0xa0bca0)
	D:/a/arduino-language-server/arduino-language-server/handler/handler.go:149 +0x59 fp=0xc00023ddb8 sp=0xc00023dd60 pc=0x95ed09
github.com/sourcegraph/jsonrpc2.(*HandlerWithErrorConfigurer).Handle(0xc000186160, 0xbb3aa0, 0xc00001e198, 0xc0001807e0, 0xc000228050)
	C:/Users/runneradmin/go/pkg/mod/github.com/sourcegraph/jsonrpc2@v0.0.0-20200429184054-15c2290dcb37/handler_with_error.go:21 +0x7a fp=0xc00023de60 sp=0xc00023ddb8 pc=0x91ef0a
github.com/sourcegraph/jsonrpc2.(*Conn).readMessages(0xc0001807e0, 0xbb3aa0, 0xc00001e198)
	C:/Users/runneradmin/go/pkg/mod/github.com/sourcegraph/jsonrpc2@v0.0.0-20200429184054-15c2290dcb37/jsonrpc2.go:522 +0x571 fp=0xc00023dfc8 sp=0xc00023de60 pc=0x921f11
runtime.goexit()
	C:/hostedtoolcache/windows/go/1.13.15/x64/src/runtime/asm_amd64.s:1357 +0x1 fp=0xc00023dfd0 sp=0xc00023dfc8 pc=0x45bef1
created by github.com/sourcegraph/jsonrpc2.NewConn
	C:/Users/runneradmin/go/pkg/mod/github.com/sourcegraph/jsonrpc2@v0.0.0-20200429184054-15c2290dcb37/jsonrpc2.go:334 +0x1e0
goroutine 1 [chan receive]:
main.main()
	D:/a/arduino-language-server/arduino-language-server/main.go:57 +0x65f
goroutine 6 [syscall]:
os/signal.signal_recv(0x0)
	C:/hostedtoolcache/windows/go/1.13.15/x64/src/runtime/sigqueue.go:147 +0xa3
os/signal.loop()
	C:/hostedtoolcache/windows/go/1.13.15/x64/src/os/signal/signal_unix.go:23 +0x29
created by os/signal.init.0
	C:/hostedtoolcache/windows/go/1.13.15/x64/src/os/signal/signal_unix.go:29 +0x48
goroutine 8 [sync.Cond.Wait]:
runtime.goparkunlock(...)
	C:/hostedtoolcache/windows/go/1.13.15/x64/src/runtime/proc.go:310
sync.runtime_notifyListWait(0xc0001e2310, 0x0)
	C:/hostedtoolcache/windows/go/1.13.15/x64/src/runtime/sema.go:510 +0x106
sync.(*Cond).Wait(0xc0001e2300)
	C:/hostedtoolcache/windows/go/1.13.15/x64/src/sync/cond.go:56 +0xa4
github.com/bcmi-labs/arduino-language-server/handler.(*ProgressProxyHandler).handlerLoop(0xc0001e4140)
	D:/a/arduino-language-server/arduino-language-server/handler/progress.go:55 +0x209
created by github.com/bcmi-labs/arduino-language-server/handler.NewProgressProxy
	D:/a/arduino-language-server/arduino-language-server/handler/progress.go:44 +0xcc
goroutine 9 [sleep]:
runtime.goparkunlock(...)
	C:/hostedtoolcache/windows/go/1.13.15/x64/src/runtime/proc.go:310
time.Sleep(0x5f5e100)
	C:/hostedtoolcache/windows/go/1.13.15/x64/src/runtime/time.go:105 +0x16c
github.com/bcmi-labs/arduino-language-server/handler.(*InoHandler).rebuildEnvironmentLoop(0xc000131900)
	D:/a/arduino-language-server/arduino-language-server/handler/builder.go:40 +0x97
created by github.com/bcmi-labs/arduino-language-server/handler.NewInoHandler
	D:/a/arduino-language-server/arduino-language-server/handler/handler.go:129 +0x326
goroutine 18 [runnable]:
github.com/bcmi-labs/arduino-language-server/handler.(*InoHandler).HandleMessageFromIDE.func1(0xc000131900, 0xbb3aa0, 0xc00001e198, 0xc000230000)
	D:/a/arduino-language-server/arduino-language-server/handler/handler.go:209
created by github.com/bcmi-labs/arduino-language-server/handler.(*InoHandler).HandleMessageFromIDE
	D:/a/arduino-language-server/arduino-language-server/handler/handler.go:209 +0x2ee6
[Info  - 11:38:10 AM] Connection to server got closed. Server will restart.
[Error - 11:38:10 AM] Request textDocument/codeAction failed.
Error: Connection got disposed.
    at Object.dispose (C:\Users\Arduino\Desktop\IDE2\arduino-pro-ide_0.1.4-snapshot.3042c1a_Windows_64bit\resources\app\plugins\vscode-arduino-language-server\extension\dist\bundle.js:5369:25)
    at Object.dispose (C:\Users\Arduino\Desktop\IDE2\arduino-pro-ide_0.1.4-snapshot.3042c1a_Windows_64bit\resources\app\plugins\vscode-arduino-language-server\extension\dist\bundle.js:6492:35)
    at LanguageClient.handleConnectionClosed (C:\Users\Arduino\Desktop\IDE2\arduino-pro-ide_0.1.4-snapshot.3042c1a_Windows_64bit\resources\app\plugins\vscode-arduino-language-server\extension\dist\bundle.js:8727:42)
    at LanguageClient.handleConnectionClosed (C:\Users\Arduino\Desktop\IDE2\arduino-pro-ide_0.1.4-snapshot.3042c1a_Windows_64bit\resources\app\plugins\vscode-arduino-language-server\extension\dist\bundle.js:10066:15)
    at closeHandler (C:\Users\Arduino\Desktop\IDE2\arduino-pro-ide_0.1.4-snapshot.3042c1a_Windows_64bit\resources\app\plugins\vscode-arduino-language-server\extension\dist\bundle.js:8714:18)
    at CallbackList.invoke (C:\Users\Arduino\Desktop\IDE2\arduino-pro-ide_0.1.4-snapshot.3042c1a_Windows_64bit\resources\app\plugins\vscode-arduino-language-server\extension\dist\bundle.js:4046:39)
    at Emitter.fire (C:\Users\Arduino\Desktop\IDE2\arduino-pro-ide_0.1.4-snapshot.3042c1a_Windows_64bit\resources\app\plugins\vscode-arduino-language-server\extension\dist\bundle.js:4105:36)
    at closeHandler (C:\Users\Arduino\Desktop\IDE2\arduino-pro-ide_0.1.4-snapshot.3042c1a_Windows_64bit\resources\app\plugins\vscode-arduino-language-server\extension\dist\bundle.js:4705:26)
    at CallbackList.invoke (C:\Users\Arduino\Desktop\IDE2\arduino-pro-ide_0.1.4-snapshot.3042c1a_Windows_64bit\resources\app\plugins\vscode-arduino-language-server\extension\dist\bundle.js:4046:39)
    at Emitter.fire (C:\Users\Arduino\Desktop\IDE2\arduino-pro-ide_0.1.4-snapshot.3042c1a_Windows_64bit\resources\app\plugins\vscode-arduino-language-server\extension\dist\bundle.js:4105:36)
2021/02/09 11:38:11 logging to c:\Users\Arduino\AppData\Local\Temp\.arduinoProIDE-unsaved202119-2612-hr9fz.s83fnm\Blink\inols-err.log
2021/02/09 11:38:11 logging to c:\Users\Arduino\AppData\Local\Temp\.arduinoProIDE-unsaved202119-2612-hr9fz.s83fnm\Blink\inols.log
2021/02/09 11:38:11 Initial board configuration: {"Arduino Zero (Native USB Port)" arduino:samd:arduino_zero_native}
2021/02/09 11:38:11 [92mIDE --> LS     CL: REQUEST initialize 0[0m
2021/02/09 11:38:11 IDE --> initialize 0 [93m locked[0m
2021/02/09 11:38:11 IDE --> initialize 0 [93m unlocked[0m
2021/02/09 11:38:11 [91mIDE <-- LS     CL: ANSWER UNBOUND (0)[0m
2021/02/09 11:38:11 INIT--- initializing workbench
2021/02/09 11:38:11 INIT--- [93m locked[0m
2021/02/09 11:38:11     --> initialize(file:///c%3A/Users/Arduino/AppData/Local/Temp/.arduinoProIDE-unsaved202119-2612-hr9fz.s83fnm/Blink)
2021/02/09 11:38:11 running:  c:\Users\Arduino\Desktop\IDE2\arduino-pro-ide_0.1.4-snapshot.3042c1a_Windows_64bit\resources\app\node_modules\arduino-ide-extension\build\arduino-cli.exe compile --fqbn arduino:samd:arduino_zero_native --only-compilation-database --clean --source-override C:\Users\Arduino\AppData\Local\Temp\124657455 --format json C:\Users\Arduino\AppData\Local\Temp\.arduinoProIDE-unsaved202119-2612-hr9fz.s83fnm\Blink
2021/02/09 11:38:11 [92mIDE --> LS     CL: NOTIFICATION initialized[0m
2021/02/09 11:38:11 [92mIDE     LS <-- CL: NOTIFICATION $/progress[0m
2021/02/09 11:38:11 CLG <-- $/progress notif10 (done)
2021/02/09 11:38:13 arduino-cli output: {
  "compiler_out": "",
  "compiler_err": "",
  "builder_result": {
    "build_path": "C:\\Users\\Arduino\\AppData\\Local\\Temp\\arduino-sketch-669C438ACCA105656BD4929E458C24FF"
  },
  "success": true
}

After this the Language Server restarts itself.

image

To Reproduce
Steps to reproduce the behavior:

  1. Install Arduino SAMD boards
  2. Connect and select an Arduino Zero in the Board Selector
  3. File > Examples > Basics > Blink
  4. Click Upload Button

Expected behavior
The LS does not crash

Desktop (please complete the following information):
OS: Win 10 Pro
Version: 0.1.4-snapshot.3042c1a
Date: 2021-02-08T10:04:20.854Z
CLI Version: 0.15.1 alpha [c7403ed2]

cc @cmaglie, being a panic generated by the LS

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions