News for hackers. Stuff that matters.
Re:Solving the ABA Problem in Rust with Tagged Pointers by wat10000 on Friday February 14, 2025 @09:13AM (#43048463)
The problem isn’t the mutability of the State object, but the mutability of the pointer to it.

Your approach works in Java, but it only works if you have a garbage collector that can ensure the memory is not freed until there are no extant pointers to it, or you never free the objects. The ABA problem occurs when one writer reads the old pointer, another writer swaps out the pointer and frees the old object, a third writer allocates a new object that happens to be placed at the exact same location as the first one, then the first writer does its compare-and-swap.

There are no comments on this comment yet.