Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

bug: full freeze of Neovim on file reload #1581

Closed
3 tasks done
emersonford opened this issue Oct 4, 2023 · 25 comments · Fixed by #1585
Closed
3 tasks done

bug: full freeze of Neovim on file reload #1581

emersonford opened this issue Oct 4, 2023 · 25 comments · Fixed by #1585
Labels
bug Something isn't working

Comments

@emersonford
Copy link

emersonford commented Oct 4, 2023

Did you check docs and existing issues?

  • I have read all the LazyVim docs
  • I have searched the existing issues of LazyVim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

0.9.1 & 0.9.2

Operating system/version

Linux & macOS Sonoma

Describe the bug

I've been experiencing what effectively feels like a deadlock on file reloads after updating to the latest version of LazyVim. I'm fairly confident this is due to LazyVim as I am able to consistently reproduce the issue with:

require("lazy").setup({
  spec = {
    -- add LazyVim and import its plugins
    { "LazyVim/LazyVim", import = "lazyvim.plugins", commit = "f1ce07510d2048e33fec2b609814d68a7175d591" },
    -- import/override with your plugins
    { import = "plugins" },
  },
  ...
})

but am not able to reproduce the issue when I use the immediate previous commit 364bcf325d91a06e6bd6516bdfed84399566cdb6.

I've been trying to get a sense of what exactly is triggering this deadlock-like behavior, but haven't had much luck. The farthest I've gotten is using:

debug.sethook(function()
        local file = io.open("/home/emersonford/Downloads/nvim_bt", "a")
        file:write(debug.traceback("backtrace"))
        file:close()
end, "c", 43)

which spits out a file dominated by the following callstack:

/usr/share/nvim/runtime/lua/vim/treesitter/_fold.lua:190: in function 'get_folds_levels'
/usr/share/nvim/runtime/lua/vim/treesitter/_fold.lua:249: in function 'fn'
/usr/share/nvim/runtime/lua/vim/treesitter/_fold.lua:236: in function </usr/share/nvim/runtime/lua/vim/treesitter/_fold.lua:232

I do see a comment about infinite recursion here: https://github.com/neovim/neovim/blob/1e7e9ee91f73c62b8c5ba9dbdabba3a3b6dc0130/runtime/lua/vim/treesitter/_fold.lua#L280

not sure if this is related?

Steps To Reproduce

  1. Open a file with formatting issues.
  2. Run formatter outside of Neovim (e.g. cargo fmt in a separate tmux pane).
  3. Neovim should now be completely unresponsive, only way to quit Neovim is with kill -9.

Expected Behavior

Neovim should not freeze.

@emersonford emersonford added the bug Something isn't working label Oct 4, 2023
@folke
Copy link
Collaborator

folke commented Oct 4, 2023

This it not a LazyVim issue.
Might be related to this setting: vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()".

Report an issue upstream if that's what's causing it.

@folke folke closed this as not planned Won't fix, can't repro, duplicate, stale Oct 4, 2023
@davidsteinberger
Copy link

I just ran into the same. It is indeed caused/realted to value of vim.opt.foldmethod.
Setting this to vim.opt.foldmethod = "manual" in options.lua fixes it for me at the expense of not having folds.
How do others deal with that?

@folke
Copy link
Collaborator

folke commented Oct 4, 2023

It's clearly a bug.
Make sure to report an issue in the Neovim repo. I can't reproduce this.

@folke folke reopened this Oct 4, 2023
@folke
Copy link
Collaborator

folke commented Oct 4, 2023

Can you try to see if Nightly solved this? If so I will change the defaults so that it only is enabled on nightly.

@delice0 same for you

@fredrikaverpil
Copy link
Contributor

FWIW, I've been experiencing freezes today as well, but I'm not at my computer at the moment.

@folke
Copy link
Collaborator

folke commented Oct 4, 2023

This seems to have been fixed in this PR: neovim/neovim#24230 (comment)

@folke
Copy link
Collaborator

folke commented Oct 4, 2023

If someone can confirm it works on nightly, then I'll just disable the feature for now on 0.9.x

@folke
Copy link
Collaborator

folke commented Oct 4, 2023

@fredrikaverpil are you on 0.9.2 or a recent nightly?

@idelice
Copy link

idelice commented Oct 4, 2023

vim.opt.foldmethod = "manual"

I'm not sure what "nightly" means in this context, but vim.opt.foldmethod = "manual" fixed it for me for now.

@folke
Copy link
Collaborator

folke commented Oct 4, 2023

That's not a fix. With nightly I mean on Neovim nightly. So a recent NEovim build.

@fredrikaverpil
Copy link
Contributor

@fredrikaverpil are you on 0.9.2 or a recent nightly?

0.9.2

@jyuan0
Copy link
Contributor

jyuan0 commented Oct 4, 2023

@folke seems to be working on nightly (commit: 248305cf3). I formatted a simple Rust file with cargo fmt outside of Neovim, and Neovim is still responsive.

@folke
Copy link
Collaborator

folke commented Oct 4, 2023

@jyuan0 and you get freezes on 0.9.2 as well?

I can't reproduce it on either at the moment.

@jyuan0
Copy link
Contributor

jyuan0 commented Oct 4, 2023

@jyuan0 and you get freezes on 0.9.2 as well?

Sorry, I don't have a build of 0.9.2 handy for testing.

@kingedward35
Copy link

I also experience the same issue and I am on 0.9.2.

@folke
Copy link
Collaborator

folke commented Oct 4, 2023

Still the same. I need someone to confirm:

  • it freezes on 0.9.2
  • it does not freeze on 0.10 (nightly)

Alternatively if someone can give me steps to reproduce I can test it myself.

@kingedward35
Copy link

I don't know if this will help, but I can see the issue after I update to the latest version of LazyVim and then restart NeoVim and open a file. I don't see it when the splash screen shows up upon opening, but only when I open a file. Hope that helps. And thanks.

@folke folke closed this as completed in d989ecc Oct 4, 2023
@folke
Copy link
Collaborator

folke commented Oct 4, 2023

I just pushed a changed to enable treesitter folding only on 0.10

@kevintraver
Copy link
Contributor

Working again in 0.9.2

Still freezes in 0.10

Specifically when opening telescope symbols require("telescope.builtin").lsp_document_symbols() in a larger file (5000 lines)

@folke
Copy link
Collaborator

folke commented Oct 4, 2023

just tested with a 12000 lines lua file and have no issues

@davidsteinberger
Copy link

davidsteinberger commented Oct 4, 2023

@folke here's a repro that breaks for me on neovim 0.9.2.

repro.lua:

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
	vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
	vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath })
end
vim.opt.runtimepath:prepend(lazypath)

require("lazy").setup({
	spec = {
		-- add LazyVim and import its plugins
		{ "LazyVim/LazyVim", commit = "3849e0150b0a616dbd6e7e12ec5025aff6c81d39", import = "lazyvim.plugins" },
		-- { "LazyVim/LazyVim", commit = "d989ecc943b3240db0be3aa0369b96089cee4b40", import = "lazyvim.plugins" },
		-- import any extras modules here
		{ import = "lazyvim.plugins.extras.lang.typescript" },
	},
})
echo '{}' > test.json
nvim -u repro.lua test.json

Then in Lazyvim execute command :e.
Note: d989ecc fixes it for me in neovim 0.9.2.

@folke
Copy link
Collaborator

folke commented Oct 4, 2023

Great, thanks! I can reproduce this on 0.9.2.

It works correctly on 0.10.0, so all good :)

@dannyfritz
Copy link

Probably not the most useful comment, but I was dealing with this at work today and was just logging on now to report it. Glad to see it is sorted out already. I tested LazyVim 9.0.2 on Neovim 0.9.2 and can also confirm all is well here. :)

@clason
Copy link

clason commented Oct 12, 2023

Pro tip: not reporting bugs ensures that they will never be fixed (or the fix backported, in this case).

@folke
Copy link
Collaborator

folke commented Oct 12, 2023

Right, didn't think about backporting. Thanks!

jeffutter added a commit to jeffutter/nixpkgs that referenced this issue Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants