public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-4452] libstdc++: Add error handler for <stacktrace>
@ 2022-12-02 0:18 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2022-12-02 0:18 UTC (permalink / raw)
To: gcc-cvs, libstdc++-cvs
https://gcc.gnu.org/g:40adb39566c6e06809fc63ccade8d25bdfc8dd24
commit r13-4452-g40adb39566c6e06809fc63ccade8d25bdfc8dd24
Author: Björn Schäpers <bjoern@hazardy.de>
Date: Wed Nov 30 12:04:16 2022 +0000
libstdc++: Add error handler for <stacktrace>
Not providing an error handler results in a null pointer dereference
when an error occurs.
Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
* include/std/stacktrace (stacktrace_entry::_S_err_handler): New
static function.
(stacktrace_entry, basic_stacktrace): Pass &_S_err_handler to
all calls to libbacktrace.
Diff:
---
libstdc++-v3/include/std/stacktrace | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/libstdc++-v3/include/std/stacktrace b/libstdc++-v3/include/std/stacktrace
index e7cbbee5638..ec3335e89d8 100644
--- a/libstdc++-v3/include/std/stacktrace
+++ b/libstdc++-v3/include/std/stacktrace
@@ -155,11 +155,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Allocator> friend class basic_stacktrace;
+ static void _S_err_handler(void*, const char*, int) { }
+
static __glibcxx_backtrace_state*
_S_init()
{
static __glibcxx_backtrace_state* __state
- = __glibcxx_backtrace_create_state(nullptr, 1, nullptr, nullptr);
+ = __glibcxx_backtrace_create_state(nullptr, 1, _S_err_handler, nullptr);
return __state;
}
@@ -192,7 +194,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, _S_err_handler,
+ &__data))
return true;
if (__desc && __desc->empty())
{
@@ -201,8 +204,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,
+ _S_err_handler, &__data))
return true;
}
return false;
@@ -252,7 +255,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,
+ stacktrace_entry::_S_err_handler,
std::__addressof(__ret)))
__ret._M_clear();
}
@@ -270,7 +274,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,
+ stacktrace_entry::_S_err_handler,
std::__addressof(__ret)))
__ret._M_clear();
}
@@ -294,7 +299,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
auto __state = stacktrace_entry::_S_init();
int __err = __glibcxx_backtrace_simple(__state, __skip + 1, __cb,
- nullptr,
+ stacktrace_entry::_S_err_handler,
std::__addressof(__ret));
if (__err < 0)
__ret._M_clear();
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-12-02 0:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-02 0:18 [gcc r13-4452] libstdc++: Add error handler for <stacktrace> Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).