From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0C5323858C00; Mon, 29 May 2023 15:37:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0C5323858C00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685374674; bh=eyttHW6HgoRxqwL50o1ej3vG6+m5j2Flgn8kLGRq/n0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PvKRjuxMYblee87zQ8/nazPi10Pz2hSsy+w4Hu2WFkWIq2aauJd3nIQNqfAYUwnVr 3If5+neBc/p1rNk2wt2nUo668NdiMLMWSm0n9LutpX3ai8bUNzFCckbrebaCyAQHuU 8baIX5PHkQQp7tY1BaMpv2ELwcuQz6DwAEy6tpvU= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/110016] Possible miscodegen when inlining std::condition_variable::wait predicate causes deadlock Date: Mon, 29 May 2023 15:37:53 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 12.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status resolution Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110016 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #15 from Andrew Pinski --- (In reply to Rachel Mant from comment #14)=20 > To properly understand this problem space, why do you think locking the > mutex before setting `finished` is sufficient to fix this? It feels to us > like it shouldn't, and should only mask the bug, making it less likely to > trigger? So currently wait (and the check of finished) is under the mutex, workMutex= . If you want to modify finish, it needs to be under the same mutex. Note https://en.cppreference.com/w/cpp/thread/condition_variable mentiones = the exact fix too. And even has the following: "Even if the shared variable is atomic, it must= be modified while owning the mutex to correctly publish the modification to the waiting thread." (this part was added back in 2015: https://en.cppreference.com/mwiki/index.php?title=3Dcpp/thread/condition_va= riable&diff=3D81211&oldid=3D80448 ) So I think I can now close this as invalid.=