[libc-commits] [libc] [libc] Implement simple lock-free stack data structure (PR #83026)

Jon Chesterfield via libc-commits libc-commits at lists.llvm.org
Mon Feb 26 09:41:47 PST 2024


JonChesterfield wrote:

ABA tag plus handwavy arguments that it's unlikely to overflow is unsound with an unfair scheduler. Failure mode goes:

thread A reads the integers, plans to commit to the first value in the stack, gets suspended
other threads do things with the stack for a while - uint32_t puts that in the ballpark of some hours
thread A gets rescheduled around the time the stack happens to have an aba counter that matches what it used to have

Bang, game over.

Haven't read the rest of the patch. CAS + ABA + unfair scheduler => broken.

https://github.com/llvm/llvm-project/pull/83026


More information about the libc-commits mailing list