https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127757
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jonathan Wakely <[email protected]>: https://gcc.gnu.org/g:05ac72feea409f96c2b690a6f064171e274c8f91 commit r17-5118-g05ac72feea409f96c2b690a6f064171e274c8f91 Author: Jonathan Wakely <[email protected]> Date: Wed Oct 7 17:54:54 2026 +0100 libstdc++: Fix missed atomic notifying operations [PR127757] As described in the PR we can get missed wakes for atomic wait/notify operations, due to the notifier thread thinking there are no waiters and eliding the futex wake syscall. Without the full fence added by this commit the notifying thread can load _M_waiters == 0 and the waiting thread can load the old value of the atomic object, so the waiter blocks but the notifier doesn't notify. The full fence with seq_cst ordering ensures that either the waiter thread sees the new value of the atomic object or the notifier sees a non-zero count of waiters. An LLM was used to modify the original testcase so that it uses less memory and completes faster. Assisted-by: LLM libstdc++-v3/ChangeLog: PR libstdc++/127757 * src/c++20/atomic.cc (__waitable_state::_M_enter_wait): Add comment. (__waitable_state::_M_waiting): Add seq_cst fence and comments. * testsuite/29_atomics/atomic/wait_notify/127757.cc: New test. Reviewed-by: Tomasz KamiÅski <[email protected]>
