From 8117471a5e35346ed674d3efc7800be91dbf3d2d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 4 Mar 2022 05:59:08 +0100 Subject: SIGSEGV workaround in jau::get_backtrace(..) of libunwind [1.3 - 1.6.2]'s unw_step(..) using g++ 10.2.1 aarch64: Disable Optimization --- src/debug.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/debug.cpp') diff --git a/src/debug.cpp b/src/debug.cpp index 65c54a3..acc77a7 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -33,6 +33,16 @@ using namespace jau; +/** + * On aarch64 using g++ (Debian 10.2.1-6) 10.2.1 20210110 + * optimization of `jau::get_backtrace(..)` leads to a SIGSEGV + * on libunwind version [1.3 - 1.6.2] function `unw_step(..)` + */ +#if defined(__GNUC__) && ! defined(__clang__) + #pragma GCC push_options + #pragma GCC optimize("-O0") +#endif + std::string jau::get_backtrace(const bool skip_anon_frames, const jau::snsize_t max_frames, const jau::snsize_t skip_frames) noexcept { // symbol: // 1: _ZN9direct_bt10DBTAdapter14startDiscoveryEbNS_19HCILEOwnAddressTypeEtt + 0x58d @ ip 0x7faa959d6daf, sp 0x7ffe38f301e0 @@ -101,6 +111,10 @@ std::string jau::get_backtrace(const bool skip_anon_frames, const jau::snsize_t return out; } +#if defined(__GNUC__) && ! defined(__clang__) + #pragma GCC pop_options +#endif + void jau::print_backtrace(const bool skip_anon_frames, const jau::snsize_t max_frames, const jau::snsize_t skip_frames) noexcept { fprintf(stderr, "%s", get_backtrace(skip_anon_frames, max_frames, skip_frames).c_str()); fflush(stderr); -- cgit v1.2.3