From patchwork Fri Feb 2 10:28:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 195783 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp333200dyc; Fri, 2 Feb 2024 02:30:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IFtlgFr9c3NAOsH9PdXYw6UZvLlAqTsPmXVU3Ak+DFxjpnCpxc+f7eqRHKUbk6ANmpi1lq/ X-Received: by 2002:a0d:e28d:0:b0:5d4:90a:c3bc with SMTP id l135-20020a0de28d000000b005d4090ac3bcmr7080410ywe.30.1706869805496; Fri, 02 Feb 2024 02:30:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706869805; cv=pass; d=google.com; s=arc-20160816; b=Y5rVQbUWp+HMcb4z2Q2vW0Aubk6CKCGx4tHxIk7bhC4K7HiZk+iG9nO6V7OCJGZOV3 85wyn2ZPvCJAzMsMl2pVXcA284pOfYmVkP3yOQokiaVZ9jWUz7+KITbqkeqlthzbAx6Y sX0+b7t/a6aj7CXtt7yG5kZef0n6O3LYa57pcR5WK3fW5rBGRvrIII88jLdgxwFw1BIh My/8FXCa9rADMFZ8g4i2/YIi1iH395bCFI9+Hm2vtDKUqUyj3U4qU/3PXHzBiEzAIEqb wcOTVo8gl/TGH1u5WlzvO7Q6tYqtQWOX4bLQn6sSDtYg1OZDyo1E9ZgeDUXSYNBgmdOQ rR/Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=ciJ0PZlhVNYPKjjvhVy5ABGlifkRol2CQD9fFR8EauI=; fh=a1JeyoUGT1NfH+2qMwGG34/77DKVHwG7IxelU3JLge0=; b=DbOHqZf8fUnpnvXxu+iXjdOHWu7tJ6e4xYXPMJIbIa7S8woADTDRJ+fXHG42HE71JX f3LI7bKnqckssfqF3WJgfx81XJnCUzSKkDUOgwZ1ImD88UUTgpCn+817T4dAfKNc/Tap dpD4+YrzrmbrMYBO2crY/yEr0xCPENtJfQRWAilGia146uqMAaDhEdaF0kxbgZi0kqNx KSyI+C1kQi1jBJN1/t0lJR5i2gYbmy723fP517TBP6PArT/rnoCwXy0VE7VXfLdWAhCz VL73xqX+gGLObPeJK4mIfhsNjzVv/3KGUjzaKVqnqYM4hXTfMVNx7bW3OAcjsRFhD2/z WVYA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YZQgENlz; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCUUlBG6nPQmt6+XtGfDyXAwbDSMDxUbgoNXCd74t8txEnI2Ql2s6SOWCHpEUlOEUVIrZkv/jwmEZsR39OJuMTtZyHGuAA== Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id o4-20020a05622a008400b0042a87d0cfa7si1719226qtw.159.2024.02.02.02.30.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 02:30:05 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YZQgENlz; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 29B0F385802B for ; Fri, 2 Feb 2024 10:30:05 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 201DF3857BBC for ; Fri, 2 Feb 2024 10:28:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 201DF3857BBC Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 201DF3857BBC Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706869737; cv=none; b=ikQcqEpstUgejq5mI1z5ETM4pMPWq+Zce1EZyignrcfadx9jjy+Pg/bjwW8mpDO/doP/A6WpDvrvFW+SJBWR4sBMuUM+A7EJ2cY+WvdJfuUiaKQpE7A9ewdKxKxdDpi+eKXUsJCISQoYNYHESOgX60XA1G5KoFja18ZC+igyLUo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706869737; c=relaxed/simple; bh=28a/YkCyVFrtyuxqGMW7R8wnVTC/QUobNC8E+01IXkw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=UdwBUUgWVQQqLeY4pwoerBWVCrRy+Pn6dbGiBQHLfUqplxYJ0KRoY292hY3S2pujIU5ZtOCjdb7Sd0vvzK6s3deJFn79EFTTNWk3OgaWAEUGCAZkdoy5vAalSmx2VGkEsOsnI1CSTIqKY5Xy0VER3L8XQ3f1vqghg3EDvM6iogw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706869734; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ciJ0PZlhVNYPKjjvhVy5ABGlifkRol2CQD9fFR8EauI=; b=YZQgENlz96u7q0NUQwijLVFX6UZjKeAIyBERzqcXmFaQhosj2INxm7dX0gvRuh+nCUzNVF S++gvm7ZPC+JGJuFHcYyQJLbupw0JC/KTF9SX2Ob8ii+Y05aRJ+3jPoKV/TGv5TlDDiHxI BBrfgCOiw7PY8YPZaekfw3eaO680bCE= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-433-NEIXKqgAPcuvKozeSrDbFw-1; Fri, 02 Feb 2024 05:28:51 -0500 X-MC-Unique: NEIXKqgAPcuvKozeSrDbFw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 421863806702; Fri, 2 Feb 2024 10:28:51 +0000 (UTC) Received: from localhost (unknown [10.42.28.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F3781C060B1; Fri, 2 Feb 2024 10:28:50 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Cc: =?utf-8?q?Fran=C3=A7ois_Dumont?= Subject: [committed 1/2] libstdc++: Avoid reusing moved-from iterators in PSTL tests [PR90276] Date: Fri, 2 Feb 2024 10:28:07 +0000 Message-ID: <20240202102846.2241323-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789782713064213930 X-GMAIL-MSGID: 1789782713064213930 Tested x86_64-linux. Pushed to trunk. -- >8 -- The reverse_invoker utility for PSTL tests uses forwarding references for all parameters, but some of those parameters get forwarded to move constructors which then leave the objects in a moved-from state. When the parameters are forwarded a second time that results in making new copies of moved-from iterators. For libstdc++ debug mode iterators, the moved-from state is singular, which means copying them will abort at runtime. The fix is to make copies of iterator arguments instead of forwarding them. The callers of reverse_invoker::operator() also forward the iterators multiple times, but that's OK because reverse_invoker accepts them by forwarding reference but then breaks the chain of forwarding and copies them as lvalues. libstdc++-v3/ChangeLog: PR libstdc++/90276 * testsuite/util/pstl/test_utils.h (reverse_invoker): Do not use perfect forwarding for iterator arguments. --- libstdc++-v3/testsuite/util/pstl/test_utils.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libstdc++-v3/testsuite/util/pstl/test_utils.h b/libstdc++-v3/testsuite/util/pstl/test_utils.h index ed6d48b9471..e35084eabb2 100644 --- a/libstdc++-v3/testsuite/util/pstl/test_utils.h +++ b/libstdc++-v3/testsuite/util/pstl/test_utils.h @@ -1083,18 +1083,18 @@ struct iterator_invoker template struct reverse_invoker { - template + template void - operator()(Rest&&... rest) + operator()(Policy&& exec, Op op, Rest&&... rest) { // Random-access iterator - iterator_invoker()(std::forward(rest)...); + iterator_invoker()(std::forward(exec), op, rest...); // Forward iterator - iterator_invoker()(std::forward(rest)...); + iterator_invoker()(std::forward(exec), op, rest...); // Bidirectional iterator - iterator_invoker()(std::forward(rest)...); + iterator_invoker()(std::forward(exec), op, rest...); } };