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++/99537] Wrong memory_order used in stop_token ref-counting
Date: Mon, 29 Mar 2021 20:03:27 +0000	[thread overview]
Message-ID: <bug-99537-4-7LKkEZjUwm@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-99537-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99537

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:ad9ae82ed1c33e1803f33bb367b0b4c9ee2e3e63

commit r10-9594-gad9ae82ed1c33e1803f33bb367b0b4c9ee2e3e63
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Mar 11 16:44:57 2021 +0000

    libstdc++: Use acq_rel memory ordering [PR 99537]

    As Lewis Baker wrote in the PR:

    > The 'fetch_sub()' operation in _M_release_ownership() should be using
    > memory_order::acq_rel instead of memory_order::release. The use of
    > 'release' only is insufficient as it does not synchronise with any
    > corresponding 'acquire' operation.

    > With the current implementation, it's possible that a prior write to
    > one of the _M_value or _M_head data-members by a thread releasing the
    > second-to-last reference might not be visible to another thread that
    > releases the last reference and frees the memory, resulting in
    > potential write to freed memory.

    This simply changes the memory order to acq_rel as suggested.

    libstdc++-v3/ChangeLog:

            PR libstdc++/99537
            * include/std/stop_token (_Stop_state_t::_M_release_ownership):
            Use acq_rel memory ordering.

    (cherry picked from commit 15825b17cf3fbf28181c51fe94a2898f448f915c)

  parent reply	other threads:[~2021-03-29 20:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-11  2:00 [Bug libstdc++/99537] New: " lewissbaker.opensource at gmail dot com
2021-03-11 13:34 ` [Bug libstdc++/99537] " redi at gcc dot gnu.org
2021-03-11 17:53 ` cvs-commit at gcc dot gnu.org
2021-03-11 17:53 ` cvs-commit at gcc dot gnu.org
2021-03-29 20:03 ` cvs-commit at gcc dot gnu.org [this message]
2021-03-29 21:36 ` redi at gcc dot gnu.org

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-99537-4-7LKkEZjUwm@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: link
Be 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).