elihunter173/dirbuf.nvim

Hash collision

lourenci opened this issue · 7 comments

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,
  }

Hi! This is a bug. The most recent commit b8dd48f 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.

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

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

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

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

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

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