Conversation
This PR can create deadlocks - there is nothing synchronizing the mutex/condvar with the `Arc` of the `Zalsa`, therefore code may wake up by the `Condvar` but not see an updated refcount, go to sleep again, and never wake up.
✅ Deploy Preview for salsa-rs canceled.
|
CodSpeed Performance ReportMerging #1039 will improve performances by 4.12%Comparing Summary
Benchmarks breakdown
|
|
Are you saying we might notify in a drop, see the current strong count, then decrement due to drop finishing, and the loop is already in a waiting state again? |
|
@Veykril Not exactly, rather this is a cache coherency thing. There is no happens-before relationship, so the CPU does not guarantee that the thread waking up due to the notify will see the refcount decrement. |
|
Right, Either way you are correct that change was invalid. (odd this hasn't blown up more) |
|
Even with an |
|
There is actually a happens-before relationship here because of drop order (though we do need |
|
@ibraheemdev There isn't, or rather, not strong enough: you're right that (assuming we'd use
There is a reason |
|
@ChayimFriedman2 yes, that is what I meant by missed wakeups, and needing to hold the lock while decrementing the count.
I only meant to say that the comment here is not exactly true, because if there is a true wakeup, you are guaranteed to see the new count (even without |
This PR can create deadlocks - there is nothing synchronizing the mutex/condvar with the
Arcof theZalsa, therefore code may wake up by theCondvarbut not see an updated refcount, go to sleep again, and never wake up.