nim-lang/langserver

Langserver stops responding to any requests (neovim lsp logs)

Closed this issue · 4 comments

Nim version: 2.0.8
Langserver version: compiled from HEAD ed6cc74
OS: macos, arm64

Getting this error:

Traceback (most recent call last)
../langserver/nimlangserver.nim(166) nimlangserver
../langserver/pkgs2/chronos-4.0.3-ba179f34b0513ebd1615076f07b61e2e217bd228/chronos/internal/asyncengine.nim(1210) runForever
../langserver/pkgs2/chronos-4.0.3-ba179f34b0513ebd1615076f07b61e2e217bd228/chronos/internal/asyncengine.nim(150) poll
../langserver/lstransports.nim(251) startStdioLoop
../langserver/lstransports.nim(188) processMessage
../langserver/lstransports.nim(160) runRpc
../langserver/lstransports.nim(143) writeOutput
../langserver/pkgs2/nim-2.0.8-46333e8f4bda41dd6d3852a3f5fa4975b96b66a2/lib/pure/streams.nim(381) write
../langserver/pkgs2/nim-2.0.8-46333e8f4bda41dd6d3852a3f5fa4975b96b66a2/lib/pure/streams.nim(343) writeData
../langserver/pkgs2/nim-2.0.8-46333e8f4bda41dd6d3852a3f5fa4975b96b66a2/lib/pure/streams.nim(1346) fsWriteData
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

Have no idea how to debug, any advice?

Thanks, can you post the full log?

Hey, @jmgomez. Sorry for late reply. So that log above is from neovim's lsp.log, nimlangserver also creates nimlangserver.log file in project directory. Here it is:

DBG CPU Time                                   benchmark="chk \"/Users/armed/Dev/my-app/src/cli/mockscanner.nim\":0:0" time=0.258 command="chk \"/Users/armed/Dev/my-app/src/cli/mockscanner.nim\":0:0"
DBG Found diagnostics                          file={}
DBG Stopping nimsuggest for                    root=/Users/armed/Dev/my-app/src/libsdk.nim
DBG Stopped nimsuggest                         res=ok()
DBG ShowMessage                                message="Nimsuggest initialized for /Users/armed/Dev/my-app/src/libsdk.nim"
DBG Running diagnostics                        uri=file:///Users/armed/Dev/my-app/src/libsdk.nim
DBG processQueue                               size=1
DBG Started...                                 benchmark="chk \"/Users/armed/Dev/my-app/src/libsdk.nim\":0:0" command="chk \"/Users/armed/Dev/my-app/src/libsdk.nim\":0:0"
DBG timeoutCallback is set                     timeout=120000 command="chk \"/Users/armed/Dev/my-app/src/libsdk.nim\":0:0"
ERR NimSuggest Error (stderr)                  err=
DBG NimSuggest needed to be restarted due to an error
WRN Server stopped.                            projectFile=/Users/armed/Dev/my-app/src/libsdk.nim
DBG ShowMessage                                message="Using Nim Compiler Version 2.2.0 [MacOSX: arm64]"
INF Starting nimsuggest                        root=/Users/armed/Dev/my-app/src/libsdk.nim timeout=120000 path=/Users/armed/.local/share/mise/installs/nim/2.2.0/bin/nimsuggest workingDir=/Users/armed/Dev/my-app
DBG Parsing nimsuggest capability              capability=con
DBG Parsing nimsuggest capability              capability=exceptionInlayHints
DBG Parsing nimsuggest capability              capability=unknownFile
DBG Nimsuggest Capabilities                    capabilities="{con, exceptionInlayHints, unknownFile}"
DBG Sending result(s)                          length=249 command="chk \"/Users/armed/Dev/my-app/src/libsdk.nim\":0:0"
DBG CPU Time                                   benchmark="chk \"/Users/armed/Dev/my-app/src/libsdk.nim\":0:0" time=0.256 command="chk \"/Users/armed/Dev/my-app/src/libsdk.nim\":0:0"
DBG Found diagnostics                          file={}
DBG Stopping nimsuggest for                    root=/Users/armed/Dev/my-app/src/libsdk.nim
DBG Stopped nimsuggest                         res=ok()
DBG ShowMessage                                message="Nimsuggest initialized for /Users/armed/Dev/my-app/src/libsdk.nim"
DBG Running diagnostics                        uri=file:///Users/armed/Dev/my-app/src/cli/mockscanner.nim
DBG processQueue                               size=1
DBG Started...                                 benchmark="chk \"/Users/armed/Dev/my-app/src/cli/mockscanner.nim\":0:0" command="chk \"/Users/armed/Dev/my-app/src/cli/mockscanner.nim\":0:0"
DBG timeoutCallback is set                     timeout=120000 command="chk \"/Users/armed/Dev/my-app/src/cli/mockscanner.nim\":0:0"
ERR NimSuggest Error (stderr)                  err=
DBG NimSuggest needed to be restarted due to an error
WRN Server stopped.                            projectFile=/Users/armed/Dev/my-app/src/libsdk.nim
DBG ShowMessage                                message="Using Nim Compiler Version 2.2.0 [MacOSX: arm64]"
INF Starting nimsuggest                        root=/Users/armed/Dev/my-app/src/libsdk.nim timeout=120000 path=/Users/armed/.local/share/mise/installs/nim/2.2.0/bin/nimsuggest workingDir=/Users/armed/Dev/my-app
DBG Parsing nimsuggest capability              capability=con
DBG Parsing nimsuggest capability              capability=exceptionInlayHints
DBG Parsing nimsuggest capability              capability=unknownFile
DBG Nimsuggest Capabilities                    capabilities="{con, exceptionInlayHints, unknownFile}"
DBG Sending result(s)                          length=249 command="chk \"/Users/armed/Dev/my-app/src/cli/mockscanner.nim\":0:0"
DBG CPU Time                                   benchmark="chk \"/Users/armed/Dev/my-app/src/cli/mockscanner.nim\":0:0" time=0.259 command="chk \"/Users/armed/Dev/my-app/src/cli/mockscanner.nim\":0:0"
DBG Found diagnostics                          file={}

Langserver got into infinite nimguggest restart state. It was restarting nimsuiggest until I kill nimlangserver process tree completely and then trigger editor to start it again.

also my editor adds following config upon starting LSP

{
  nim_langserver = {
    settings = {
      single_file_support = false,
      nim = {
        projectMapping = {
          {
            projectFile = "./src/libsdk.nim",
            fileRegex = ".*\\.nim",
          },
          {
            projectFile = "./src/cli.nim",
            fileRegex = ".*\\.nim",
          },
        },
      },
    },
  },
}

UPDATE:

  • nim verision is now 2.2.0
  • nimlangserver is built from master 5ccf289
  • nimsuggest is from nim 2.2.0 distribution

same error

This is a nimsuggest crash. You need to report it in the nim repro. If you open the the project with the vscode extension you will likely see the last cmd that made the code crash. Its probably chk \"/Users/armed/Dev/my-app/src/libsdk.nim\.

Alternatively, you can just use directly nimsuggest in the cmd line to reproduce it (https://nim-lang.org/docs/nimsuggest.html).