Skip to content

nvim gets stuck when finding a file in a directory with a looping symlink #1480

Closed
@archiif

Description

@archiif

Description

When navigating up to a large directory (e.g. from C:\large-directory\subdirectory to C:\large-directory) that contains a looping symlink (e.g. C:\large-directory\loop -> C:\large-directory), nvim will try to find the previously selected file (e.g. C:\large-directory\subdirectory\neat.file).
But that looping symlink will make nvim loop through the directory again and again, causing it to lock up while its RAM usage gradually grows larger and larger (>1GB).

Neovim version

NVIM v0.8.0-dev-739-ge59bc078d
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compiled by runneradmin@fv-az158-506

Features: -acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM\sysinit.vim"
  fall-back for $VIM: "C:/Program Files (x86)/nvim/share/nvim"

Run :checkhealth for more info

Operating system and version

Microsoft Windows [Version 10.0.19043.1826]

nvim-tree version

451901c

Minimal config

-- Yes, this bug occurs with this minimal config as it is
vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvt-min/site]]
local package_root = "/tmp/nvt-min/site/pack"
local install_path = package_root .. "/packer/start/packer.nvim"
local function load_plugins()
  require("packer").startup {
    {
      "wbthomason/packer.nvim",
      "kyazdani42/nvim-tree.lua",
      "kyazdani42/nvim-web-devicons",
      -- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
    },
    config = {
      package_root = package_root,
      compile_path = install_path .. "/plugin/packer_compiled.lua",
      display = { non_interactive = true },
    },
  }
end
if vim.fn.isdirectory(install_path) == 0 then
  print "Installing nvim-tree and dependencies."
  vim.fn.system { "git", "clone", "--depth=1", "https://github.com/wbthomason/packer.nvim", install_path }
end
load_plugins()
require("packer").sync()
vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua setup()]]
vim.opt.termguicolors = true
vim.opt.cursorline = true

-- MODIFY NVIM-TREE SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
_G.setup = function()
  require("nvim-tree").setup {}
end

Steps to reproduce

  1. mkdir /tmp/crasher && cd /tmp/crasher
  2. mkdir ./a_{0..500}
  3. ln -s ./ ./loop
  4. mkdir ./z && touch ./z/cool.file
  5. Open nvim and toggle nvim-tree
  6. Navigate into the z folder with Ctrl+]
  7. Navigate back up using -

I also followed the suggestion in #549 (comment) and what happens in the logs is that after START find file C:\Users\foo\AppData\Local\Everything\Everything.db, [watcher] Watcher:new events are spawned on throughout all folders in C:\Users\foo\AppData\Local over and over again, looping back and forth hundreds of times. The log file weighs tens of megabytes when I crashed nvim.

Expected behavior

nvim doesn't lock up

Actual behavior

nvim locks up, while its RAM usage gradually grows larger and larger (>1GB)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions