Commit d0e76dbb authored by Maged Michael's avatar Maged Michael Committed by Facebook Github Bot

hazptr: Fix batch push obj

Summary:
Fix missing null check.
It is possible for a thread to successfully CAS count from >= threshold to 0 and also pop an empty list.
Example with 2 threads:
- Batch contains Threshold - 1 objects
- Thread 1 pushes an object, finds count == Threshold, CAS-es count to 0 successfully.
- Thread 2 pushes Threshold more objects, finds count == Threshold, CAS-es count to 0 successfully.
- Thread 1 pops all 2xThreshold objects (that's ok)
- Thread 2 pops 0 objects (that's ok too but we need to do null check before dereferencing the head of the list).

Reviewed By: davidtgoldblatt

Differential Revision: D17680391

fbshipit-source-id: a1d68997668077cc0b34cc66405628ed2f95702b
parent 2cc6ef64
......@@ -387,7 +387,7 @@ class hazptr_obj_batch {
while (c >= kThreshold) {
if (cas_count(c, 0)) {
List ll = l_.pop_all();
if (ll.head()->tagged()) {
if (ll.head() && ll.head()->tagged()) {
pushed_to_domain_tagged_.store(true, std::memory_order_relaxed);
}
if (kIsDebug) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment