Incorrect util-hash behavior

In util-hash.c I have observed some behavior that is unexpected and likely incorrect. To see this behavior, create a hash table 32 entries wide and use the default hash function. Then add a short string “abc”, observe the string is stored properly. Now remove a string “iln”, and observe string “abc” is no longer in the table.

Other scenarios can provoke this behavior but this is possibly the simplest way. It occurs because if the table slot has one entry, remove does not perform a compare before removal.

I have a unit test patch to show this, and a fix patch to make it behave as a typical hash table would behave. The behavior goes back to at least 6.0 and continues into the current 8.0.1 work branch.

Hello,

Thanks for the report, you’ve mentioned that you have a possible patch and unit test that showcases this. Could you please then share those in a pull request, so it’s easier for the team to visualize and review the behavior – and, if the bug is confirmed, for us to test and merge your contribution, once it’s ready? :slight_smile:

I’ve opened issue “Bug #7828” and PR " Clv/fix hash collision issue #13633" is submitted if I’ve navigated properly.

Thanks!

1 Like