-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Potential Bug #3
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, first thanks for your amazing work!
I found here may be a potential bug:
First you tried to lock the bucket:
if (bucket.state.compare_exchange_strong(bucketState, Bucket::State::BUSY, std::memory_order_relaxed))
Then you write key (and value) in:
bucket.entry.first = std::move(key);
Finally your change the state of the bucket to mark its state as ready:
bucket.state.store(Bucket::State::VALID, std::memory_order_release); // mark the bucket as valid
The problem, I think, lies in the situation when two threads try to insert the same key into the hashtable:
The two threads can probably insert the same key into two different buckets - when one thread already applied a free bucket but hasn't saved the key inside. At this time, the second thread cannot see the key in the table so it would apply a new bucket for that key.
The text was updated successfully, but these errors were encountered: