From patchwork Wed Dec 14 14:11:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 33224 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp244152wrn; Wed, 14 Dec 2022 06:13:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf6QCIcsm5b8BbCTf3K0RtrDGYximzYQFePfUcV3fHJORp3lT9bq745Q87lFExdICoE8XOEk X-Received: by 2002:a05:6402:444b:b0:461:68e4:15cc with SMTP id o11-20020a056402444b00b0046168e415ccmr19776982edb.9.1671027212678; Wed, 14 Dec 2022 06:13:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671027212; cv=none; d=google.com; s=arc-20160816; b=Qowz3nmIKrnKOiZ6QWxkJtarCiLBEPciCXRbZAGumEr54eWF0SnRCqLehgRKUrYLYg d9cVEaF2Oxf1U0lTIsQpG9RyV2OcH+v/qglwVVeWb/4li1lpSyYNfeGdTscx+4pXWTjo oN3vbgXVveZgSUqxRKoXfT+u70VK8mrRjNoOqdZ5TxNdtT0ACSoRjWtKlLobefBXM9rY KKcL8qQYYepxqJMzlp5uDD204Wl00hm9vR5+1wlyiFgzLphDGfUCvMRipJZ+cqtbWk9p Sc+kpkLsoF43QfGJWeFT1uswXLKit/wONDLqi8r7EvbQwymPkhZtGQQE/Y30ryPQBo8X x29g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=Qg29uxJAsZ3+4Dqay0DLpFupft5L8ljTfzTId8/31u4=; b=HPEECW0X5CiZQpFZ3eSKIhJP2zoyhc68BDJrraFJ2YQM2wR38Mznnv+wvE3v1Im+LB 4Mjjp/FP3ImIiOTqQFYaokOLV1WKfkj9+es+n9bQiQypBQWRdUxTu7k1t9pXY7eFeOLz vxzJb7jCJQ1GPSc8+LAutY+2xPBOoBSfGj46pYyJAPSt2hdcl6aSgvRwIF0EPNaq+Cs/ gzGUaEVuYEgluO58nA0hINNR2tM+zZ6QJiZWH2jV1+rcIGTF/XhcTjvDpvSlvC7P+NSp W2UBbOi+vcFarMMTctMPCagXxpvDqPiDuY8Y8c8AzYfBYyeKfmAiSNqGD+akFo7TVI3P IQ/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=AaXBJ8k8; 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=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id g12-20020a056402090c00b0046dcead6a54si14525978edz.513.2022.12.14.06.13.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Dec 2022 06:13:32 -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=@gcc.gnu.org header.s=default header.b=AaXBJ8k8; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EB64F382BE81 for ; Wed, 14 Dec 2022 14:12:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EB64F382BE81 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671027174; bh=Qg29uxJAsZ3+4Dqay0DLpFupft5L8ljTfzTId8/31u4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=AaXBJ8k8/8Tqgnfxaqwd5PE+fbPgghJiqIBq4kgHmsA4S8QE5EcBgGXqZfmWuOf4g 2tlwqoyamBrgOYDtQN+zO4uOHXibhSCj8ez5XG8h1Ogxz1nfnkY9DrjxRLse15CmEC H+OSflGVQPrOPvBQtHEyIYaHRB8O+F0siNFbeh3U= 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 B3961382D3D6 for ; Wed, 14 Dec 2022 14:12:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B3961382D3D6 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-435-0cQnh8hTOJ-LU-oQKJ5WMg-1; Wed, 14 Dec 2022 09:11:54 -0500 X-MC-Unique: 0cQnh8hTOJ-LU-oQKJ5WMg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6ED66857F82; Wed, 14 Dec 2022 14:11:54 +0000 (UTC) Received: from localhost (unknown [10.33.36.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 38D3740C2005; Wed, 14 Dec 2022 14:11:54 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Fix size passed to operator delete [PR108097] Date: Wed, 14 Dec 2022 14:11:51 +0000 Message-Id: <20221214141151.933092-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.8 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 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752199030267437026?= X-GMAIL-MSGID: =?utf-8?q?1752199030267437026?= Tested x86_64-linux. Pushed to trunk. -- >8 -- The number of elements gets stored in _M_capacity so use a separate variable for the number of bytes to allocate. libstdc++-v3/ChangeLog: PR libstdc++/108097 * include/std/stacktrace (basic_stracktrace::_Impl): Do not multiply N by sizeof(value_type) when allocating. --- libstdc++-v3/include/std/stacktrace | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/std/stacktrace b/libstdc++-v3/include/std/stacktrace index 83c6463b0d8..402be3e828e 100644 --- a/libstdc++-v3/include/std/stacktrace +++ b/libstdc++-v3/include/std/stacktrace @@ -608,8 +608,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { if constexpr (is_same_v>) { - __n *= sizeof(value_type); - void* const __p = _GLIBCXX_OPERATOR_NEW (__n, nothrow_t{}); + // For std::allocator we use nothrow-new directly so we + // don't need to handle bad_alloc exceptions. + size_t __nb = __n * sizeof(value_type); + void* const __p = _GLIBCXX_OPERATOR_NEW (__nb, nothrow_t{}); if (__p == nullptr) [[unlikely]] return nullptr; _M_frames = static_cast(__p);