You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, recently I have been working on the next release of nano-signal-slot for some time now and have encountered a data race issue with my current iteration. Curious how others solved it I started looking into other thread safe implementations. Perusing nod I noticed the exact same signature of the issue exists in nod.
The signature is:
for (auto slot : copied_slots)
{
if (slot)
slot(args...)
}
The issue is the lock for emission is released as soon as the copied_slots is created. Due to this there is now a "potential data race" where the slot target "could" be destructed before being called in the emission loop.
Edit: Also my first attempt at resolving this is the same as how you currently test your shared disconnector in destruction. However, this would be UB now instead of a data race as accessing a class in destruction is UB.
The text was updated successfully, but these errors were encountered:
Recursive mutex would only allow for reentrancy, the slot emission race would still exist?
Your second point is what my previous Edit: was about.
However, after a year absence, I'm pretty sure there would be no UB as destruction is blocked by its own locked weak_ptr (heap owned reference counter). The block to destruction would only occur if an emission is currently taking place in a different thread as the tracked observer is being destructed.
Hello, recently I have been working on the next release of nano-signal-slot for some time now and have encountered a data race issue with my current iteration. Curious how others solved it I started looking into other thread safe implementations. Perusing nod I noticed the exact same signature of the issue exists in nod.
The signature is:
The issue is the lock for emission is released as soon as the copied_slots is created. Due to this there is now a "potential data race" where the slot target "could" be destructed before being called in the emission loop.
Edit: Also my first attempt at resolving this is the same as how you currently test your shared disconnector in destruction. However, this would be UB now instead of a data race as accessing a class in destruction is UB.
The text was updated successfully, but these errors were encountered: