From patchwork Thu Sep 26 11:50:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1989816 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GhIGgeKf; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XDsPq5Ffxz1xt6 for ; Thu, 26 Sep 2024 21:51:27 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 61C483858CDB for ; Thu, 26 Sep 2024 11:51:25 +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.133.124]) by sourceware.org (Postfix) with ESMTP id AC2B8385842A for ; Thu, 26 Sep 2024 11:51:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AC2B8385842A 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 AC2B8385842A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727351462; cv=none; b=D+a3Dx7DL8mJ9x9TKFZgnskRDqKHYFxl01rmGwG1/a8UGoVeFTLEfoNi1sUc2o37CliMK2nrGPtKvJgfBYZNpWZ9zlLcRj254egut7LuGCWzw3+YhRr0BJxaql/seLxtmIkmyVJE3zyB9clOv1I6Pc+pcum1J88ApZgRhWLRbFk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727351462; c=relaxed/simple; bh=y/r+BT/xbYH+qEpdwU+sjWHaPNUuwTVPZ+lkLuTZ6hY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=j7vhmNGDBkxnhcPYo07VyXdPL2DDCXfToUwdJOQwFO3bD6p/zKScaD2e8yYg27ePNnVcCk7FvQ6MKTcan+b06uumUe8GE0t58gP8nH+A9ZCkhObkKYtgGiftQ3QkzkyBsNxib4osLCjCURZZefhqFfaEbfowQQo4e+NKN1DLDDQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727351460; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=PXm03nyxpmj94KlppaiWQMaB/jtVKXnthxcvMuS3QB4=; b=GhIGgeKfYzqTZKP04bxN+Oxe8FD0l5D4KOdpW9xecaUFeeSXl/rLAdcpngsENjqm/Ao+Mj BJnwlYifIwFp5JXQ0kYwjaoweAZz9MKlnh9MgYhWGezcTYq6esF9UXyQr8YFV3HqudSAEJ vOp3A0cOlBRwKnYwDmtiYCt5tvdHU5g= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-646-wttMyAzDOnC7yE1WYt7K6w-1; Thu, 26 Sep 2024 07:50:57 -0400 X-MC-Unique: wttMyAzDOnC7yE1WYt7K6w-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (unknown [10.30.177.15]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3E24D18B3225; Thu, 26 Sep 2024 11:50:56 +0000 (UTC) Received: from localhost (unknown [10.42.28.136]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5D2021979060; Thu, 26 Sep 2024 11:50:55 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Fix std::basic_stracktrace to not assume allocators throw std::bad_alloc Date: Thu, 26 Sep 2024 12:50:18 +0100 Message-ID: <20240926115054.2002070-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org I find this allowance in the standard baffling, but it is what it is. Tested x86_64-linux. Pushed to trunk. -- >8 -- The standard allows allocators to throw any kind of exception, not only something that can be caught as std::bad_alloc. std::basic_stracktrace was assuming std::bad_alloc. libstdc++-v3/ChangeLog: * include/std/stacktrace (basic_stacktrace::_Impl::_M_allocate): Do not assume allocators only throw std::bad_alloc. --- libstdc++-v3/include/std/stacktrace | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/std/stacktrace b/libstdc++-v3/include/std/stacktrace index de7446064c7..58d0c2a0fc2 100644 --- a/libstdc++-v3/include/std/stacktrace +++ b/libstdc++-v3/include/std/stacktrace @@ -560,7 +560,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION if constexpr (is_same_v>) { // For std::allocator we use nothrow-new directly so we - // don't need to handle bad_alloc exceptions. + // don't need to handle exceptions from __alloc.allocate(n). auto __p = __detail::__get_temporary_buffer(__n); if (__p == nullptr) [[unlikely]] return nullptr; @@ -572,7 +572,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { _M_frames = __alloc.allocate(__n); } - __catch (const std::bad_alloc&) + __catch (...) { return nullptr; }