jermp / pthash

Fast and compact minimal perfect hash functions in C++.
MIT License
179 stars 25 forks source link

the program crashed #66

Closed Zhao00Xu closed 1 week ago

Zhao00Xu commented 1 week ago

hello, I have a question: the function map_parallel in internal_memory_builder_single_phf.hpp, uint64_t local_num_keys = (tid != config.num_threads - 1) ? num_keys_per_thread : (num_keys - tid * num_keys_per_thread); local_pairs.resize(local_num_keys); (num_keys - tid * num_keys_per_thread) may less than 0, and then crash happened when execute "local_pairs.resize(local_num_keys)"

why don't you write some judgement to avoid the crash? justnow, my program crashed here: local_num_keys = (457 - 31 * 15) = -8

jermp commented 1 week ago

Mmmh you're right; it just should be floor(num_keys/num_threads). Thank you; fixed now.

I'll check if this bug has also been propagated to the external memory code as well.