Tessil / robin-map

C++ implementation of a fast hash map and hash set using robin hood hashing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Robin_map:find() causing segmentation faults

moxSedai opened this issue · comments

robin_hash::dist_from_ideal_bucket() is causing segmentation faults when accessed via robin_map::find()

Thanks for the report.

Could you try to set a TSL_DEBUG global define (-DTSL_DEBUG) and enable assert (avoiding using NDEBUG) and see if any assert is triggered?

Do you have any code example to reproduce the problem?

How would I set that? I'm extremely amateur and just running into this while working on a personal project. I'm looking through to make sure that everything is actually initialized.

You'll need to pass the -DTSL_DEBUG flag to the compiler command line (if you use gcc or clang) or add_definitions to CMake or /DTSL_DEBUG is you use Visual Studio.

If you eventually have a small example to reproduce the problem, I could look into it.

I believe this is also related with issues in this ticket: #52

@gabrieltanase42 The above issue should not cause a segmentation fault in the find but an infinite loop.

Looking at the find implementation, a segfault during the dist_from_ideal_bucket() call could be because we access a non-existing bucket. As the ibucket is bounded between [0, bucket_count()) by next_bucket the problem could come from calling find through an invalid or null tsl::robin_map/set pointer or an invalid reference, a custom GrowthPolicy with a wrong bucket_for_hash implementation, a m_buckets which is not of size bucket_count or some corner case bug in the hash map itself with an empty map.

@maxerature As you mention "make sure that everything is actually initialized", how do you use the robin_map/set? Through a pointer or reference? Are you sure the pointer is not null? As a nullptr would exhibit this kind of error.

I'll close the issue for now. @maxerature make sure you're not using the map trough a null-pointer or invalid reference and if you still encounter the error, don't hesitate to reply and I'll re-open the issue.

I got this issue as well.
It is hard to reproduce. My local small scale test works.
It only happens when I run it in real-world data with a pretty large scale.

I switched to hopscotch_map, it also has this issue..

It turns out that my segmentation fault issue is not from robin_map, but my usage of std::queue.