Race Condition using CHashMap::alter with many (40+) threads
I am using CHashMap as the backing storage for memorization of expensive computation. The computation is parallelized with Rayon and stored in the hashmap, if the result does not exist yet. For this I use the
CHashMap::alter function, as it allows me to perform a
get_or_insert_new type of operation.
If I scale this to many threads, I can reliably cause thread panics.
thread '<unnamed>' panicked at 'No free buckets found', src/libcore/option.rs:1187:5
The stacktrace does not mention any function of chashmap, probably due to inlining, which is why I ommit it here. However, the error message points to this line in lib.rs:333.
I cannot reproduce this issue if I set
RAYON_NUM_THREADS=30, but with 40 threads it is already quite reliable if not 100% reproducible. More threads make the problem better reproducible.