elihunter173 / dirbuf.nvim

A file manager for Neovim which lets you edit your filesystem like you edit text
GNU Affero General Public License v3.0
426 stars 6 forks source link

Hash collision #20

Closed lourenci closed 2 years ago

lourenci commented 2 years ago

Hi. Thank you for the plugin.

I have got this issue very frequently. Do you have any idea whether it is a bug or a problem with my config?

image

My config:

  use {
    "elihunter173/dirbuf.nvim",
    config = function ()
      require("dirbuf").setup {
        sort_order = "directories_first",
      }
    end,
  }
elihunter173 commented 2 years ago

Hi! This is a bug. The most recent commit b8dd48f838507aa5f0c7455cefc0cda38aaeff30 should mitigate your issue, while I work on an actual fix.

The issue is that dirbuf.nvim (currently) identifies files by the hash of their absolute path, which has a chance for hash collisions. This issue can be fixed by switching from a hash to a guaranteed-unique index.

It's actually really exciting to see you found two paths that result in a collision! I knew this was technically possible, but I didn't think it would ever actually occur in real life. I suspect the long path names that are identical for the first many characters is what is causing that, so my quick mitigation just hashes the tail of the path which should result in less likely collisions.

lourenci commented 2 years ago

Got it. FYI, your quick fix solved the issues with the paths I was having the problem with.

lourenci commented 2 years ago

The same issue started to happen again in origin/HEAD. 😢 Maybe the last commit?

elihunter173 commented 2 years ago

Hrm... The latest commit still has the same hash function that my hotfix had, so that shouldn't have changed. I'll work on getting the actual fix out tomorrow. Sorry you ran into this issue

elihunter173 commented 2 years ago

This should be fixed on the no-hash branch. I'm still doing more testing since this is a semi-invasive change

lourenci commented 2 years ago

Thank you for your quick fix on that. I'll use that branch today and let you know about any issues.

elihunter173 commented 2 years ago

Closed by bec06dcb909520ab3f69c532760e1962fbca483b. Hashes can no longer collide because now we use an index!