From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.hazardy.de (mail.hazardy.de [78.94.181.132]) by sourceware.org (Postfix) with ESMTPS id 11EFA3858D37; Wed, 30 Nov 2022 19:20:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 11EFA3858D37 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 3A7087008A3; Wed, 30 Nov 2022 20:20:33 +0100 (CET) Message-ID: Date: Wed, 30 Nov 2022 20:20:33 +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: Re: [PATCH] libstdc++: Add error handler for Content-Language: de-DE To: =?UTF-8?Q?Fran=c3=a7ois_Dumont?= , gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org References: <20221129214107.25572-1-gcc@hazardy.de> From: =?UTF-8?Q?Bj=c3=b6rn_Sch=c3=a4pers?= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00,BODY_8BITS,GIT_PATCH_0,KAM_DMARC_STATUS,NICE_REPLY_A,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 List-Id: One could (for a manual test) always change libbacktrace to call the callback. Or invoke it on a platform where libbacktrace can't figure out the executable path on its own, like currently windows. As for an automated test, I have no idea how to enforce that, without changing the code to be tested. Björn. Am 30.11.2022 um 07:04 schrieb François Dumont: > Good catch, then we also need this patch. > > I still need to test it thought, just to make sure it compiles. Unless you have > a nice way to force call to the error callback ? > > François > > On 29/11/22 22:41, Björn Schäpers wrote: >> 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(-) >> >> 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() >>       { >>         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(); >