From patchwork Tue Nov 29 21:48:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Bj=C3=B6rn_Sch=C3=A4pers?= X-Patchwork-Id: 27519 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp584027wrr; Tue, 29 Nov 2022 13:48:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf6e74zbLgEVnW5aytscP1d5sMovjvnBY4RecRs0iCkfPgHh0npxlMEloTe5ExZ6NSXqb/Rt X-Received: by 2002:a17:907:cbc9:b0:7c0:8a2c:8886 with SMTP id vk9-20020a170907cbc900b007c08a2c8886mr4089096ejc.183.1669758523823; Tue, 29 Nov 2022 13:48:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669758523; cv=none; d=google.com; s=arc-20160816; b=PILtEktPbfDRqWz/ZdMx2ZRFHLnE7UrnrHzfYPQnZdquC2igva+zx6liJLRVyxHRSw JowjIZ8subpH/BAZq8Q5qY/YlKqT7ISyu8N0sxqsK6xR3acLVpLl9ynkirK1BtAO6cEC z4gNONrIPdPDhgijUKOcrvAZkCvBaAdxvLCSHDAiDelb9PZF+fQaC7gtDATlBThdZzo6 /VwjpTJa+mBFk5gr99lJ6w+FM2D7zhWMcL5NPdTJ/XaVDKsyWHXzaCnnAVmZvNRo6TtF 5czgwhI9BTS1RFs62ffwmZR78rKEOR9hDI4twugxYhx2tRD/dHwEoBCUP9+wN5jfi6Jw 6tLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :in-reply-to:from:to:content-language:references:subject:user-agent :mime-version:date:message-id:dmarc-filter:delivered-to; bh=2pzOxiahQetxyK9gCWWKlRDZgPJCclBKLdx+dy0+e/M=; b=OBOszjipgxUanFXYP77l3KBKLradS8Aa57wdEnO616j42GhY62lVnI+CIqfqSje1rO nyAPjFg3fxavWTG7jrDKcjrH0BxjHrEK9oBM56/tyanj+fCeSvji95Nl4jACbTn4I28D A9i2klnYWM7MNrtmUyg/9gIzi0nz5TLCwXQra2xJveHDHYZWMNKPQC19qpxHnBNbIwEq FgvCEPjT+giluqwUr+Q9tDXSq7Kq3UiaenFVu8gylK4i3nVYkdqZ9euiqezbLahtSPQF 17WypfL+eo8tixNPrWuOzhdYQ5MBNoI3YP46xXpoeF3CSc1GZl8BYBL69q8n/J+J7hp1 TaTQ== ARC-Authentication-Results: i=1; mx.google.com; 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" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id e13-20020a17090658cd00b007adbc807ca8si15698783ejs.137.2022.11.29.13.48.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 13:48:43 -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; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A337B3858CDA for ; Tue, 29 Nov 2022 21:48:37 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail.hazardy.de (mail.hazardy.de [78.94.181.132]) by sourceware.org (Postfix) with ESMTPS id B67A23858CDB for ; Tue, 29 Nov 2022 21:48:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B67A23858CDB Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=hazardy.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=hazardy.de Received: from [10.0.1.129] (hades.hazardy.de [10.0.1.129]) by mail.hazardy.de (Postfix) with ESMTPSA id 616D270050C for ; Tue, 29 Nov 2022 22:48:13 +0100 (CET) Message-ID: <776a72a7-a6b8-3bd2-d758-821c70420ed9@hazardy.de> Date: Tue, 29 Nov 2022 22:48:13 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Fwd: [PATCH] libstdc++: Add error handler for References: <20221129214107.25572-1-gcc@hazardy.de> Content-Language: de-DE To: gcc-patches@gcc.gnu.org From: =?utf-8?q?Bj=C3=B6rn_Sch=C3=A4pers?= In-Reply-To: <20221129214107.25572-1-gcc@hazardy.de> X-Forwarded-Message-Id: <20221129214107.25572-1-gcc@hazardy.de> X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham 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: , 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?1750868713798268347?= X-GMAIL-MSGID: =?utf-8?q?1750868713798268347?= -------- Weitergeleitete Nachricht -------- Betreff: [PATCH] libstdc++: Add error handler for Datum: Tue, 29 Nov 2022 22:41:07 +0100 Von: Björn Schäpers An: gcc-patches@gc.gnu.org, libstdc++@gcc.gnu.org From: Björn Schäpers Not providing an error handler results in a nullpointer dereference when an error occurs. libstdc++-v3/ChangeLog * include/std/stacktrace: Add __backtrace_error_handler and use it in all calls to libbacktrace. --- libstdc++-v3/include/std/stacktrace | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) { static __glibcxx_backtrace_state* __state - = __glibcxx_backtrace_create_state(nullptr, 1, nullptr, nullptr); + = __glibcxx_backtrace_create_state(nullptr, 1, + __backtrace_error_handler, nullptr); return __state; } @@ -192,7 +196,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return __function != nullptr; }; const auto __state = _S_init(); - if (::__glibcxx_backtrace_pcinfo(__state, _M_pc, +__cb, nullptr, &__data)) + if (::__glibcxx_backtrace_pcinfo(__state, _M_pc, +__cb, + __backtrace_error_handler, &__data)) return true; if (__desc && __desc->empty()) { @@ -201,8 +206,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION if (__symname) *static_cast<_Data*>(__data)->_M_desc = _S_demangle(__symname); }; - if (::__glibcxx_backtrace_syminfo(__state, _M_pc, +__cb2, nullptr, - &__data)) + if (::__glibcxx_backtrace_syminfo(__state, _M_pc, +__cb2, + __backtrace_error_handler, &__data)) return true; } return false; @@ -252,7 +257,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION if (auto __cb = __ret._M_prepare()) [[likely]] { auto __state = stacktrace_entry::_S_init(); - if (__glibcxx_backtrace_simple(__state, 1, __cb, nullptr, + if (__glibcxx_backtrace_simple(__state, 1, __cb, + __backtrace_error_handler, std::__addressof(__ret))) __ret._M_clear(); } @@ -270,7 +276,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION if (auto __cb = __ret._M_prepare()) [[likely]] { auto __state = stacktrace_entry::_S_init(); - if (__glibcxx_backtrace_simple(__state, __skip + 1, __cb, nullptr, + if (__glibcxx_backtrace_simple(__state, __skip + 1, __cb, + __backtrace_error_handler, std::__addressof(__ret))) __ret._M_clear(); } @@ -294,7 +301,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { auto __state = stacktrace_entry::_S_init(); int __err = __glibcxx_backtrace_simple(__state, __skip + 1, __cb, - nullptr, + __backtrace_error_handler, std::__addressof(__ret)); if (__err < 0) __ret._M_clear(); diff --git a/libstdc++-v3/include/std/stacktrace b/libstdc++-v3/include/std/stacktrace index e7cbbee5638..b786441cbad 100644 --- a/libstdc++-v3/include/std/stacktrace +++ b/libstdc++-v3/include/std/stacktrace @@ -85,6 +85,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #define __cpp_lib_stacktrace 202011L + inline void + __backtrace_error_handler(void*, const char*, int) {} + // [stacktrace.entry], class stacktrace_entry class stacktrace_entry { @@ -159,7 +162,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _S_init()