On Mon Jul 3 19:55:43 2023 +0000, Rémi Bernon wrote:
I'm a bit tired and this is kinda complicated, so please don't mind if
I just rehash the issues real quick to avoid misunderstanding. No worries at all.
For clarification, you mean A passing the check `!impl->ref_public` in
`Resolve`, then B calling `Release` and getting a 0, while A gets a valid Object. We need to have both calls either fail or succeed. Correct? Correct.
Second problem is, when incrementing the count in `Resolve` we could
miss that `if (!ref)` in `geolocator_Release`. Right? So we could just always add/release the weak reference in the geolocator. Yes, the alternative solution would be to duplicate the `geolocator_Release` check in `Resolve`, but it gets a bit awkward and error prone.
Actually I think I missed the case where multiple threads are calling IWeakReference_Resolve concurrently. My suggestion is not behaving correctly there, as increasing public refcount by 1 may make other threads to succeed. Maybe a separate "invalid" field would be better but I need to think about it.
I suggest to leave this aside for now and only include the changes that do not touch weak references yet, I think they look good now.