jonhoo / haphazard

Hazard pointers in Rust.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

eager_reclaim doesn't decrement retired.count causing panics in HazPtrDomain::drop

soruh opened this issue · comments

commented

I have been playing around with optionally fully checking using the wrong domain at runtime. My implementation does seem to work (should I make a PR to discuss it?) but one of my tests still fails.

It seems the cause of this aren't my changes but rather a bug in eager_reclaim.
Changing the feels_good test on the current main branch to use a local domain also causes it to fail.
The problem seems to be the following:

  • retire increments the retired.count and the number of reclaimable objects
  • eager_reclaim relcaims the reclaimable objects but doesn't decrement retired.count
  • HazPtrDomain::drop asserts that it can reclaim retired.count objects (which it obviously can't)

I'd guess the fix would just be to have eager_reclaim do a retired.count.fetch_sub(n_reclaimed) with the result of the bulk_reclaim but I'm not 100% certain.
Would that be the best way to fix this?

EDIT: adding the fetch_sub in eager_reclaim makes both my test and the modified feels_good pass, by the way.

commented

fixed

BTW, see #10 if you want to take a stab at CI :)