Skip to content

Conversation

@hugoam
Copy link

@hugoam hugoam commented Oct 17, 2024

Hello

We encountered this, which I believe is a bug, in our usage of ExcaliburHash

Basically, if a HashMap has only Tombstones left, but no Empty slots anymore, emplace() will loop infinitely

My attempt to fix, with a very rough understanding of linear probing and tombstones, is that once we've completed a loop over all elements (reached startItem) we can safely insert in the first encountered tombstone as we are sure there are no duplicate keys

@hugoam hugoam force-pushed the fix-emplace-no-empty-infinite-loop branch from 8e595b5 to fb159c4 Compare October 17, 2024 11:31
@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (b99119a) to head (fb159c4).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #14   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            6         6           
  Lines         1325      1326    +1     
=========================================
+ Hits          1325      1326    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@SergeyMakeev
Copy link
Owner

I fixed the issue with the infinite loop by using a slightly different approach: ae73086

Now, in emplace(), we take into account both occupied slots and tombstone slots.
This prevents "poisoning" the hash_map and helps avoid the infinite loop issue, improving performance in general.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants