pgourlain / vscode_erlang

Erlang support for Visual Studio Code
MIT License
129 stars 46 forks source link

Denial of Service due to crash at initialization #180

Open pvillads opened 3 years ago

pvillads commented 3 years ago

I am using the latest version of the code add-in (0.6.7). I am editing a simple file: -module(test). -export([factorial/1]).

factorial(0) -> 1; factorial(N) -> N * factorial(N-1).

I have set the erlang path specifically to C:\Program Files\erl-23.2\bin.

When the system starts it displays the following in the output window. As far as I can see, this is an almost complete denial of service: Even though the colorizer does work, none of the commands do.

erlang extension is active using erlang binaries from path : 'C:\Program Files\erl-23.2\bin' starting : escript.exe c:\Users\pvillads.vscode\extensions\pgourlain.erlang-0.6.7\rebar3 compile ===> Verifying dependencies... ===> Compiling vscode_lsp escript.exe exit code:0 using erlang binaries from path : 'C:\Program Files\erl-23.2\bin' starting : erl -noshell -pa src -pa ebin -s int -vscode_port 52836 -s vscode_lsp_entry start 52836 Old inliner: threshold=0 functions=[{hex,1}] Old inliner: threshold=0 functions=[{object_key,2}] =ERROR REPORT==== 23-Dec-2020::13:42:18.337000 === LSP handler error error:badarg while executing lsphandlers:initialize(, #{capabilities =>

{textDocument =>

                                                                                  #{codeAction =>
                                                                                        #{codeActionLiteralSupport =>
                                                                                              #{codeActionKind =>
                                                                                                    #{valueSet =>
                                                                                                          [<<>>,
                                                                                                           <<"quickfix">>,
                                                                                                           <<"refactor">>,
                                                                                                           <<"refactor.extract">>,
                                                                                                           <<"refactor.inline">>,
                                                                                                           <<"refactor.rewrite">>,
                                                                                                           <<"source">>,
                                                                                                           <<"source.organizeImports">>]}},
                                                                                          dynamicRegistration =>
                                                                                              true},
                                                                                    codeLens =>
                                                                                        #{dynamicRegistration =>
                                                                                              true},
                                                                                    colorProvider =>
                                                                                        #{dynamicRegistration =>
                                                                                              true},
                                                                                    completion =>
                                                                                        #{completionItem =>
                                                                                              #{commitCharactersSupport =>
                                                                                                    true,
                                                                                                deprecatedSupport =>
                                                                                                    true,
                                                                                                documentationFormat =>
                                                                                                    [<<"markdown">>,
                                                                                                     <<"plaintext">>],
                                                                                                preselectSupport =>
                                                                                                    true,
                                                                                                snippetSupport =>
                                                                                                    true},
                                                                                          completionItemKind =>
                                                                                              #{valueSet =>
                                                                                                    [1,
                                                                                                     2,
                                                                                                     3,
                                                                                                     4,
                                                                                                     5,
                                                                                                     6,
                                                                                                     7,
                                                                                                     8,
                                                                                                     9,
                                                                                                     10,
                                                                                                     11,
                                                                                                     12,
                                                                                                     13,
                                                                                                     14,
                                                                                                     15,
                                                                                                     16,
                                                                                                     17,
                                                                                                     18,
                                                                                                     19,
                                                                                                     20,
                                                                                                     21,
                                                                                                     22,
                                                                                                     23,
                                                                                                     24,
                                                                                                     25]},
                                                                                          contextSupport =>
                                                                                              true,
                                                                                          dynamicRegistration =>
                                                                                              true},
                                                                                    definition =>
                                                                                        #{dynamicRegistration =>
                                                                                              true},
                                                                                    documentHighlight =>
                                                                                        #{dynamicRegistration =>
                                                                                              true},
                                                                                    documentLink =>
                                                                                        #{dynamicRegistration =>
                                                                                              true},
                                                                                    documentSymbol =>
                                                                                        #{dynamicRegistration =>
                                                                                              true,
                                                                                          hierarchicalDocumentSymbolSupport =>
                                                                                              true,
                                                                                          symbolKind =>
                                                                                              #{valueSet =>
                                                                                                    [1,
                                                                                                     2,
                                                                                                     3,
                                                                                                     4,
                                                                                                     5,
                                                                                                     6,
                                                                                                     7,
                                                                                                     8,
                                                                                                     9,
                                                                                                     10,
                                                                                                     11,
                                                                                                     12,
                                                                                                     13,
                                                                                                     14,
                                                                                                     15,
                                                                                                     16,
                                                                                                     17,
                                                                                                     18,
                                                                                                     19,
                                                                                                     20,
                                                                                                     21,
                                                                                                     22,
                                                                                                     23,
                                                                                                     24,
                                                                                                     25,
                                                                                                     26]}},
                                                                                    foldingRange =>
                                                                                        #{dynamicRegistration =>
                                                                                              true,
                                                                                          lineFoldingOnly =>
                                                                                              true,
                                                                                          rangeLimit =>
                                                                                              5000},
                                                                                    formatting =>
                                                                                        #{dynamicRegistration =>
                                                                                              true},
                                                                                    hover =>
                                                                                        #{contentFormat =>
                                                                                              [<<"markdown">>,
                                                                                               <<"plaintext">>],
                                                                                          dynamicRegistration =>
                                                                                              true},
                                                                                    implementation =>
                                                                                        #{dynamicRegistration =>
                                                                                              true},
                                                                                    onTypeFormatting =>
                                                                                        #{dynamicRegistration =>
                                                                                              true},
                                                                                    publishDiagnostics =>
                                                                                        #{relatedInformation =>
                                                                                              true},
                                                                                    rangeFormatting =>
                                                                                        #{dynamicRegistration =>
                                                                                              true},
                                                                                    references =>
                                                                                        #{dynamicRegistration =>
                                                                                              true},
                                                                                    rename =>
                                                                                        #{dynamicRegistration =>
                                                                                              true},
                                                                                    signatureHelp =>
                                                                                        #{dynamicRegistration =>
                                                                                              true,
                                                                                          signatureInformation =>
                                                                                              #{documentationFormat =>
                                                                                                    [<<"markdown">>,
                                                                                                     <<"plaintext">>]}},
                                                                                    synchronization =>
                                                                                        #{didSave =>
                                                                                              true,
                                                                                          dynamicRegistration =>
                                                                                              true,
                                                                                          willSave =>
                                                                                              true,
                                                                                          willSaveWaitUntil =>
                                                                                              true},
                                                                                    typeDefinition =>
                                                                                        #{dynamicRegistration =>
                                                                                              true}},
                                                                              workspace =>
                                                                                  #{applyEdit =>
                                                                                        true,
                                                                                    configuration =>
                                                                                        true,
                                                                                    didChangeConfiguration =>
                                                                                        #{dynamicRegistration =>
                                                                                              true},
                                                                                    didChangeWatchedFiles =>
                                                                                        #{dynamicRegistration =>
                                                                                              true},
                                                                                    executeCommand =>
                                                                                        #{dynamicRegistration =>
                                                                                              true},
                                                                                    symbol =>
                                                                                        #{dynamicRegistration =>
                                                                                              true,
                                                                                          symbolKind =>
                                                                                              #{valueSet =>
                                                                                                    [1,
                                                                                                     2,
                                                                                                     3,
                                                                                                     4,
                                                                                                     5,
                                                                                                     6,
                                                                                                     7,
                                                                                                     8,
                                                                                                     9,
                                                                                                     10,
                                                                                                     11,
                                                                                                     12,
                                                                                                     13,
                                                                                                     14,
                                                                                                     15,
                                                                                                     16,
                                                                                                     17,
                                                                                                     18,
                                                                                                     19,
                                                                                                     20,
                                                                                                     21,
                                                                                                     22,
                                                                                                     23,
                                                                                                     24,
                                                                                                     25,
                                                                                                     26]}},
                                                                                    workspaceEdit =>
                                                                                        #{documentChanges =>
                                                                                              true},
                                                                                    workspaceFolders =>
                                                                                        true}},
                                                                        processId =>
                                                                            28432,
                                                                        rootPath =>
                                                                            null,
                                                                        rootUri =>
                                                                            null,
                                                                        trace =>
                                                                            <<"off">>,
                                                                        workspaceFolders =>
                                                                            null}), stacktrace:[{erlang,
                                                                                                 binary_to_list,
                                                                                                 [null],
                                                                                                 []},
                                                                                                {lsp_handlers,
                                                                                                 initialize,
                                                                                                 2,
                                                                                                 [{file,
                                                                                                   "src/lsp_handlers.erl"},
                                                                                                  {line,
                                                                                                   10}]},
                                                                                                {gen_lsp_server,
                                                                                                 safeApply,
                                                                                                 3,
                                                                                                 [{file,
                                                                                                   "src/gen_lsp_server.erl"},
                                                                                                  {line,
                                                                                                   26}]},
                                                                                                {gen_lsp_server,
                                                                                                 do_contents,
                                                                                                 2,
                                                                                                 [{file,
                                                                                                   "src/gen_lsp_server.erl"},
                                                                                                  {line,
                                                                                                   104}]}]
fadushin commented 2 years ago

I have (always?) had more or less the same issue on MacOS with most of my projects. Erlang/OTP 24 installed via Homebrew.

A BEAM process is spawned that consumes 2 cores, which I need to kill manually.

Here is the Output panel from VSCode:

erlang extension is active
using erlang binaries from path : '/usr/local/bin'
starting : escript 
/Users/fadushin/.vscode/extensions/pgourlain.erlang-0.8.4/rebar3 compile
===> Verifying dependencies...
===> Cleaning out vscode_lsp...
===> Analyzing applications...
===> Compiling vscode_lsp
escript exit code:0
using erlang binaries from path : '/usr/local/bin'
starting : erl 
-noshell -pa src -pa ebin -s int -vscode_port 49781 -s vscode_lsp_entry start 49781 
Old inliner: threshold=0 functions=[{hex,1}]
Old inliner: threshold=0 functions=[{object_key,2}]
=ERROR REPORT==== 7-Apr-2022::09:13:14.158901 ===
LSP handler error exit:{timeout,
                           {gen_server,call,
                               [gen_lsp_doc_server,get_documents]}} while executing lsp_handlers:configuration(_, [#{codeLensEnabled =>
                                                                                                                         false,
                                                                                                                     debuggerRunMode =>
                                                                                                                         <<"external">>,
                                                                                                                     eep48Help =>
                                                                                                                         true,
                                                                                                                     erlangPath =>
                                                                                                                         <<"/usr/local/bin">>,
                                                                                                                     formattingLineLength =>
                                                                                                                         100,
                                                                                                                     includePaths =>
                                                                                                                         [],
                                                                                                                     linting =>
                                                                                                                         true,
                                                                                                                     rebarBuildArgs =>
                                                                                                                         [<<"compile">>],
                                                                                                                     rebarPath =>
                                                                                                                         <<"/usr/local/bin">>,
                                                                                                                     verbose =>
                                                                                                                         false},
                                                                                                                   #{autosave =>
                                                                                                                         false,
                                                                                                                     tmpdir =>
                                                                                                                         <<"/var/folders/w4/hfd_n5wj3pz071q6m38_m_c40000gn/T">>},
                                                                                                                   #{proxy =>
                                                                                                                         <<>>,
                                                                                                                     proxyAuthorization =>
                                                                                                                         null,
                                                                                                                     proxyStrictSSL =>
                                                                                                                         true,
                                                                                                                     proxySupport =>
                                                                                                                         <<"override">>,
                                                                                                                     systemCertificates =>
                                                                                                                         true},
                                                                                                                   #{actionsPosition =>
                                                                                                                         <<"right">>,
                                                                                                                     collapseResults =>
                                                                                                                         <<"alwaysExpand">>,
                                                                                                                     exclude =>
                                                                                                                         #{'**/*.code-search' =>
                                                                                                                               true,
                                                                                                                           '**/bower_components' =>
                                                                                                                               true,
                                                                                                                           '**/node_modules' =>
                                                                                                                               true},
                                                                                                                     followSymlinks =>
                                                                                                                         true,
                                                                                                                     globalFindClipboard =>
                                                                                                                         false,
                                                                                                                     location =>
                                                                                                                         <<"sidebar">>,
                                                                                                                     maintainFileSearchCache =>
                                                                                                                         false,
                                                                                                                     maxResults =>
                                                                                                                         20000,
                                                                                                                     mode =>
                                                                                                                         <<"view">>,
                                                                                                                     quickOpen =>
                                                                                                                         #{history =>
                                                                                                                               #{filterSortOrder =>

                                                                                                            <<"default">>},
                                                                                                                           includeHistory =>
                                                                                                                               true,
                                                                                                                           includeSymbols =>
                                                                                                                               false},
                                                                                                                     searchEditor =>
                                                                                                                         #{defaultNumberOfContextLines =>
                                                                                                                               1,
                                                                                                                           doubleClickBehaviour =>
                                                                                                                               <<"goToLocation">>,
                                                                                                                           reusePriorSearchConfiguration =>
                                                                                                                               false},
                                                                                                                     searchOnType =>
                                                                                                                         true,
                                                                                                                     searchOnTypeDebouncePeriod =>
                                                                                                                         300,
                                                                                                                     seedOnFocus =>
                                                                                                                         false,
                                                                                                                     seedWithNearestWord =>
                                                                                                                         false,
                                                                                                                     showLineNumbers =>
                                                                                                                         false,
                                                                                                                     smartCase =>
                                                                                                                         false,
                                                                                                                     sortOrder =>
                                                                                                                         <<"default">>,
                                                                                                                     useGlobalIgnoreFiles =>
                                                                                                                         false,
                                                                                                                     useIgnoreFiles =>
                                                                                                                         true,
                                                                                                                     usePCRE2 =>
                                                                                                                         false,
                                                                                                                     useParentIgnoreFiles =>
                                                                                                                         false,
                                                                                                                     useReplacePreview =>
                                                                                                                         true,
                                                                                                                     useRipgrep =>
                                                                                                                         true}]), stacktrace:[{gen_server,
                                                                                                                                               call,
                                                                                                                                               2,
                                                                                                                                               [{file,
                                                                                                                                                 "gen_server.erl"},
                                                                                                                                                {line,
                                                                                                                                                 239}]},
                                                                                                                                              {lsp_handlers,
                                                                                                                                               configuration,
                                                                                                                                               2,
                                                                                                                                               [{file,
                                                                                                                                                 "src/lsp_handlers.erl"},
                                                                                                                                                {line,
                                                                                                                                                 41}]},
                                                                                                                                              {gen_lsp_server,
                                                                                                                                               safeApply,
                                                                                                                                               3,
                                                                                                                                               [{file,
                                                                                                                                                 "src/gen_lsp_server.erl"},
                                                                                                                                                {line,

                  26}]},
                                                                                                                                              {gen_lsp_server,
                                                                                                                                               do_contents,
                                                                                                                                               2,
                                                                                                                                               [{file,
                                                                                                                                                 "src/gen_lsp_server.erl"},
                                                                                                                                                {line,
                                                                                                                                                 115}]}]