hazptr_obj_cohort: Fix race condition
Summary: Fix race condition in hazptr_obj_cohort deactivation Race condition: - Thread T1 is doing asynchronous reclamation of objects. - Thread T2 starts deactivating cohort C. - T1 reclaims an object that its destructor retires a tagged object A that belongs to cohort C. - T1 checks that C is active. - T2 sets C.active_ to false. - T2 pops and reclaims the objects in C's list. - T1 pushes A in C's list - T2 expects to find C's list empty but it is not. Assertion failure. With the fix. - Thread T1 is doing asynchronous reclamation of objects. - Thread T2 starts deactivating cohort C. - T1 reclaims an object that its destructor retires a tagged object A that belongs to cohort C. - T1 checks that C is active. - T2 sets C.active_ to false. - **T2 waits for T1 to release the lock on the domain tagged list** - T1 pushes A in C's list - **T1 releases the lock** - **T2 cleans up C's objects in the domain tagged list** - **No subsequent asynchronous reclamation of objects in the domain will involve objects that belong to C** - T2 pops and reclaims the objects in C's list **including A** - T2 finds C's list empty as expected. Reviewed By: yfeldblum Differential Revision: D23947490 fbshipit-source-id: 943664e61190da7b4ad1bb31ac47609bdea2314d
Showing
Please register or sign in to comment