Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OTP26][Windows] 0.15.1 crash or hang on start #927

Closed
princemaple opened this issue Jun 30, 2023 · 14 comments
Closed

[OTP26][Windows] 0.15.1 crash or hang on start #927

princemaple opened this issue Jun 30, 2023 · 14 comments

Comments

@princemaple
Copy link
Contributor

Environment

  • Elixir & Erlang versions (elixir --version): elixir 1.15.0-otp-26, erlang otp 26.0.2
  • Elixir Language Server version: 0.15.1
  • Operating system: win11
  • Editor or IDE name (e.g. Emacs/VSCode): Sublime
  • Editor Plugin/LSP Client name and version: LSP, LSP-elixir

Current behavior

Crash after

:: [13:39:35.001] --> lsp-elixir initialize (1): {'rootUri': 'file:///C:/Users/chenp/code/REDACTED', 'workspaceFolders': [{'uri': 'file:///C:/Users/chenp/code/REDACTED', 'name': 'REDACTED'}], 'processId': 44792, 'rootPath': 'C:\\Users\\chenp\\code\\REDACTED', 'clientInfo': {'version': '1.24.0', 'name': 'Sublime Text LSP'}, 'initializationOptions': {}, 'capabilities': {'workspace': {'workspaceEdit': {'failureHandling': 'abort', 'documentChanges': True}, 'didChangeConfiguration': {'dynamicRegistration': True}, 'codeLens': {'refreshSupport': True}, 'semanticTokens': {'refreshSupport': True}, 'inlayHint': {'refreshSupport': True}, 'workspaceFolders': True, 'diagnostics': {'refreshSupport': True}, 'executeCommand': {}, 'applyEdit': True, 'configuration': True, 'symbol': {'symbolKind': {'valueSet': [20, 6, 3, 1, 22, 12, 10, 13, 17, 24, 25, 23, 26, 18, 19, 2, 5, 15, 7, 8, 4, 11, 16, 9, 14, 21]}, 'dynamicRegistration': True, 'tagSupport': {'valueSet': [1]}}}, 'textDocument': {'declaration': {'dynamicRegistration': True, 'linkSupport': True}, 'rangeFormatting': {'dynamicRegistration': True}, 'rename': {'prepareSupport': True, 'dynamicRegistration': True, 'prepareSupportDefaultBehavior': 1}, 'implementation': {'dynamicRegistration': True, 'linkSupport': True}, 'synchronization': {'dynamicRegistration': True, 'willSave': True, 'willSaveWaitUntil': True, 'didSave': True}, 'diagnostic': {'dynamicRegistration': True, 'relatedDocumentSupport': True}, 'colorProvider': {'dynamicRegistration': True}, 'codeLens': {'dynamicRegistration': True}, 'publishDiagnostics': {'dataSupport': True, 'relatedInformation': True, 'versionSupport': True, 'codeDescriptionSupport': True, 'tagSupport': {'valueSet': [1, 2]}}, 'documentHighlight': {'dynamicRegistration': True}, 'selectionRange': {'dynamicRegistration': True}, 'definition': {'dynamicRegistration': True, 'linkSupport': True}, 'codeAction': {'dataSupport': True, 'dynamicRegistration': True, 'isPreferredSupport': True, 'resolveSupport': {'properties': ['edit']}, 'codeActionLiteralSupport': {'codeActionKind': {'valueSet': ['quickfix', 'refactor', 'refactor.extract', 'refactor.inline', 'refactor.rewrite', 'source.fixAll', 'source.organizeImports']}}}, 'documentSymbol': {'symbolKind': {'valueSet': [20, 6, 3, 1, 22, 12, 10, 13, 17, 24, 25, 23, 26, 18, 19, 2, 5, 15, 7, 8, 4, 11, 16, 9, 14, 21]}, 'dynamicRegistration': True, 'hierarchicalDocumentSymbolSupport': True, 'tagSupport': {'valueSet': [1]}}, 'typeDefinition': {'dynamicRegistration': True, 'linkSupport': True}, 'formatting': {'dynamicRegistration': True}, 'inlayHint': {'dynamicRegistration': True, 'resolveSupport': {'properties': ['textEdits', 'label.command']}}, 'signatureHelp': {'dynamicRegistration': True, 'contextSupport': True, 'signatureInformation': {'parameterInformation': {'labelOffsetSupport': True}, 'activeParameterSupport': True, 'documentationFormat': ['markdown', 'plaintext']}}, 'completion': {'dynamicRegistration': True, 'completionItemKind': {'valueSet': [19, 15, 18, 2, 17, 20, 3, 1, 13, 14, 23, 24, 22, 25, 9, 7, 12, 10, 5, 8, 4, 16, 6, 21, 11]}, 'completionList': {'itemDefaults': ['editRange', 'insertTextFormat', 'data']}, 'completionItem': {'snippetSupport': True, 'insertTextModeSupport': {'valueSet': [2]}, 'resolveSupport': {'properties': ['detail', 'documentation', 'additionalTextEdits']}, 'labelDetailsSupport': True, 'documentationFormat': ['markdown', 'plaintext'], 'deprecatedSupport': True, 'insertReplaceSupport': True, 'tagSupport': {'valueSet': [1]}}, 'insertTextMode': 2}, 'typeHierarchy': {'dynamicRegistration': True}, 'documentLink': {'dynamicRegistration': True, 'tooltipSupport': True}, 'semanticTokens': {'formats': ['relative'], 'multilineTokenSupport': True, 'tokenTypes': ['modifier', 'method', 'namespace', 'typeParameter', 'enumMember', 'function', 'enum', 'variable', 'event', 'property', 'decorator', 'operator', 'struct', 'comment', 'type', 'class', 'string', 'macro', 'interface', 'number', 'keyword', 'regexp', 'parameter'], 'dynamicRegistration': True, 'augmentsSyntaxTokens': True, 'overlappingTokenSupport': False, 'tokenModifiers': ['modification', 'declaration', 'async', 'static', 'abstract', 'readonly', 'definition', 'documentation', 'deprecated', 'defaultLibrary'], 'requests': {'range': True, 'full': {'delta': True}}}, 'callHierarchy': {'dynamicRegistration': True}, 'references': {'dynamicRegistration': True}, 'hover': {'dynamicRegistration': True, 'contentFormat': ['markdown', 'plaintext']}}, 'general': {'markdown': {'version': '3.2.2', 'parser': 'Python-Markdown'}, 'regularExpressions': {'engine': 'ECMAScript'}}, 'window': {'workDoneProgress': True, 'showDocument': {'support': True}, 'showMessage': {'messageActionItem': {'additionalPropertiesSupport': True}}}}}
lsp-elixir: Installing ElixirLS release v0.15.1
lsp-elixir: Running in c:/Users/chenp/code/REDACTED
lsp-elixir: Install complete

Crash dump is uploaded

Expected behavior

After resetting back to otp 25.3 and elixir 1.15.0-otp-25, it runs without problems

:: [13:46:41.563] --> lsp-elixir initialize (1): {'capabilities': {'window': {'showMessage': {'messageActionItem': {'additionalPropertiesSupport': True}}, 'showDocument': {'support': True}, 'workDoneProgress': True}, 'general': {'markdown': {'parser': 'Python-Markdown', 'version': '3.2.2'}, 'regularExpressions': {'engine': 'ECMAScript'}}, 'textDocument': {'codeLens': {'dynamicRegistration': True}, 'formatting': {'dynamicRegistration': True}, 'hover': {'contentFormat': ['markdown', 'plaintext'], 'dynamicRegistration': True}, 'rename': {'prepareSupportDefaultBehavior': 1, 'dynamicRegistration': True, 'prepareSupport': True}, 'diagnostic': {'relatedDocumentSupport': True, 'dynamicRegistration': True}, 'inlayHint': {'resolveSupport': {'properties': ['textEdits', 'label.command']}, 'dynamicRegistration': True}, 'semanticTokens': {'requests': {'full': {'delta': True}, 'range': True}, 'tokenModifiers': ['deprecated', 'abstract', 'modification', 'documentation', 'declaration', 'defaultLibrary', 'definition', 'async', 'static', 'readonly'], 'augmentsSyntaxTokens': True, 'formats': ['relative'], 'multilineTokenSupport': True, 'overlappingTokenSupport': False, 'dynamicRegistration': True, 'tokenTypes': ['enumMember', 'modifier', 'namespace', 'parameter', 'enum', 'macro', 'regexp', 'decorator', 'number', 'comment', 'event', 'string', 'class', 'typeParameter', 'operator', 'property', 'method', 'variable', 'struct', 'function', 'interface', 'keyword', 'type']}, 'signatureHelp': {'contextSupport': True, 'signatureInformation': {'activeParameterSupport': True, 'parameterInformation': {'labelOffsetSupport': True}, 'documentationFormat': ['markdown', 'plaintext']}, 'dynamicRegistration': True}, 'rangeFormatting': {'dynamicRegistration': True}, 'codeAction': {'codeActionLiteralSupport': {'codeActionKind': {'valueSet': ['quickfix', 'refactor', 'refactor.extract', 'refactor.inline', 'refactor.rewrite', 'source.fixAll', 'source.organizeImports']}}, 'resolveSupport': {'properties': ['edit']}, 'isPreferredSupport': True, 'dynamicRegistration': True, 'dataSupport': True}, 'documentLink': {'tooltipSupport': True, 'dynamicRegistration': True}, 'synchronization': {'willSave': True, 'willSaveWaitUntil': True, 'didSave': True, 'dynamicRegistration': True}, 'completion': {'completionItem': {'resolveSupport': {'properties': ['detail', 'documentation', 'additionalTextEdits']}, 'insertTextModeSupport': {'valueSet': [2]}, 'documentationFormat': ['markdown', 'plaintext'], 'labelDetailsSupport': True, 'tagSupport': {'valueSet': [1]}, 'deprecatedSupport': True, 'snippetSupport': True, 'insertReplaceSupport': True}, 'completionList': {'itemDefaults': ['editRange', 'insertTextFormat', 'data']}, 'completionItemKind': {'valueSet': [20, 1, 16, 18, 13, 11, 12, 5, 17, 4, 21, 19, 23, 7, 25, 24, 10, 2, 15, 6, 9, 22, 3, 8, 14]}, 'insertTextMode': 2, 'dynamicRegistration': True}, 'selectionRange': {'dynamicRegistration': True}, 'documentHighlight': {'dynamicRegistration': True}, 'typeDefinition': {'linkSupport': True, 'dynamicRegistration': True}, 'declaration': {'linkSupport': True, 'dynamicRegistration': True}, 'references': {'dynamicRegistration': True}, 'callHierarchy': {'dynamicRegistration': True}, 'publishDiagnostics': {'tagSupport': {'valueSet': [2, 1]}, 'versionSupport': True, 'dataSupport': True, 'relatedInformation': True, 'codeDescriptionSupport': True}, 'definition': {'linkSupport': True, 'dynamicRegistration': True}, 'typeHierarchy': {'dynamicRegistration': True}, 'implementation': {'linkSupport': True, 'dynamicRegistration': True}, 'documentSymbol': {'tagSupport': {'valueSet': [1]}, 'hierarchicalDocumentSymbolSupport': True, 'dynamicRegistration': True, 'symbolKind': {'valueSet': [22, 6, 3, 10, 17, 8, 1, 9, 21, 4, 14, 24, 15, 18, 5, 26, 25, 7, 16, 13, 2, 23, 12, 19, 11, 20]}}, 'colorProvider': {'dynamicRegistration': True}}, 'workspace': {'symbol': {'tagSupport': {'valueSet': [1]}, 'dynamicRegistration': True, 'symbolKind': {'valueSet': [22, 6, 3, 10, 17, 8, 1, 9, 21, 4, 14, 24, 15, 18, 5, 26, 25, 7, 16, 13, 2, 23, 12, 19, 11, 20]}}, 'configuration': True, 'semanticTokens': {'refreshSupport': True}, 'applyEdit': True, 'executeCommand': {}, 'didChangeConfiguration': {'dynamicRegistration': True}, 'workspaceEdit': {'documentChanges': True, 'failureHandling': 'abort'}, 'workspaceFolders': True, 'diagnostics': {'refreshSupport': True}, 'inlayHint': {'refreshSupport': True}, 'codeLens': {'refreshSupport': True}}}, 'initializationOptions': {}, 'rootUri': 'file:///C:/Users/chenp/code/REDACTED', 'workspaceFolders': [{'name': 'REDACTED', 'uri': 'file:///C:/Users/chenp/code/REDACTED'}], 'processId': 46016, 'clientInfo': {'name': 'Sublime Text LSP', 'version': '1.24.0'}, 'rootPath': 'C:\\Users\\chenp\\code\\REDACTED'}
lsp-elixir: Installing ElixirLS release v0.15.1
lsp-elixir: Running in c:/Users/chenp/code/REDACTED
lsp-elixir: Install complete
lsp-elixir: Started ElixirLS v0.15.1
:: [13:46:44.099] <-  lsp-elixir window/logMessage: {'type': 3, 'message': 'Started ElixirLS v0.15.1'}
lsp-elixir: Running in c:/Users/chenp/code/REDACTED
:: [13:46:44.099] <-  lsp-elixir window/logMessage: {'type': 3, 'message': 'Running in c:/Users/chenp/code/REDACTED'}
lsp-elixir: ElixirLS built with elixir "1.15.0" on OTP "25"
:: [13:46:44.102] <-  lsp-elixir window/logMessage: {'type': 3, 'message': 'ElixirLS built with elixir "1.15.0" on OTP "25"'}
lsp-elixir: Running on elixir "1.15.0 (compiled with Erlang/OTP 25)" on OTP "25"
:: [13:46:44.102] <-  lsp-elixir window/logMessage: {'type': 3, 'message': 'Running on elixir "1.15.0 (compiled with Erlang/OTP 25)" on OTP "25"'}
lsp-elixir: Protocols are not consolidated
:: [13:46:44.104] <-  lsp-elixir window/logMessage: {'type': 3, 'message': 'Protocols are not consolidated'}
lsp-elixir: Elixir sources not found (checking in c:/home/runner/work/elixir/elixir). Code navigation to Elixir modules disabled.
:: [13:46:44.112] <-  lsp-elixir window/logMessage: {'type': 3, 'message': 'Elixir sources not found (checking in c:/home/runner/work/elixir/elixir). Code navigation to Elixir modules disabled.'}
:: [13:46:44.172] <<< lsp-elixir (1) (duration: 2608ms): {'serverInfo': {'name': 'ElixirLS', 'version': '0.15.1'}, 'capabilities': {'implementationProvider': True, 'signatureHelpProvider': {'triggerCharacters': ['(', ',']}, 'codeActionProvider': False, 'executeCommandProvider': {'commands': ['expandMacro:k_kYDJBDbk5UHF6ssTZhf8Rxs2qQ3AKv', 'getExUnitTestsInFile:k_kYDJBDbk5UHF6ssTZhf8Rxs2qQ3AKv', 'manipulatePipes:k_kYDJBDbk5UHF6ssTZhf8Rxs2qQ3AKv', 'mixClean:k_kYDJBDbk5UHF6ssTZhf8Rxs2qQ3AKv', 'restart:k_kYDJBDbk5UHF6ssTZhf8Rxs2qQ3AKv', 'spec:k_kYDJBDbk5UHF6ssTZhf8Rxs2qQ3AKv']}, 'definitionProvider': True, 'documentOnTypeFormattingProvider': {'firstTriggerCharacter': '\n'}, 'completionProvider': {'triggerCharacters': ['.', '@', '&', '%', '^', ':', '!', '-', '~']}, 'documentSymbolProvider': True, 'workspaceSymbolProvider': True, 'referencesProvider': True, 'foldingRangeProvider': True, 'textDocumentSync': {'save': {'includeText': True}, 'didOpen': {}, 'didClose': {}, 'change': {'syncKind': 2}}, 'documentFormattingProvider': True, 'macroExpansion': True, 'workspace': {'workspaceFolders': {'supported': False, 'changeNotifications': False}}, 'hoverProvider': True, 'codeLensProvider': {'resolveProvider': False}}}
:: [13:46:44.172]  -> lsp-elixir initialized: {}
:: [13:46:44.173]  -> lsp-elixir workspace/didChangeConfiguration: {'settings': {'elixirLS': {'projectDir': None, 'fetchDeps': True, 'mixTarget': None, 'dialyzerEnabled': True, 'mixEnv': 'dev', 'dialyzerFormat': 'dialyxir_long', 'dialyzerWarnOpts': ['error_handling', 'no_behaviours', 'no_contracts', 'no_fail_call', 'no_fun_app', 'no_improper_lists', 'no_match', 'no_missing_calls', 'no_opaque', 'no_return', 'no_undefined_callbacks', 'no_unused', 'unknown']}}}
:: [13:46:44.173] <-- lsp-elixir client/registerCapability (1): {'registrations': [{'registerOptions': {'watchers': [{'globPattern': '**/*.ex'}, {'globPattern': '**/*.exs'}, {'globPattern': '**/*.erl'}, {'globPattern': '**/*.hrl'}, {'globPattern': '**/*.yrl'}, {'globPattern': '**/*.xrl'}, {'globPattern': '**/*.eex'}, {'globPattern': '**/*.leex'}, {'globPattern': '**/*.heex'}, {'globPattern': '**/*.sface'}]}, 'method': 'workspace/didChangeWatchedFiles', 'id': 'B63DDB275E15ED256156A5090CE35EB12FC8CC8C'}]}
:: [13:46:44.173] >>> lsp-elixir (1) (duration: 0ms): None
...
...
Truncated
...
...
@princemaple
Copy link
Contributor Author

princemaple commented Jun 30, 2023

Starting the .bat file directly seems OK:

LSP-elixir\server\0.15.1
❯ .\language_server.bat
Installing ElixirLS release v0.15.1
Running in c:/Users/chenp/AppData/Local/Sublime Text/Package Storage/LSP-elixir/server/0.15.1
Install complete
Content-Length: 103

{"jsonrpc":"2.0","method":"window/logMessage","params":{"message":"Started ElixirLS v0.15.1","type":3}}Content-Length: 172

{"jsonrpc":"2.0","method":"window/logMessage","params":{"message":"Running in c:/Users/chenp/AppData/Local/Sublime Text/Package Storage/LSP-elixir/server/0.15.1","type":3}}Content-Length: 130

{"jsonrpc":"2.0","method":"window/logMessage","params":{"message":"ElixirLS built with elixir \"1.15.0\" on OTP \"26\"","type":3}}Content-Length: 151

{"jsonrpc":"2.0","method":"window/logMessage","params":{"message":"Running on elixir \"1.15.0 (compiled with Erlang/OTP 26)\" on OTP \"26\"","type":3}}Content-Length: 109

{"jsonrpc":"2.0","method":"window/logMessage","params":{"message":"Protocols are not consolidated","type":3}}Content-Length: 196

{"jsonrpc":"2.0","method":"window/logMessage","params":{"message":"Elixir sources not found (checking in c:/home/runner/work/elixir/elixir). Code navigation to Elixir modules disabled.","type":3}}Content-Length: 111

{"jsonrpc":"2.0","method":"window/logMessage","params":{"message":"Experimental server is disabled.","type":3}}

Somewhere during initialize with a proper project failed.

@lukaszsamson
Copy link
Collaborator

There is definitively a problem on windows. I tried on elixir 1.15 and otp 26.0.2 and didn't get a crash but it hangs. I wonder if this is related to this patch that did not make it into 1.15 elixir elixir-lang/elixir@0dd933b

It seems the initialize message makes it missbehave

@lukaszsamson lukaszsamson changed the title 0.15.1 crash [OTP26][Windows] 0.15.1 crash or hang on start Jun 30, 2023
@princemaple
Copy link
Contributor Author

princemaple commented Jun 30, 2023

I tried patching the elixir.bat file like this commit did. It didn't seem to make a difference. Not sure my "try" was conclusive though.

@princemaple
Copy link
Contributor Author

I wanted to start the language server myself, then curl the initialize command with the payload above against the language server directly to see what happens. However I don't understand language server enough to do it. 🫠

@lukaszsamson
Copy link
Collaborator

You need to write to stdin a message like

Content-Length: 123\r\n\r\n{...}

if you need any non ascii chars remember it needs to be encoded to latin1
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification/#contentPart

@princemaple
Copy link
Contributor Author

princemaple commented Jun 30, 2023

Finally I got something useful

GenServer ElixirLS.LanguageServer.JsonRpc terminating
** (FunctionClauseError) no function clause matching in ElixirLS.LanguageServer.JsonRpc.handle_call/3
    (language_server 0.15.1) lib/language_server/json_rpc.ex:147: ElixirLS.LanguageServer.JsonRpc.handle_call({:packet, %{"capabilities" => %{"general" => %{"markdown" => %{"parser" => "Python-Markdown", "version" => "3.2.2"}, "regularExpressions" => %{"engine" => "ECMAScript"}}, "textDocument" => %{"callHierarchy" => %{"dynamicRegistration" => true}, "codeAction" => %{"codeActionLiteralSupport" => %{"codeActionKind" => %{"valueSet" => ["quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source.fixAll", "source.organizeImports"]}}, "dataSupport" => true, "dynamicRegistration" => true, "isPreferredSupport" => true, "resolveSupport" => %{"properties" => ["edit"]}}, "codeLens" => %{"dynamicRegistration" => true}, "colorProvider" => %{"dynamicRegistration" => true}, "completion" => %{"completionItem" => %{"deprecatedSupport" => true, "documentationFormat" => ["markdown", "plaintext"], "insertReplaceSupport" => true, "insertTextModeSupport" => %{"valueSet" => [2]}, "labelDetailsSupport" => true, "resolveSupport" => %{"properties" => ["detail", "documentation", "additionalTextEdits"]}, "snippetSupport" => true, "tagSupport" => %{"valueSet" => [1]}}, "completionItemKind" => %{"valueSet" => [20, 1, 16, 18, 13, 11, 12, 5, 17, 4, 21, 19, 23, 7, 25, 24, 10, 2, 15, 6, 9, 22, 3, 8, 14]}, "completionList" => %{"itemDefaults" => ["editRange", "insertTextFormat", "data"]}, "dynamicRegistration" => true, "insertTextMode" => 2}, "declaration" => %{"dynamicRegistration" => true, "linkSupport" => true}, "definition" => %{"dynamicRegistration" => true, "linkSupport" => true}, "diagnostic" => %{"dynamicRegistration" => true, "relatedDocumentSupport" => true}, "documentHighlight" => %{"dynamicRegistration" => true}, "documentLink" => %{"dynamicRegistration" => true, "tooltipSupport" => true}, "documentSymbol" => %{"dynamicRegistration" => true, "hierarchicalDocumentSymbolSupport" => true, "symbolKind" => %{"valueSet" => [22, 6, 3, 10, 17, 8, 1, 9, 21, 4, 14, 24, 15, 18, 5, 26, 25, 7, 16, 13, 2, 23, 12, 19, 11, 20]}, "tagSupport" => %{"valueSet" => [1]}}, "formatting" => %{"dynamicRegistration" => true}, "hover" => %{"contentFormat" => ["markdown", "plaintext"], "dynamicRegistration" => true}, "implementation" => %{"dynamicRegistration" => true, "linkSupport" => true}, "inlayHint" => %{"dynamicRegistration" => true, "resolveSupport" => %{"properties" => ["textEdits", "label.command"]}}, "publishDiagnostics" => %{"codeDescriptionSupport" => true, "dataSupport" => true, "relatedInformation" => true, "tagSupport" => %{"valueSet" => [2, 1]}, "versionSupport" => true}, "rangeFormatting" => %{"dynamicRegistration" => true}, "references" => %{"dynamicRegistration" => true}, "rename" => %{"dynamicRegistration" => true, "prepareSupport" => true, "prepareSupportDefaultBehavior" => 1}, "selectionRange" => %{"dynamicRegistration" => true}, "semanticTokens" => %{"augmentsSyntaxTokens" => true, "dynamicRegistration" => true, "formats" => ["relative"], "multilineTokenSupport" => true, "overlappingTokenSupport" => false, "requests" => %{"full" => %{"delta" => true}, "range" => true}, "tokenModifiers" => ["deprecated", "abstract", "modification", "documentation", "declaration", "defaultLibrary", "definition", "async", "static", "readonly"], "tokenTypes" => ["enumMember", "modifier", "namespace", "parameter", "enum", "macro", "regexp", "decorator", "number", "comment", "event", "string", "class", "typeParameter", "operator", "property", ...]}, "signatureHelp" => %{"contextSupport" => true, "dynamicRegistration" => true, "signatureInformation" => %{"activeParameterSupport" => true, "documentationFormat" => ["markdown", "plaintext"], "parameterInformation" => %{"labelOffsetSupport" => true}}}, "synchronization" => %{"didSave" => true, "dynamicRegistration" => true, "willSave" => true, "willSaveWaitUntil" => true}, "typeDefinition" => %{"dynamicRegistration" => true, "linkSupport" => true}, "typeHierarchy" => %{"dynamicRegistration" => true}}, "window" => %{"showDocument" => %{"support" => true}, "showMessage" => %{"messageActionItem" => %{"additionalPropertiesSupport" => true}}, "workDoneProgress" => true}, "workspace" => %{"applyEdit" => true, "codeLens" => %{"refreshSupport" => true}, "configuration" => true, "diagnostics" => %{"refreshSupport" => true}, "didChangeConfiguration" => %{"dynamicRegistration" => true}, "executeCommand" => %{}, "inlayHint" => %{"refreshSupport" => true}, "semanticTokens" => %{"refreshSupport" => true}, "symbol" => %{"dynamicRegistration" => true, "symbolKind" => %{"valueSet" => [22, 6, 3, 10, 17, 8, 1, 9, 21, 4, 14, 24, 15, 18, 5, 26, 25, 7, 16, 13, 2, 23, 12, 19, 11, 20]}, "tagSupport" => %{"valueSet" => [1]}}, "workspaceEdit" => %{"documentChanges" => true, "failureHandling" => "abort"}, "workspaceFolders" => true}}, "clientInfo" => %{"name" => "Sublime Text LSP", "version" => "1.24.0"}, "initializationOptions" => %{}, "processId" => 46016, "rootPath" => "C:Userschenpcodeswoosh", "rootUri" => "file: ///C:/Users/chenp/code/swoosh", "workspaceFolders" => [%{"name" => "swoosh", "uri" => "file:///C:/Users/chenp/code/swoosh"}]}}, {#PID<0.98.0>, [:alias | #Reference<0.0.12547.1577818942.1308688393.189788>]}, %ElixirLS.LanguageServer.JsonRpc{language_server: ElixirLS.LanguageServer.Server, next_id: 1, outgoing_requests: %{}})
    (stdlib 5.0.2) gen_server.erl:1113: :gen_server.try_handle_call/4
    (stdlib 5.0.2) gen_server.erl:1142: :gen_server.handle_msg/6
    (stdlib 5.0.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
    Last message (from #PID<0.98.0>): {:packet, %{"capabilities" => %{"general" => %{"markdown" => %{"parser" => "Python-Markdown", "version" => "3.2.2"}, "regularExpressions" => %{"engine" => "ECMAScript"}}, "textDocument" => %{"callHierarchy" => %{"dynamicRegistration" => true}, "codeAction" => %{"codeActionLiteralSupport" => %{"codeActionKind" => %{"valueSet" => ["quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source.fixAll", "source.organizeImports"]}}, "dataSupport" => true, "dynamicRegistration" => true, "isPreferredSupport" => true, "resolveSupport" => %{"properties" => ["edit"]}}, "codeLens" => %{"dynamicRegistration" => true}, "colorProvider" => %{"dynamicRegistration" => true}, "completion" => %{"completionItem" => %{"deprecatedSupport" => true, "documentationFormat" => ["markdown", "plaintext"], "insertReplaceSupport" => true, "insertTextModeSupport" => %{"valueSet" => [2]}, "labelDetailsSupport" => true, "resolveSupport" => %{"properties" => ["detail", "documentation", "additionalTextEdits"]}, "snippetSupport" => true, "tagSupport" => %{"valueSet" => [1]}}, "completionItemKind" => %{"valueSet" => [20, 1, 16, 18, 13, 11, 12, 5, 17, 4, 21, 19, 23, 7, 25, 24, 10, 2, 15, 6, 9, 22, 3, 8, 14]}, "completionList" => %{"itemDefaults" => ["editRange", "insertTextFormat", "data"]}, "dynamicRegistration" => true, "insertTextMode" => 2}, "declaration" => %{"dynamicRegistration" => true, "linkSupport" => true}, "definition" => %{"dynamicRegistration" => true, "linkSupport" => true}, "diagnostic" => %{"dynamicRegistration" => true, "relatedDocumentSupport" => true}, "documentHighlight" => %{"dynamicRegistration" => true}, "documentLink" => %{"dynamicRegistration" => true, "tooltipSupport" => true}, "documentSymbol" => %{"dynamicRegistration" => true, "hierarchicalDocumentSymbolSupport" => true, "symbolKind" => %{"valueSet" => [22, 6, 3, 10, 17, 8, 1, 9, 21, 4, 14, 24, 15, 18, 5, 26, 25, 7, 16, 13, 2, 23, 12, 19, 11, 20]}, "tagSupport" => %{"valueSet" => [1]}}, "formatting" => %{"dynamicRegistration" => true}, "hover" => %{"contentFormat" => ["markdown", "plaintext"], "dynamicRegistration" => true}, "implementation" => %{"dynamicRegistration" => true, "linkSupport" => true}, "inlayHint" => %{"dynamicRegistration" => true, "resolveSupport" => %{"properties" => ["textEdits", "label.command"]}}, "publishDiagnostics" => %{"code (truncated)","type":1}}

That doesn't look like something that SHOULD crash the LS.

@lukaszsamson
Copy link
Collaborator

@princemaple Your request is invalid. It has to be a proper JsonRPC message like the one here ce88f3c#diff-021acf15c1baa0e6d10e0b9ff09a8903779b5188bad2748accf2238d2e4ac783

@lukaszsamson
Copy link
Collaborator

Also rootUri and rootPath look broken

@princemaple
Copy link
Contributor Author

princemaple commented Jun 30, 2023

Also rootUri and rootPath look broken

The message is extracted from the rpc response and replaced some of the characters for readability. I accidentally removed more than necessary :)

Your request is invalid.

I used this - it is in python format, I turned it into json, maybe I did something wrong in the process. I'll try again next week. Cheers.

{'rootUri': 'file:///C:/Users/chenp/code/REDACTED', 'workspaceFolders': [{'uri': 'file:///C:/Users/chenp/code/REDACTED', 'name': 'REDACTED'}], 'processId': 44792, 'rootPath': 'C:\\Users\\chenp\\code\\REDACTED', 'clientInfo': {'version': '1.24.0', 'name': 'Sublime Text LSP'}, 'initializationOptions': {}, 'capabilities': {'workspace': {'workspaceEdit': {'failureHandling': 'abort', 'documentChanges': True}, 'didChangeConfiguration': {'dynamicRegistration': True}, 'codeLens': {'refreshSupport': True}, 'semanticTokens': {'refreshSupport': True}, 'inlayHint': {'refreshSupport': True}, 'workspaceFolders': True, 'diagnostics': {'refreshSupport': True}, 'executeCommand': {}, 'applyEdit': True, 'configuration': True, 'symbol': {'symbolKind': {'valueSet': [20, 6, 3, 1, 22, 12, 10, 13, 17, 24, 25, 23, 26, 18, 19, 2, 5, 15, 7, 8, 4, 11, 16, 9, 14, 21]}, 'dynamicRegistration': True, 'tagSupport': {'valueSet': [1]}}}, 'textDocument': {'declaration': {'dynamicRegistration': True, 'linkSupport': True}, 'rangeFormatting': {'dynamicRegistration': True}, 'rename': {'prepareSupport': True, 'dynamicRegistration': True, 'prepareSupportDefaultBehavior': 1}, 'implementation': {'dynamicRegistration': True, 'linkSupport': True}, 'synchronization': {'dynamicRegistration': True, 'willSave': True, 'willSaveWaitUntil': True, 'didSave': True}, 'diagnostic': {'dynamicRegistration': True, 'relatedDocumentSupport': True}, 'colorProvider': {'dynamicRegistration': True}, 'codeLens': {'dynamicRegistration': True}, 'publishDiagnostics': {'dataSupport': True, 'relatedInformation': True, 'versionSupport': True, 'codeDescriptionSupport': True, 'tagSupport': {'valueSet': [1, 2]}}, 'documentHighlight': {'dynamicRegistration': True}, 'selectionRange': {'dynamicRegistration': True}, 'definition': {'dynamicRegistration': True, 'linkSupport': True}, 'codeAction': {'dataSupport': True, 'dynamicRegistration': True, 'isPreferredSupport': True, 'resolveSupport': {'properties': ['edit']}, 'codeActionLiteralSupport': {'codeActionKind': {'valueSet': ['quickfix', 'refactor', 'refactor.extract', 'refactor.inline', 'refactor.rewrite', 'source.fixAll', 'source.organizeImports']}}}, 'documentSymbol': {'symbolKind': {'valueSet': [20, 6, 3, 1, 22, 12, 10, 13, 17, 24, 25, 23, 26, 18, 19, 2, 5, 15, 7, 8, 4, 11, 16, 9, 14, 21]}, 'dynamicRegistration': True, 'hierarchicalDocumentSymbolSupport': True, 'tagSupport': {'valueSet': [1]}}, 'typeDefinition': {'dynamicRegistration': True, 'linkSupport': True}, 'formatting': {'dynamicRegistration': True}, 'inlayHint': {'dynamicRegistration': True, 'resolveSupport': {'properties': ['textEdits', 'label.command']}}, 'signatureHelp': {'dynamicRegistration': True, 'contextSupport': True, 'signatureInformation': {'parameterInformation': {'labelOffsetSupport': True}, 'activeParameterSupport': True, 'documentationFormat': ['markdown', 'plaintext']}}, 'completion': {'dynamicRegistration': True, 'completionItemKind': {'valueSet': [19, 15, 18, 2, 17, 20, 3, 1, 13, 14, 23, 24, 22, 25, 9, 7, 12, 10, 5, 8, 4, 16, 6, 21, 11]}, 'completionList': {'itemDefaults': ['editRange', 'insertTextFormat', 'data']}, 'completionItem': {'snippetSupport': True, 'insertTextModeSupport': {'valueSet': [2]}, 'resolveSupport': {'properties': ['detail', 'documentation', 'additionalTextEdits']}, 'labelDetailsSupport': True, 'documentationFormat': ['markdown', 'plaintext'], 'deprecatedSupport': True, 'insertReplaceSupport': True, 'tagSupport': {'valueSet': [1]}}, 'insertTextMode': 2}, 'typeHierarchy': {'dynamicRegistration': True}, 'documentLink': {'dynamicRegistration': True, 'tooltipSupport': True}, 'semanticTokens': {'formats': ['relative'], 'multilineTokenSupport': True, 'tokenTypes': ['modifier', 'method', 'namespace', 'typeParameter', 'enumMember', 'function', 'enum', 'variable', 'event', 'property', 'decorator', 'operator', 'struct', 'comment', 'type', 'class', 'string', 'macro', 'interface', 'number', 'keyword', 'regexp', 'parameter'], 'dynamicRegistration': True, 'augmentsSyntaxTokens': True, 'overlappingTokenSupport': False, 'tokenModifiers': ['modification', 'declaration', 'async', 'static', 'abstract', 'readonly', 'definition', 'documentation', 'deprecated', 'defaultLibrary'], 'requests': {'range': True, 'full': {'delta': True}}}, 'callHierarchy': {'dynamicRegistration': True}, 'references': {'dynamicRegistration': True}, 'hover': {'dynamicRegistration': True, 'contentFormat': ['markdown', 'plaintext']}}, 'general': {'markdown': {'version': '3.2.2', 'parser': 'Python-Markdown'}, 'regularExpressions': {'engine': 'ECMAScript'}}, 'window': {'workDoneProgress': True, 'showDocument': {'support': True}, 'showMessage': {'messageActionItem': {'additionalPropertiesSupport': True}}}}}

@lukaszsamson
Copy link
Collaborator

It's missing the JsonRPC wrapper {"jsonrpc":"2.0","id":0,"method":"initialize","params": <your initialize request here>}

@princemaple
Copy link
Contributor Author

princemaple commented Jun 30, 2023 via email

@lukaszsamson
Copy link
Collaborator

This was a tricky bug to track. On my windows machine IO.binwrite to stdout hangs when :standard_out is set to :latin1 encoding. But to reproduce it I have to spawn a process via port.

erl -noshell -eval "Path = os:find_executable('erl'), Port1 = erlang:open_port({spawn_executable, Path}, [binary, {args, ['-noshell', '-kernel', 'standard_io_encoding', 'latin1', '-eval', \"io:setopts(standard_io, [{encoding, latin1}]), io:format('duπa~n', []), erlang:halt()\"]}, exit_status]), receive {Port1, {data, A}} -> io:fwrite(A, []) after 2000 -> io:fwrite('nothing~n') end, erlang:halt()"

On OTP 25 windows and OTP 25 or OTP 26.0.2 macOS this prints

du\x{3C0}a

On OTP 26.0.2 windows

nothing

However if I run it directly from the cmd terminal

erl -noshell -kernel standard_io_encoding latin1 -eval "io:setopts(standard_io, [{encoding, latin1}]), io:format('duπa~n', []), erlang:halt()"

It prints to stdout correctly

du\x{3C0}a

That explains why the launcher bat works from terminal and hangs when run spawned from vscode.

Note that we need to set stdout to latin1. Otherwise the client closes connection on first non ASCII range character printed to output.

@lukaszsamson
Copy link
Collaborator

OTP 26.1 is out with the fix for erlang/otp#7459, I'll test it out later

@lukaszsamson
Copy link
Collaborator

I can confirm that elixir-ls 0.16 with OTP 26.1 is working on windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants