From patchwork Thu Sep 16 22:14:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Rodgers X-Patchwork-Id: 1529090 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; dkim=pass (4096-bit key; secure) header.d=kolabnow.com header.i=@kolabnow.com header.a=rsa-sha256 header.s=dkim20160331 header.b=L3w+4b3h; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4H9WpZ1D2rz9sPf for ; Fri, 17 Sep 2021 08:24:21 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8C5CB385BF84 for ; Thu, 16 Sep 2021 22:24:19 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from ext-mx-out002.mykolab.com (mx.kolabnow.com [95.128.36.41]) by sourceware.org (Postfix) with ESMTPS id EBF41385AC1D; Thu, 16 Sep 2021 22:14:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EBF41385AC1D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=appliantology.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=appliantology.com Received: from localhost (unknown [127.0.0.1]) by ext-mx-out002.mykolab.com (Postfix) with ESMTP id 81AE41300; Fri, 17 Sep 2021 00:14:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kolabnow.com; h= content-transfer-encoding:mime-version:message-id:date:date :subject:subject:from:from:received:received:received; s= dkim20160331; t=1631830469; x=1633644870; bh=hMlUV2u17KG2nKxkYsh Q4KZmFmE4yOqbIHt0q0mQw1I=; b=L3w+4b3heQ1Dwy/Exqu3CRH4yjVEpsEDz+9 Mm0iVIuPpezwYOr8oigzX+/0yADlIHIyMVDjEamf0TcWmoSybf18w4u5hljRCJYI Z8IL9ndpF9KFR/Lw1U9p/fd0PcCRL2O9pRhuIZDTjr0Ak4fbS/fpnxL2KKmiJo8U ho3CWCG44L/F2GvjKH/nimyffs++UXBwjHmZKM7ZYFozk5dOBco9/3de7uShTDSZ EQnQa9ohWdeKpWuwcYsRkA1E3/Yindx/pht0HLAmOwETfK8bQqSF9JKzGL2cSjHD f3p8FvY+GVu8dVR1lluh5RvKwJ8o0KSAyb22ku8pvOtMMfC8akfs/30fD17gEhn/ chGPicTYP0988Ll3vrtQdh9ZjAOzebKDcOEpJCnuTSQcsaIWTPFzJzBO5lzNwk3c 9q3VLLnkxiwR8bvXvk30wQQW5OFQ5fM7/MOS5dk6U1GNPFJYzg+kkp1A3J2koFuA 4MQPZa7RQFk+veAG+f1DKqks6FO2GAijp7tHbjGqhfk/HxgexIBbXb7mjWct5wbE TnNNVFoQSAO4PVmpotxttyi3f6TNcljRKog7Qs42eFNpNdwndCQgYlFe0+fZj79Z 0/ylN8AVc2GtZ9bV29q/FxiDY8ewm1qzLh1iQYxjP7kolQQpzLZHrNcFmq5f3tOg JsqsILE8= X-Virus-Scanned: amavisd-new at mykolab.com X-Spam-Score: -1.899 X-Spam-Level: X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 Received: from ext-mx-out002.mykolab.com ([127.0.0.1]) by localhost (ext-mx-out002.mykolab.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id d1xNHkXBwh5j; Fri, 17 Sep 2021 00:14:29 +0200 (CEST) Received: from int-mx001.mykolab.com (unknown [10.9.13.1]) by ext-mx-out002.mykolab.com (Postfix) with ESMTPS id F3EAC12F9; Fri, 17 Sep 2021 00:14:28 +0200 (CEST) Received: from ext-subm001.mykolab.com (unknown [10.9.6.1]) by int-mx001.mykolab.com (Postfix) with ESMTPS id EBBB7389; Fri, 17 Sep 2021 00:14:27 +0200 (CEST) From: Thomas Rodgers To: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Subject: [PATCH] libstdc++: Fix UB in atomic_ref/wait_notify.cc [PR101761] Date: Thu, 16 Sep 2021 15:14:08 -0700 Message-Id: <20210916221408.602576-1-rodgert@appliantology.com> MIME-Version: 1.0 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: trodgers@redhat.com, Thomas Rodgers Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" From: Thomas Rodgers Remove UB in atomic_ref/wait_notify test. Signed-off-by: Thomas Rodgers libstdc++-v3/ChangeLog: PR libstdc++/101761 * testsuite/29_atomics/atomic_ref/wait_notify.cc (test): Use va and vb as arguments to wait/notify, remove unused bb local. Tested x86_64-pc-linux-gnu, committed to master. Ok to backport to releases/gcc-11? --- .../testsuite/29_atomics/atomic_ref/wait_notify.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_ref/wait_notify.cc b/libstdc++-v3/testsuite/29_atomics/atomic_ref/wait_notify.cc index b75e27617f7..b41d1ac0bb7 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic_ref/wait_notify.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic_ref/wait_notify.cc @@ -33,15 +33,14 @@ template if constexpr (std::atomic_ref::is_always_lock_free) { S aa{ va }; - S bb{ vb }; std::atomic_ref a{ aa }; - a.wait(bb); + a.wait(vb); std::thread t([&] { - a.store(bb); + a.store(vb); a.notify_one(); }); - a.wait(aa); + a.wait(va); t.join(); } }