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
{{ message }}
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.
Suppose you have two retain_ptr smart pointers pointing to the same object and its reference count is 2. Then, both retain_ptr smart pointers are destructed in different threads. In each thread, fetch_sub decrements the reference count, so it goes from 2 to 1 and then to 0. Then in each thread, use_count returns 0 and both threads delete the same object. decrement should instead check what value fetch_sub returned, so that only the thread that changed the reference count to 0 deletes the object.
This seems to delete the object when the reference count decreases to any nonzero value. It should delete when the reference count decreases to zero. Commit 898a4fd in PR #6 fixes that.
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
In
template <class T> struct retain_traits
, thedecrement
functions seem to delete the object in the wrong situations:Suppose you have two
retain_ptr
smart pointers pointing to the same object and its reference count is 2. Then, bothretain_ptr
smart pointers are destructed in different threads. In each thread,fetch_sub
decrements the reference count, so it goes from 2 to 1 and then to 0. Then in each thread,use_count
returns 0 and both threads delete the same object.decrement
should instead check what valuefetch_sub
returned, so that only the thread that changed the reference count to 0 deletes the object.This seems to delete the object when the reference count decreases to any nonzero value. It should delete when the reference count decreases to zero. Commit 898a4fd in PR #6 fixes that.
The text was updated successfully, but these errors were encountered: