ABA problems and pool allocation
ABA problems and pool allocation
Posted Oct 13, 2025 10:35 UTC (Mon) by chris_se (subscriber, #99706)In reply to: ABA problems and pool allocation by alison
Parent article: Progress on defeating lifetime-end pointer zapping
Well, it probably depends on specifics whether that's true or not. Internally many memory allocators also like to use pools of memory for objects with the same size, so this will strongly depend on the details of your memory allocator and/or the details on your own pool-based algorithm.
Funnily enough, since this specific ABA problem is not a "traditional" ABA problem, but is "just" about provenance, taking them from a preallocated pool of pre-created objects (not just pre-allocated memory) would solve the undefined behavior issue, because the object never gets destroyed in the sense the compiler developers are thinking about. This is different from other ABA problems where you are in fact required to use RCU, hazard pointers, double-word CAS, or similar methods to actually solve the problem. In contrast, this stack example only suffers from the ABA issue regarding the provenance of the pointer, but the assembly code generated by current compilers will work at the moment, which is not the case for the other types of ABA problems.
