Skip to content

HLS hangs at 100% CPU usage on one core with GHC 8.8.4 and QuasiQuotes/string-interpolate #1404

@jflanglois

Description

@jflanglois

Your environment

Output of haskell-language-server --probe-tools or haskell-language-server-wrapper --probe-tools:

haskell-language-server version: 0.9.0.0 (GHC: 8.8.4) (PATH: /nix/store/xm31b7c3y15czjv2d9fiwv2lwf5hygmi-haskell-language-server-exe-haskell-language-server-0.9.0.0/bin/haskell-language-server)
Tool versions found on the $PATH
cabal:		3.2.0.0
stack:		Not found
ghc:		8.8.4

Which lsp-client do you use: LanguageClient-neovim

Describe your project (alternative: link to the project): https://github.com/jflanglois/hls-qq-example

Contents of hie.yaml:

cradle:
  cabal:

Steps to reproduce

Write a project that uses GHC 8.8.4 (seems to work fine with 8.10.4) and a QuasiQuote of string-interpolate and observe HLS hang for a long time (it will eventually sort itself out after a minute or two) at 100% CPU on one core. This also appears to be a regression around the 0.9.0.0 mark. Using 0.8.0 in the past seemed to work fine.

Expected behaviour

HLS should not hang.

Actual behaviour

HLS hangs at Making new HscEnv. LanguageClient-neovim times out.

Include debug information

Execute in the root of your project the command haskell-language-server --debug . and paste the logs here:

Debug output:
haskell-language-server version: 0.9.0.0 (GHC: 8.8.4) (PATH: /nix/store/xm31b7c3y15czjv2d9fiwv2lwf5hygmi-haskell-language-server-exe-haskell-language-server-0.9.0.0/bin/haskell-language-server)
(haskell-language-server)Ghcide setup tester in /home/julien/development/hls-qq-example.
Report bugs at https://github.com/haskell/haskell-language-server/issues

Tool versions found on the $PATH
cabal:		3.2.0.0
stack:		Not found
ghc:		8.8.4


Step 1/4: Finding files to test in /home/julien/development/hls-qq-example
Found 1 files

Step 2/4: Looking for hie.yaml files that control setup
Found 1 cradle

Step 3/4: Initializing the IDE

Step 4/4: Type checking the files
[INFO] Consulting the cradle for "Main.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/home/julien/development/hls-qq-example", cradleOptsProg = CradleAction: Cabal}
> Build profile: -w ghc-8.8.4 -O1
> In order, the following will be built (use -v for more details):
>  - hls-qq-example-0.1 (exe:example) (first run)
> Preprocessing executable 'example' for hls-qq-example-0.1..
[INFO] Using interface files cache dir: ghcide
[INFO] Making new HscEnv[main]
[INFO] finish: User TypeCheck (took 2m48s)

Completed (1 file worked, 0 files failed)

Paste the logs from the lsp-client, e.g. for VS Code

LSP logs:
#######
LanguageClient 0.1.160
#######
14:49:19 INFO writer-None src/rpcclient.rs:238 => None {"jsonrpc":"2.0","method":"eval","params":["[!!get(g:, 'LanguageClient_autoStart', 1), s:GetVar('LanguageClient_serverCommands', {}), s:getSelectionUI(), get(g:, 'LanguageClient_trace', v:null), map(s:ToList(get(g:, 'LanguageClient_settingsPath', '.vim/settings.json')), 'expand(v:val)'), !!get(g:, 'LanguageClient_loadSettings', 1), get(g:, 'LanguageClient_rootMarkers', v:null), get(g:, 'LanguageClient_changeThrottle', v:null), get(g:, 'LanguageClient_waitOutputTimeout', v:null), !!get(g:, 'LanguageClient_diagnosticsEnable', 1), get(g:, 'LanguageClient_diagnosticsList', 'Quickfix'), get(g:, 'LanguageClient_diagnosticsDisplay', {}), get(g:, 'LanguageClient_windowLogMessageLevel', 'Warning'), get(g:, 'LanguageClient_hoverPreview', 'Auto'), get(g:, 'LanguageClient_completionPreferTextEdit', 0), has('nvim')]"],"id":2}
14:49:19 INFO reader-None src/rpcclient.rs:191 <= None {"id": 2, "jsonrpc": "2.0", "result": [1, {"haskell": ["haskell-language-server", "--lsp"], "rust": ["rls"], "cpp": ["clangd"]}, null, null, [".vim/settings.json"], 1, null, null, null, 1, "Quickfix", {}, "Warning", "Auto", 0, 1]}
14:49:19 INFO writer-None src/rpcclient.rs:238 => None {"jsonrpc":"2.0","method":"eval","params":["[get(g:, 'LanguageClient_diagnosticsSignsMax', v:null), get(g:, 'LanguageClient_diagnosticsMaxSeverity', 'Hint'), get(g:, 'LanguageClient_diagnosticsIgnoreSources', []), get(g:, 'LanguageClient_documentHighlightDisplay', {}), !!s:GetVar('LanguageClient_selectionUI_autoOpen', 1), s:useVirtualText(), !!s:GetVar('LanguageClient_echoProjectRoot', 1), s:GetVar('LanguageClient_semanticHighlightMaps', {}), s:GetVar('LanguageClient_semanticScopeSeparator', ':'), get(g:, 'LanguageClient_applyCompletionAdditionalTextEdits', 1), get(g:, 'LanguageClient_preferredMarkupKind', v:null), s:GetVar('LanguageClient_hideVirtualTextsOnInsert', 0), get(g:, 'LanguageClient_enableExtensions', v:null), get(g:, 'LanguageClient_codeLensHighlightGroup', 'Comment')]"],"id":3}
14:49:19 INFO reader-None src/rpcclient.rs:191 <= None {"id": 3, "jsonrpc": "2.0", "result": [null, "Hint", [], {}, 1, "All", 1, {}, ":", 1, null, 0, null, "Comment"]}
14:49:19 INFO writer-None src/rpcclient.rs:238 => None {"jsonrpc":"2.0","method":"eval","params":["get(g:, 'loaded_fzf')"],"id":4}
14:49:19 INFO reader-None src/rpcclient.rs:191 <= None {"id": 4, "jsonrpc": "2.0", "result": 1}
14:49:19 INFO unnamed src/language_server_protocol.rs:338 End sync settings
14:49:19 INFO unnamed src/language_server_protocol.rs:3886 settings synced
14:49:19 INFO unnamed src/language_server_protocol.rs:3912 Project root: /home/julien/development/hls-qq-example
14:49:19 INFO writer-None src/rpcclient.rs:238 => None {"jsonrpc":"2.0","method":"s:EchomsgEllipsis","params":["Project root: /home/julien/development/hls-qq-example"]}
14:49:19 INFO unnamed src/language_server_protocol.rs:3989 End languageClient/startServer
14:49:19 INFO unnamed src/language_server_protocol.rs:382 Defining signs
14:49:19 INFO unnamed src/language_server_protocol.rs:1142 Begin initialize
14:49:19 INFO writer-None src/rpcclient.rs:238 => None {"jsonrpc":"2.0","method":"s:command","params":["sign define LanguageClientError text=✖ texthl=ALEErrorSign","sign define LanguageClientInformation text=ℹ texthl=ALEInfoSign","sign define LanguageClientWarning text=⚠ texthl=ALEWarningSign","sign define LanguageClientHint text=➤ texthl=ALEInfoSign"]}
14:49:19 INFO writer-None src/rpcclient.rs:238 => None {"jsonrpc":"2.0","method":"eval","params":["s:hasSnippetSupport()"],"id":5}
14:49:19 INFO reader-None src/rpcclient.rs:191 <= None {"id": 5, "jsonrpc": "2.0", "result": 0}
14:49:19 WARN unnamed src/language_server_protocol.rs:1154 Failed to get initializationOptions: Failed to read file (/home/julien/development/hls-qq-example/.vim/settings.json)
14:49:19 INFO writer-Some("haskell") src/rpcclient.rs:238 => Some("haskell") {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"textDocument":{"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"codeLens":{"dynamicRegistration":true},"colorProvider":{"dynamicRegistration":false},"completion":{"completionItem":{"insertReplaceSupport":false,"snippetSupport":false}},"declaration":{"linkSupport":true},"definition":{"linkSupport":true},"hover":{},"implementation":{"linkSupport":true},"publishDiagnostics":{"relatedInformation":true},"semanticHighlightingCapabilities":{"semanticHighlighting":true},"signatureHelp":{"signatureInformation":{"parameterInformation":{"labelOffsetSupport":true}}},"typeDefinition":{"linkSupport":true}},"workspace":{"applyEdit":true,"didChangeWatchedFiles":{"dynamicRegistration":true}}},"clientInfo":{"name":"LanguageClient-neovim","version":"0.1.160"},"processId":10536,"rootPath":"/home/julien/development/hls-qq-example","rootUri":"file:///home/julien/development/hls-qq-example","trace":"off"},"id":0}
14:49:19 INFO reader-Some("haskell") src/rpcclient.rs:191 <= Some("haskell") {"result":{"capabilities":{"typeDefinitionProvider":true,"foldingRangeProvider":false,"textDocumentSync":{"openClose":true,"change":2,"save":{}},"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":true}},"implementationProvider":true,"documentRangeFormattingProvider":true,"documentHighlightProvider":true,"executeCommandProvider":{"commands":["10632:class:addMinimalMethodPlaceholders","10632:eval:evalCommand","10632:ghcide-type-lenses:typesignature.add","10632:hlint:applyOne","10632:hlint:applyAll","10632:moduleName:edit","10632:retrie:retrieCommand","10632:splice:expandTHSpliceInplace","10632:tactic:tacticsAutoCommand","10632:tactic:tacticsIntrosCommand","10632:tactic:tacticsDestructCommand","10632:tactic:tacticsHomomorphismCommand","10632:tactic:tacticsDestructLambdaCaseCommand","10632:tactic:tacticsHomomorphismLambdaCaseCommand"]},"renameProvider":false,"colorProvider":false,"definitionProvider":true,"hoverProvider":true,"codeActionProvider":true,"completionProvider":{"triggerCharacters":["."],"resolveProvider":false},"codeLensProvider":{},"documentSymbolProvider":true,"documentFormattingProvider":true}},"jsonrpc":"2.0","id":0}
14:49:19 INFO unnamed src/language_server_protocol.rs:1284 End initialize
14:49:19 INFO unnamed src/language_server_protocol.rs:852 Begin register NCM source
14:49:19 INFO writer-None src/rpcclient.rs:238 => None {"jsonrpc":"2.0","method":"eval","params":["exists('g:cm_matcher')"],"id":6}
14:49:19 INFO reader-None src/rpcclient.rs:191 <= None {"id": 6, "jsonrpc": "2.0", "result": 0}
14:49:19 INFO unnamed src/language_server_protocol.rs:893 Begin register NCM2 source
14:49:19 INFO writer-None src/rpcclient.rs:238 => None {"jsonrpc":"2.0","method":"eval","params":["exists('g:ncm2_loaded')"],"id":7}
14:49:19 INFO reader-None src/rpcclient.rs:191 <= None {"id": 7, "jsonrpc": "2.0", "result": 0}
14:49:19 INFO unnamed src/language_server_protocol.rs:934 Begin parse Semantic Scopes
14:49:19 INFO unnamed src/language_server_protocol.rs:946 End parse Semantic Scopes
14:49:19 INFO unnamed src/language_server_protocol.rs:1306 Begin initialized
14:49:19 INFO unnamed src/language_server_protocol.rs:954 Begin updateSemanticHighlightTables
14:49:19 INFO unnamed src/language_server_protocol.rs:1004 End updateSemanticHighlightTables
14:49:19 INFO unnamed src/language_server_protocol.rs:1314 End initialized
14:49:19 INFO writer-Some("haskell") src/rpcclient.rs:238 => Some("haskell") {"jsonrpc":"2.0","method":"initialized","params":{}}
14:49:19 WARN unnamed src/language_server_protocol.rs:4005 Failed to get workspace settings: Failed to read file (/home/julien/development/hls-qq-example/.vim/settings.json)
14:49:19 INFO unnamed src/language_server_protocol.rs:2207 Begin textDocument/didOpen
14:49:19 INFO writer-None src/rpcclient.rs:238 => None {"jsonrpc":"2.0","method":"setbufvar","params":["/home/julien/development/hls-qq-example/Main.hs","LanguageClient_isServerRunning",1]}
14:49:19 INFO writer-None src/rpcclient.rs:238 => None {"jsonrpc":"2.0","method":"LSP#text","params":["/home/julien/development/hls-qq-example/Main.hs"],"id":8}
14:49:19 INFO reader-Some("haskell") src/rpcclient.rs:191 <= Some("haskell") {"jsonrpc":"2.0","params":{"registrations":[{"registerOptions":{"watchers":[{"kind":5,"globPattern":"**/*.hs"},{"kind":5,"globPattern":"**/*.hs-boot"},{"kind":5,"globPattern":"**/*.lhs"},{"kind":5,"globPattern":"**/*.lhs-boot"}]},"method":"workspace/didChangeWatchedFiles","id":"globalFileWatches"}]},"method":"client/registerCapability","id":0}
14:49:19 INFO unnamed src/language_server_protocol.rs:2785 Begin client/registerCapability
14:49:19 INFO unnamed src/language_server_protocol.rs:2806 Watching glob pattern: **/*.hs
14:49:19 INFO reader-None src/rpcclient.rs:191 <= None {"id": 8, "jsonrpc": "2.0", "result": ["{-# LANGUAGE QuasiQuotes #-}", "", "import Data.String.Interpolate (i)", "", "main :: IO ()", "main = do", "  putStrLn [i|Hello #{42 :: Int}|]", ""]}
14:49:19 INFO unnamed src/language_server_protocol.rs:2818 Start watching path "Main.hs"
14:49:19 INFO unnamed src/language_server_protocol.rs:2806 Watching glob pattern: **/*.hs-boot
14:49:19 INFO unnamed src/language_server_protocol.rs:2806 Watching glob pattern: **/*.lhs
14:49:19 INFO unnamed src/language_server_protocol.rs:2806 Watching glob pattern: **/*.lhs-boot
14:49:19 INFO unnamed src/language_server_protocol.rs:2840 End client/registerCapability
14:49:19 INFO writer-Some("haskell") src/rpcclient.rs:238 => Some("haskell") {"jsonrpc":"2.0","result":null,"id":0}
14:49:19 INFO writer-None src/rpcclient.rs:238 => None {"jsonrpc":"2.0","method":"eval","params":["s:GetVar('LanguageClient_setOmnifunc', v:true)"],"id":9}
14:49:19 INFO reader-None src/rpcclient.rs:191 <= None {"id": 9, "jsonrpc": "2.0", "result": true}
14:49:19 INFO writer-Some("haskell") src/rpcclient.rs:238 => Some("haskell") {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"haskell","text":"{-# LANGUAGE QuasiQuotes #-}\n\nimport Data.String.Interpolate (i)\n\nmain :: IO ()\nmain = do\n  putStrLn [i|Hello #{42 :: Int}|]\n","uri":"file:///home/julien/development/hls-qq-example/Main.hs","version":0}}}
14:49:19 INFO unnamed src/language_server_protocol.rs:2157 Begin textDocument/codeLens
14:49:19 INFO writer-Some("haskell") src/rpcclient.rs:238 => Some("haskell") {"jsonrpc":"2.0","method":"textDocument/codeLens","params":{"textDocument":{"uri":"file:///home/julien/development/hls-qq-example/Main.hs"}},"id":1}
14:49:19 INFO writer-None src/rpcclient.rs:238 => None {"jsonrpc":"2.0","method":"s:command","params":["setlocal omnifunc=LanguageClient#complete"]}
14:49:19 INFO writer-None src/rpcclient.rs:238 => None {"jsonrpc":"2.0","method":"setbufvar","params":["/home/julien/development/hls-qq-example/Main.hs","LanguageClient_projectRoot","/home/julien/development/hls-qq-example"]}
14:49:19 INFO writer-None src/rpcclient.rs:238 => None {"jsonrpc":"2.0","method":"s:ExecuteAutocmd","params":["LanguageClientTextDocumentDidOpenPost"]}
14:50:19 WARN unnamed src/language_server_protocol.rs:3081 Failed to start language server automatically. timed out waiting on receive operation
14:50:19 INFO unnamed src/language_server_protocol.rs:3086 End languageClient/handleFileType
14:52:37 INFO reader-Some("haskell") src/rpcclient.rs:191 <= Some("haskell") {"result":[],"jsonrpc":"2.0","id":1}
14:52:37 ERROR reader-Some("haskell") src/rpcclient.rs:55 Thread reader-Some("haskell") exited with error: Failed to send output: "SendError(..)"

Metadata

Metadata

Assignees

No one assigned

    Labels

    performanceIssues about memory consumption, responsiveness, etc.status: needs infoNot actionable, because there's missing informationtype: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions