martinus / robin-hood-hashing

Fast & memory efficient hashtable based on robin hood hashing for C++11/14/17/20
https://gitter.im/martinus/robin-hood-hashing
MIT License
1.52k stars 146 forks source link

Crashing with overflow_error #64

Closed morispi closed 4 years ago

morispi commented 4 years ago

Hello,

I am currently trying to integrate robin hood hashing into my project. As mentioned on your github, I simply included the robin_hood.h and used robin_hood::unordered_map instead of std::unordered_map.

However, upon start, my program crashes and reports the following error:

terminate called after throwing an instance of 'std::overflow_error' what(): robin_hood::map overflow Command terminated by signal 6

Do you have any idea what could cause this?

Thanks!

Cheers, Pierre

martinus commented 4 years ago

hi, what hash are you using?

martinus commented 4 years ago

robin_hood needs a good hash to work. For integral types robin_hood::hash is used which usually is excellent

morispi commented 4 years ago

Hi,

Sorry for answering so late. I didn't modify nor specify any particular hash. How / where am I supposed to specify it?

The github guidelines only mention: Add robin_hood.h to your C++ project. Use robin_hood::unordered_map instead of std::unordered_map Use robin_hood::unordered_set instead of std::unordered_set

I'm a bit lost here.

Thanks, Pierre

jmousel commented 4 years ago

I've seen this same issue when using a hashmap of ints. I found a successful workaround was to use the Murmur3 finalizer defined in robin_hood.h instead of the umul128 hasher.

martinus commented 4 years ago

I've replaced the current hash in master Could you try again?

morispi commented 4 years ago

Just checked, seems to work pretty well! Thanks for the fix.

Cheers, Pierre