nimlsp icon indicating copy to clipboard operation
nimlsp copied to clipboard

Segment Violation on method `textDocument/didOpen` on MacOS

Open FrothyMarrow opened this issue 1 year ago • 2 comments

I am facing problems running nimlsp with a Neovim configuration. The configuration works on Linux but crashes on MacOS (14.3 (23D56).

It crashes every time I try to open an empty text.nim file with error SIGSEGV on method textDocument/didOpen.

Nim version:

Nim Compiler Version 1.6.18 [MacOSX: arm64]
Compiled at 2023-12-15
Copyright (c) 2006-2023 by Andreas Rumpf

NimLSP Debug logs:

INFO Version: 0.4.4
INFO explicitSourcePath: /nix/store/2h4q721scci6wviab1i9zpg7nrs853iw-nim-unwrapped-1.6.18-source
DEBUG Trying to read frame
>> Content-Length: 3725
>> 
>> {"jsonrpc":"2.0","method":"initialize","params":{"rootUri":"file:\/\/\/Users\/frothy\/dev\/neovim-flake","processId":25423,"clientInfo":{"version":"0.9.5","name":"Neovim"},"trace":"off","workspaceFolders":[{"uri":"file:\/\/\/Users\/frothy\/dev\/neovim-flake","name":"\/Users\/frothy\/dev\/neovim-flake"}],"initializationOptions":{},"capabilities":{"offsetEncoding":["utf-16"],"textDocument":{"publishDiagnostics":{"tagSupport":{"valueSet":[1,2]},"relatedInformation":true},"declaration":{"linkSupport":true},"definition":{"linkSupport":true},"semanticTokens":{"tokenModifiers":["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"],"dynamicRegistration":false,"tokenTypes":["namespace","type","class","enum","interface","struct","typeParameter","parameter","variable","property","enumMember","event","function","method","macro","keyword","modifier","comment","string","number","regexp","operator","decorator"],"formats":["relative"],"overlappingTokenSupport":true,"multilineTokenSupport":false,"requests":{"range":false,"full":{"delta":true}},"augmentsSyntaxTokens":true,"serverCancelSupport":false},"callHierarchy":{"dynamicRegistration":false},"typeDefinition":{"linkSupport":true},"hover":{"dynamicRegistration":false,"contentFormat":["markdown","plaintext"]},"documentSymbol":{"dynamicRegistration":false,"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]},"hierarchicalDocumentSymbolSupport":true},"implementation":{"linkSupport":true},"signatureHelp":{"dynamicRegistration":false,"signatureInformation":{"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true},"activeParameterSupport":true}},"references":{"dynamicRegistration":false},"documentHighlight":{"dynamicRegistration":false},"synchronization":{"dynamicRegistration":false,"didSave":true,"willSave":true,"willSaveWaitUntil":true},"rename":{"dynamicRegistration":false,"prepareSupport":true},"codeAction":{"isPreferredSupport":true,"dataSupport":true,"dynamicRegistration":false,"resolveSupport":{"properties":["edit"]},"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"completion":{"insertTextMode":1,"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,"completionList":{"itemDefaults":["commitCharacters","editRange","insertTextFormat","insertTextMode","data"]},"dynamicRegistration":false,"completionItem":{"tagSupport":{"valueSet":[1]},"resolveSupport":{"properties":["documentation","detail","additionalTextEdits","sortText","filterText","insertText","textEdit","insertTextFormat","insertTextMode"]},"commitCharactersSupport":true,"preselectSupport":true,"deprecatedSupport":true,"documentationFormat":["markdown","plaintext"],"insertTextModeSupport":{"valueSet":[1,2]},"labelDetailsSupport":true,"insertReplaceSupport":true,"snippetSupport":true}}},"workspace":{"workspaceEdit":{"resourceOperations":["rename","create","delete"]},"workspaceFolders":true,"didChangeWatchedFiles":{"dynamicRegistration":false,"relativePatternSupport":true},"semanticTokens":{"refreshSupport":true},"configuration":true,"symbol":{"dynamicRegistration":false,"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]},"hierarchicalWorkspaceSymbolSupport":true},"applyEdit":true},"window":{"showDocument":{"support":true},"workDoneProgress":true,"showMessage":{"messageActionItem":{"additionalPropertiesSupport":false}}}},"rootPath":"\/Users\/frothy\/dev\/neovim-flake"},"id":1}
DEBUG Got frame
DEBUG Got valid Request message of type initialize
DEBUG Got initialize request, answering
<< Content-Length: 426
<< 
<< {"jsonrpc":"2.0","id":1,"result":{"capabilities":{"textDocumentSync":{"openClose":true,"change":1,"willSave":false,"willSaveWaitUntil":false,"save":{"includeText":true}},"hoverProvider":true,"completionProvider":{"resolveProvider":false,"triggerCharacters":["."]},"signatureHelpProvider":{"triggerCharacters":["(",","]},"definitionProvider":true,"referencesProvider":true,"documentSymbolProvider":true,"renameProvider":true}}}
DEBUG Trying to read frame
>> Content-Length: 52
>> 
>> {"jsonrpc":"2.0","params":{},"method":"initialized"}
DEBUG Got frame
DEBUG Unable to parse data as RequestMessage
DEBUG Got valid Notification message of type initialized
DEBUG Properly initialized
DEBUG Trying to read frame
>> Content-Length: 183
>> 
>> {"jsonrpc":"2.0","params":{"textDocument":{"uri":"file:\/\/\/Users\/frothy\/dev\/neovim-flake\/test.nim","languageId":"nim","version":0,"text":"\n"}},"method":"textDocument\/didOpen"}
DEBUG Got frame
DEBUG Unable to parse data as RequestMessage
DEBUG Got valid Notification message of type textDocument/didOpen

Neovim LSP Debug Logs:

[START][2024-02-10 00:12:51] LSP logging initiated
[INFO][2024-02-10 00:12:51] .../vim/lsp/rpc.lua:662	"Starting RPC client"	{  args = {},  cmd = "/nix/store/zlqgcw2wpq2n21fj7qnk3q5nnl2l8cxa-nimlsp-0.4.4/bin/nimlsp_debug",  extra = {    cwd = "/Users/frothy/dev/neovim-flake"  }}
[DEBUG][2024-02-10 00:12:51] .../vim/lsp/rpc.lua:284	"rpc.send"	{  id = 1,  jsonrpc = "2.0",  method = "initialize",  params = {    capabilities = {      textDocument = {        callHierarchy = {          dynamicRegistration = false        },        codeAction = {          codeActionLiteralSupport = {            codeActionKind = {              valueSet = { "", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" }            }          },          dataSupport = true,          dynamicRegistration = false,          isPreferredSupport = true,          resolveSupport = {            properties = { "edit" }          }        },        completion = {          completionItem = {            commitCharactersSupport = true,            deprecatedSupport = true,            documentationFormat = { "markdown", "plaintext" },            insertReplaceSupport = true,            insertTextModeSupport = {              valueSet = { 1, 2 }            },            labelDetailsSupport = true,            preselectSupport = true,            resolveSupport = {              properties = { "documentation", "detail", "additionalTextEdits", "sortText", "filterText", "insertText", "textEdit", "insertTextFormat", "insertTextMode" }            },            snippetSupport = true,            tagSupport = {              valueSet = { 1 }            }          },          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 }          },          completionList = {            itemDefaults = { "commitCharacters", "editRange", "insertTextFormat", "insertTextMode", "data" }          },          contextSupport = true,          dynamicRegistration = false,          insertTextMode = 1        },        declaration = {          linkSupport = true        },        definition = {          linkSupport = true        },        documentHighlight = {          dynamicRegistration = false        },        documentSymbol = {          dynamicRegistration = false,          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 }          }        },        hover = {          contentFormat = { "markdown", "plaintext" },          dynamicRegistration = false        },        implementation = {          linkSupport = true        },        publishDiagnostics = {          relatedInformation = true,          tagSupport = {            valueSet = { 1, 2 }          }        },        references = {          dynamicRegistration = false        },        rename = {          dynamicRegistration = false,          prepareSupport = true        },        semanticTokens = {          augmentsSyntaxTokens = true,          dynamicRegistration = false,          formats = { "relative" },          multilineTokenSupport = false,          overlappingTokenSupport = true,          requests = {            full = {              delta = true            },            range = false          },          serverCancelSupport = false,          tokenModifiers = { "declaration", "definition", "readonly", "static", "deprecated", "abstract", "async", "modification", "documentation", "defaultLibrary" },          tokenTypes = { "namespace", "type", "class", "enum", "interface", "struct", "typeParameter", "parameter", "variable", "property", "enumMember", "event", "function", "method", "macro", "keyword", "modifier", "comment", "string", "number", "regexp", "operator", "decorator" }        },        signatureHelp = {          dynamicRegistration = false,          signatureInformation = {            activeParameterSupport = true,            documentationFormat = { "markdown", "plaintext" },            parameterInformation = {              labelOffsetSupport = true            }          }        },        synchronization = {          didSave = true,          dynamicRegistration = false,          willSave = true,          willSaveWaitUntil = true        },        typeDefinition = {          linkSupport = true        }      },      window = {        showDocument = {          support = true        },        showMessage = {          messageActionItem = {            additionalPropertiesSupport = false          }        },        workDoneProgress = true      },      workspace = {        applyEdit = true,        configuration = true,        didChangeWatchedFiles = {          dynamicRegistration = false,          relativePatternSupport = true        },        semanticTokens = {          refreshSupport = true        },        symbol = {          dynamicRegistration = false,          hierarchicalWorkspaceSymbolSupport = 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 = {          resourceOperations = { "rename", "create", "delete" }        },        workspaceFolders = true      }    },    clientInfo = {      name = "Neovim",      version = "0.9.5"    },    initializationOptions = vim.empty_dict(),    processId = 38271,    rootPath = "/Users/frothy/dev/neovim-flake",    rootUri = "file:///Users/frothy/dev/neovim-flake",    trace = "off",    workspaceFolders = { {        name = "/Users/frothy/dev/neovim-flake",        uri = "file:///Users/frothy/dev/neovim-flake"      } }  }}
[DEBUG][2024-02-10 00:12:52] .../vim/lsp/rpc.lua:387	"rpc.receive"	{  id = 1,  jsonrpc = "2.0",  result = {    capabilities = {      completionProvider = {        resolveProvider = false,        triggerCharacters = { "." }      },      definitionProvider = true,      documentSymbolProvider = true,      hoverProvider = true,      referencesProvider = true,      renameProvider = true,      signatureHelpProvider = {        triggerCharacters = { "(", "," }      },      textDocumentSync = {        change = 1,        openClose = true,        save = {          includeText = true        },        willSave = false,        willSaveWaitUntil = false      }    }  }}
[INFO][2024-02-10 00:12:52] .../lua/vim/lsp.lua:1344	"LSP[null-ls]"	"server_capabilities"	{  server_capabilities = {    codeActionProvider = {      resolveProvider = false    },    completionProvider = {      allCommitCharacters = {},      completionItem = {        labelDetailsSupport = true      },      resolveProvider = false,      triggerCharacters = { ".", ":", "-" }    },    documentFormattingProvider = true,    documentRangeFormattingProvider = true,    executeCommandProvider = {      commands = { "NULL_LS_CODE_ACTION" }    },    hoverProvider = true,    textDocumentSync = {      change = 1,      openClose = true,      save = {        includeText = true      }    }  }}
[DEBUG][2024-02-10 00:12:52] .../vim/lsp/rpc.lua:284	"rpc.send"	{  jsonrpc = "2.0",  method = "initialized",  params = vim.empty_dict()}
[INFO][2024-02-10 00:12:52] .../lua/vim/lsp.lua:1344	"LSP[nimls]"	"server_capabilities"	{  server_capabilities = {    completionProvider = {      resolveProvider = false,      triggerCharacters = { "." }    },    definitionProvider = true,    documentSymbolProvider = true,    hoverProvider = true,    referencesProvider = true,    renameProvider = true,    signatureHelpProvider = {      triggerCharacters = { "(", "," }    },    textDocumentSync = {      change = 1,      openClose = true,      save = {        includeText = true      },      willSave = false,      willSaveWaitUntil = false    }  }}
[DEBUG][2024-02-10 00:12:52] .../vim/lsp/rpc.lua:284	"rpc.send"	{  jsonrpc = "2.0",  method = "textDocument/didOpen",  params = {    textDocument = {      languageId = "nim",      text = "\n",      uri = "file:///Users/frothy/dev/neovim-flake/test.nim",      version = 0    }  }}
[ERROR][2024-02-10 00:12:52] .../vim/lsp/rpc.lua:734	"rpc"	"/nix/store/zlqgcw2wpq2n21fj7qnk3q5nnl2l8cxa-nimlsp-0.4.4/bin/nimlsp_debug"	"stderr"	"SIGSEGV: Illegal storage access. (Attempt to read from nil?)\n"
[INFO][2024-02-10 00:12:56] .../lua/vim/lsp.lua:1875	"exit_handler"	{  [2] = {    _on_attach = <function 1>,    attached_buffers = { true },    cancel_request = <function 2>,    commands = {},    config = {      cmd = <function 3>,      filetypes = { "nim", "nix" },      flags = {        debounce_text_changes = 250      },      get_language_id = <function 4>,      name = "null-ls",      on_attach = <function 5>,      on_exit = <function 6>,      on_init = <function 7>,      root_dir = "/Users/frothy/dev/neovim-flake",      settings = {}    },    handlers = {},    id = 2,    initialized = true,    is_stopped = <function 8>,    messages = {      messages = {},      name = "null-ls",      progress = {},      status = {}    },    name = "null-ls",    notify = <function 9>,    offset_encoding = "utf-16",    request = <function 10>,    request_sync = <function 11>,    requests = {},    rpc = {      is_closing = <function 12>,      notify = <function 13>,      request = <function 14>,      terminate = <function 15>    },    server_capabilities = {      codeActionProvider = {        resolveProvider = false      },      completionProvider = {        allCommitCharacters = {},        completionItem = {          labelDetailsSupport = true        },        resolveProvider = false,        triggerCharacters = { ".", ":", "-" }      },      documentFormattingProvider = true,      documentRangeFormattingProvider = true,      executeCommandProvider = {        commands = { "NULL_LS_CODE_ACTION" }      },      hoverProvider = true,      textDocumentSync = {        change = 1,        openClose = true,        save = {          includeText = true        }      }    },    stop = <function 16>,    supports_method = <function 17>,    workspace_folders = { {        name = "/Users/frothy/dev/neovim-flake",        uri = "file:///Users/frothy/dev/neovim-flake"      } }  }}

Please let me know if any other information is needed.

FrothyMarrow avatar Feb 10 '24 05:02 FrothyMarrow

Hmm, this is likely a bug in nimsuggest. But could you try to update to the latest NimLSP version 0.4.6? I see that between your version 0.4.4 and the current version there have been some stability improvements.

Thanks a lot for the good error report by the way, so much easier to debug with full communications output!

PMunch avatar Feb 11 '24 11:02 PMunch

0.4.6 seems to have the same issue.

Logs:

INFO Version: 0.4.6
INFO explicitSourcePath: /nix/store/sbfnv7ghc1bwd35ak2xw6rwnzl92kj5m-nim-unwrapped-1.6.18-source
DEBUG Trying to read frame
>> Content-Length: 3697
>> 
>> {"jsonrpc":"2.0","params":{"rootUri":"file:\/\/\/Users\/frothy\/dev\/neovim-flake","processId":17529,"clientInfo":{"name":"Neovim","version":"0.9.5"},"initializationOptions":{},"trace":"off","capabilities":{"textDocument":{"completion":{"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,"completionItem":{"insertReplaceSupport":true,"insertTextModeSupport":{"valueSet":[1,2]},"resolveSupport":{"properties":["documentation","detail","additionalTextEdits","sortText","filterText","insertText","textEdit","insertTextFormat","insertTextMode"]},"snippetSupport":true,"commitCharactersSupport":true,"preselectSupport":true,"deprecatedSupport":true,"documentationFormat":["markdown","plaintext"],"tagSupport":{"valueSet":[1]},"labelDetailsSupport":true},"dynamicRegistration":false,"insertTextMode":1,"completionList":{"itemDefaults":["commitCharacters","editRange","insertTextFormat","insertTextMode","data"]}},"declaration":{"linkSupport":true},"synchronization":{"dynamicRegistration":false,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"semanticTokens":{"tokenModifiers":["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"],"requests":{"range":false,"full":{"delta":true}},"dynamicRegistration":false,"formats":["relative"],"overlappingTokenSupport":true,"multilineTokenSupport":false,"serverCancelSupport":false,"augmentsSyntaxTokens":true,"tokenTypes":["namespace","type","class","enum","interface","struct","typeParameter","parameter","variable","property","enumMember","event","function","method","macro","keyword","modifier","comment","string","number","regexp","operator","decorator"]},"references":{"dynamicRegistration":false},"documentHighlight":{"dynamicRegistration":false},"documentSymbol":{"dynamicRegistration":false,"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]}},"typeDefinition":{"linkSupport":true},"implementation":{"linkSupport":true},"definition":{"linkSupport":true},"publishDiagnostics":{"tagSupport":{"valueSet":[1,2]},"relatedInformation":true},"hover":{"dynamicRegistration":false,"contentFormat":["markdown","plaintext"]},"codeAction":{"isPreferredSupport":true,"dataSupport":true,"resolveSupport":{"properties":["edit"]},"dynamicRegistration":false,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"callHierarchy":{"dynamicRegistration":false},"rename":{"dynamicRegistration":false,"prepareSupport":true},"signatureHelp":{"dynamicRegistration":false,"signatureInformation":{"documentationFormat":["markdown","plaintext"],"activeParameterSupport":true,"parameterInformation":{"labelOffsetSupport":true}}}},"workspace":{"configuration":true,"workspaceFolders":true,"workspaceEdit":{"resourceOperations":["rename","create","delete"]},"semanticTokens":{"refreshSupport":true},"didChangeWatchedFiles":{"dynamicRegistration":false,"relativePatternSupport":true},"symbol":{"dynamicRegistration":false,"hierarchicalWorkspaceSymbolSupport":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]}},"applyEdit":true},"window":{"showMessage":{"messageActionItem":{"additionalPropertiesSupport":false}},"showDocument":{"support":true},"workDoneProgress":true}},"workspaceFolders":[{"uri":"file:\/\/\/Users\/frothy\/dev\/neovim-flake","name":"\/Users\/frothy\/dev\/neovim-flake"}],"rootPath":"\/Users\/frothy\/dev\/neovim-flake"},"method":"initialize","id":1}
DEBUG Got frame
DEBUG Got valid Request message of type initialize
DEBUG Got initialize request, answering
<< Content-Length: 426
<< 
<< {"jsonrpc":"2.0","id":1,"result":{"capabilities":{"textDocumentSync":{"openClose":true,"change":1,"willSave":false,"willSaveWaitUntil":false,"save":{"includeText":true}},"hoverProvider":true,"completionProvider":{"resolveProvider":false,"triggerCharacters":["."]},"signatureHelpProvider":{"triggerCharacters":["(",","]},"definitionProvider":true,"referencesProvider":true,"documentSymbolProvider":true,"renameProvider":true}}}
DEBUG Trying to read frame
>> Content-Length: 52
>> 
>> {"jsonrpc":"2.0","method":"initialized","params":{}}
DEBUG Got frame
DEBUG Unable to parse data as RequestMessage
DEBUG Got valid Notification message of type initialized
DEBUG Properly initialized
DEBUG Trying to read frame
>> Content-Length: 183
>> 
>> {"jsonrpc":"2.0","method":"textDocument\/didOpen","params":{"textDocument":{"version":0,"languageId":"nim","uri":"file:\/\/\/Users\/frothy\/dev\/neovim-flake\/test.nim","text":"\n"}}}
DEBUG Got frame
DEBUG Unable to parse data as RequestMessage
DEBUG Got valid Notification message of type textDocument/didOpen

FrothyMarrow avatar Feb 11 '24 14:02 FrothyMarrow