Skip to content

LSP Lua suddenly stopped working: "***buffer overflow detected ***: terminated" #1844

New issue

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

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

Already on GitHub? # to your account

Closed
barryblando opened this issue Jan 22, 2023 · 21 comments
Assignees
Labels
bug Something isn't working compile Related to compiling the server from source Info Needed More information is required

Comments

@barryblando
Copy link

barryblando commented Jan 22, 2023

How are you using the lua-language-server?

NeoVim

Which OS are you using?

Windows WSL

What is the issue affecting?

Diagnostics/Syntax Checking

Expected Behaviour

loading LSP completed

Actual Behaviour

suddenly stops working with the error "Client # quit with exit code 0 and signal 6"

Reproduction steps

  1. open neovim
  2. LSP loading...
  3. suddenly stops working

Additional Notes

Using

  • Neovim 0.8.2
  • Mason
  • Lua-Language-Server@3.6.7

Log File

[ERROR][2023-01-22 09:49:10] .../vim/lsp/rpc.lua:733	"rpc"	"/home/bblando0x15/.local/share/nvim/mason/bin/lua-language-server"	"stderr"	"*** buffer overflow detected ***: terminated\n"
[ERROR][2023-01-22 09:49:51] .../vim/lsp/rpc.lua:733	"rpc"	"/home/bblando0x15/.local/share/nvim/mason/bin/lua-language-server"	"stderr"	"*** buffer overflow detected ***: terminated\n"
[ERROR][2023-01-22 09:50:50] .../vim/lsp/rpc.lua:733	"rpc"	"/home/bblando0x15/.local/share/nvim/mason/bin/lua-language-server"	"stderr"	"*** buffer overflow detected ***: terminated\n"
[ERROR][2023-01-22 10:00:14] .../vim/lsp/rpc.lua:733	"rpc"	"/home/bblando0x15/.local/share/nvim/mason/bin/lua-language-server"	"stderr"	"*** buffer overflow detected ***: terminated\n"
[ERROR][2023-01-22 10:00:58] .../vim/lsp/rpc.lua:733	"rpc"	"/home/bblando0x15/.local/share/nvim/mason/bin/lua-language-server"	"stderr"	"*** buffer overflow detected ***: terminated\n"
[START][2023-01-22 10:02:31] LSP logging initiated
[ERROR][2023-01-22 10:02:31] .../vim/lsp/rpc.lua:733	"rpc"	"/home/bblando0x15/.local/share/nvim/mason/bin/lua-language-server"	"stderr"	"*** buffer overflow detected ***: terminated\n"
[ERROR][2023-01-22 10:02:49] .../vim/lsp/rpc.lua:733	"rpc"	"/home/bblando0x15/.local/share/nvim/mason/bin/lua-language-server"	"stderr"	"*** buffer overflow detected ***: terminated\n"
[START][2023-01-22 10:12:27] LSP logging initiated
[ERROR][2023-01-22 10:12:27] .../vim/lsp/rpc.lua:733	"rpc"	"/home/bblando0x15/.local/share/nvim/mason/bin/lua-language-server"	"stderr"	"*** buffer overflow detected ***: terminated\n"
[START][2023-01-22 10:14:02] LSP logging initiated
[ERROR][2023-01-22 10:14:02] .../vim/lsp/rpc.lua:733	"rpc"	"/home/bblando0x15/.local/share/nvim/mason/bin/lua-language-server"	"stderr"	"*** buffer overflow detected ***: terminated\n"
[ERROR][2023-01-22 10:17:28] .../vim/lsp/rpc.lua:733	"rpc"	"/home/bblando0x15/.local/share/nvim/mason/bin/lua-language-server"	"stderr"	"*** buffer overflow detected ***: terminated\n"
[ERROR][2023-01-22 10:17:47] .../vim/lsp/rpc.lua:733	"rpc"	"/home/bblando0x15/.local/share/nvim/mason/bin/lua-language-server"	"stderr"	"*** buffer overflow detected ***: terminated\n"
@caarlos0
Copy link

caarlos0 commented Jan 24, 2023

for me it fails on linux amd64, same config and same project works on macos arm64 though.

@JuanZoran
Copy link

I meet the same problem as you, did you have found any solution for that?

@JuanZoran
Copy link

I try to reboot my system, then it works well

@barryblando
Copy link
Author

barryblando commented Jan 25, 2023

I meet the same problem as you, did you have found any solution for that?

none at the moment. also rebooted the WSL. Same buffer overflow. Other LSPs are working

I also change the sumneko_lua config to use vscode's Lua server. Still buffer overflow.

return {
  -- cmd = { os.getenv("HOME") .. "/.local/share/nvim/mason/bin/lua-language-server" },
  cmd = { os.getenv("HOME") .. "/.vscode-server/extensions/sumneko.lua-3.6.7-linux-x64/server/bin/lua-language-server" },
  on_new_config = function(config, root)
    local libs = vim.tbl_deep_extend("force", {}, library)
    libs[root] = nil
    config.settings.Lua.workspace.library = libs
    return config
  end,
  settings = {
    Lua = {
      runtime = {
        version = "LuaJIT",
        path = path
      },
      completion = { callSnippet = "Both" },
      diagnostics = {
        globals = { "vim" }
      },
      workspace = {
        library = library,
        maxPreload = 2000,
        preloadFileSize = 50000,
        checkThirdParty = false,
      },
      telemetry = { enable = false }
    }
  }
}

@Mikilio
Copy link

Mikilio commented Jan 25, 2023

Same issue here I tried to check if my tweaks in the recent days broke my config but that wasn't the case.
Considering that I use Nix which is hundred percent reproducible I can only imagine that something about the protocol changed.

Edit: I was using the unstable channel. Using an older version fixed the issue for me. Thanks to @deriamis for pointing that out.

@deriamis
Copy link

I am having the same problem, and it appears to be something introduced between versions 3.6.4 and 3.6.5. I can run version 3.6.4 without any problems at all.

@sumneko
Copy link
Collaborator

sumneko commented Jan 30, 2023

Should be something with #1835
Could you please help us @koppchen ?

@sumneko sumneko added bug Something isn't working compile Related to compiling the server from source labels Jan 30, 2023
@kyoh86
Copy link

kyoh86 commented Jan 31, 2023

I am having the same problem, and it appears to be something introduced between versions 3.6.4 and 3.6.5. I can run version 3.6.4 without any problems at all.

Me too. It sounds me that something in 3.6.5 becauses the issue.

@koppchen
Copy link
Contributor

I was able to reproduce this, and yeah it looks like the issue was introduced in v3.6.5

Tested with: neovim 0.8.2, with the linux-x64 releases from both lua-language-server and vscode-lua.

Tested the following versions:

  • v3.6.7 - ERROR
  • v3.6.6 - ERROR
  • v3.6.5 - ERROR
  • v3.6.4 - good
  • v3.6.3 - good
  • v3.6.2 - good

I did the following to reproduce the error. The lua files can be empty.

  • Open a lua file in one terminal and keep it open
  • Open a second lua file in another terminal.
  • If the first completed loading the workspace, the second one will error. Otherwise, either (or both) could error.

Seems I usually only have one file open, which is why I didn't notice this sooner.

@koppchen
Copy link
Contributor

Looks like the issue was introduced in this diff. I was testing a few older versions and this is where the failures started.

Also, i should have mentioned this in my previous comment: The error I'm seeing in the logs is a little different then the original report, but it's probably related.

[ERROR][2023-01-31 10:25:37] .../vim/lsp/rpc.lua:733   "rpc"   "lua-language-server"   "stderr"   "*** bit out of range 0 - FD_SETSIZE on fd_set ***: terminated\n"

@sumneko
Copy link
Collaborator

sumneko commented Jan 31, 2023

How about v3.6.8?

@koppchen
Copy link
Contributor

I got the same error with 3.6.8.

[ERROR][2023-01-31 13:41:08] .../vim/lsp/rpc.lua:733   "rpc"   "lua-language-server"   "stderr"   "*** bit out of range 0 - FD_SETSIZE on fd_set ***: terminated\n"

@deriamis
Copy link

deriamis commented Jan 31, 2023

I don't know if it helps you any, but I did an strace and the crash happens in the main thread when reading a bunch of incoming data from the client. I can't quite get a good gdb capture (Ubuntu and debug symbols... sigh), but the signal is getting raised down in the libc layer, so that's making me think maybe it's happening while the incoming buffer is getting filled.

@xulongwu4
Copy link

I hit this issue when using the released binary on linux. Building the binary from source makes it work properly.

@josemiguelo
Copy link

@JuanZoran's advice of rebooting the system worked for me 🤔

@deriamis
Copy link

deriamis commented Feb 1, 2023

The fact that rebooting and compiling the binary seems to "fix" the problem is further evidence of some kind of memory corruption bug. I understand that the Linux binary is compiled on Ubuntu, and dollars to donuts the "release" configuration has stack and buffer overflow protection enabled. That's what the segfault actually is - a protection mechanism.

I wouldn't trust rebooting and recompiling as a "fix". The memory corruption bug, if that's what it is (and I'm as sure as I can be without actually seeing it in the code) almost certainly still exists and will continue to cause problems. It's better to downgrade to 3.6.4 instead.

@sumneko
Copy link
Collaborator

sumneko commented Feb 1, 2023

It seems that only precompiled binaries have this problem.
Does anyone encounter this problem with binaries compiled by yourself?

@sumneko sumneko added the Info Needed More information is required label Feb 2, 2023
@koppchen
Copy link
Contributor

koppchen commented Feb 3, 2023

I believe this is fixed in the latest 3.6.9 release, but others should confirm if they're still having problems.

That version works for me with pre-compiled binaries from both vscode-lua & lua-language-server, and building locally with luamake.


Also, I was able to build this locally with luamake, and the issue was there with 3.6.7 and 3.6.8.
The 3.6.9 tag worked successfully, but only if the submodules were synced with git submodule update --init --recursive after switching from the 3.6.8 to 3.6.9 tag. So, it looks like this was related to a change in one of the submodules.

@xulongwu4
Copy link

The 3.6.9 release works for me as well.

@deriamis
Copy link

deriamis commented Feb 3, 2023

I can also confirm that v3.6.9 is working for me.

@barryblando
Copy link
Author

3.6.9 fixed the problem, I'll close the issue.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working compile Related to compiling the server from source Info Needed More information is required
Projects
None yet
Development

No branches or pull requests