-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Open
Labels
Description
libc uses a relaxed load
llvm-project/libc/src/__support/threads/linux/callonce.h
Lines 26 to 28 in 95820ca
| LIBC_INLINE bool callonce_fastpath(CallOnceFlag *flag) { | |
| return flag->load(cpp::MemoryOrder::RELAXED) == FINISH; | |
| } |
| if (__libcpp_acquire_load(&__flag.__state_) != once_flag::_Complete) { |
A relaxed load has no ordering constraints so if one thread calls pthread_once and another goes through the fast path, even if the other thread observes the FINISH value. What guarantees that the side effects are visible from it?