public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/104442] atomic<T>::wait incorrectly loops in case of spurious notification when __waiter is shared Date: Wed, 09 Feb 2022 20:32:30 +0000 [thread overview] Message-ID: <bug-104442-4-XrHcLdkf3y@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-104442-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104442 --- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-11 branch has been updated by Thomas Rodgers <rodgertq@gcc.gnu.org>: https://gcc.gnu.org/g:5669a60e2fcc90afaa16fe20391cdcf18ab398d7 commit r11-9547-g5669a60e2fcc90afaa16fe20391cdcf18ab398d7 Author: Thomas Rodgers <rodgert@appliantology.com> Date: Wed Feb 9 12:29:19 2022 -0800 libstdc++: Fix deadlock in atomic wait [PR104442] This issue was observed as a deadlock in 29_atomics/atomic/wait_notify/100334.cc on vxworks. When a wait is "laundered" (e.g. type T* does not suffice as a waitable address for the platform's native waiting primitive), the address waited is that of the _M_ver member of __waiter_pool_base, so several threads may wait on the same address for unrelated atomic<T> objects. As noted in the PR, the implementation correctly exits the wait for the thread whose data changed, but not for any other threads waiting on the same address. As noted in the PR the __waiter::_M_do_wait_v member was correctly exiting but the other waiters were not reloading the value of _M_ver before re-entering the wait. Moving the spin call inside the loop accomplishes this, and is consistent with the predicate accepting version of __waiter::_M_do_wait. libstdc++-v3/ChangeLog: PR libstdc++/104442 * include/bits/atomic_wait.h (__waiter::_M_do_wait_v): Move spin loop inside do loop so that threads failing the wait, reload _M_ver. (cherry picked from commit 4cf3c339815cdfa636b25a512f91b63d7c313fd6)
next prev parent reply other threads:[~2022-02-09 20:32 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-02-08 16:31 [Bug libstdc++/104442] New: " poulhies at adacore dot com 2022-02-09 0:27 ` [Bug libstdc++/104442] " rodgertq at gcc dot gnu.org 2022-02-09 8:51 ` poulhies at adacore dot com 2022-02-09 10:16 ` redi at gcc dot gnu.org 2022-02-09 15:29 ` rodgertq at gcc dot gnu.org 2022-02-09 20:31 ` cvs-commit at gcc dot gnu.org 2022-02-09 20:32 ` cvs-commit at gcc dot gnu.org [this message] 2022-02-10 8:52 ` poulhies at adacore dot com 2022-02-10 17:57 ` rodgertq at gcc dot gnu.org 2022-02-11 8:16 ` poulhies at adacore dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-104442-4-XrHcLdkf3y@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).