From a5508a2825c5388133c69e07d7315d2186feb7c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Mon, 17 Jan 2022 13:01:32 +0100 Subject: [PATCH] #1495: check for libunwind errors --- src/vt/configs/error/stack_out.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/vt/configs/error/stack_out.cc b/src/vt/configs/error/stack_out.cc index cde16be8bc..f9c37dabb8 100644 --- a/src/vt/configs/error/stack_out.cc +++ b/src/vt/configs/error/stack_out.cc @@ -43,6 +43,7 @@ #include "vt/configs/error/stack_out.h" +#include #define UNW_LOCAL_ONLY #include #include @@ -56,8 +57,12 @@ DumpStackType dumpStack(int skip) { unw_context_t context; // Initialize cursor to current frame for local unwinding. - unw_getcontext(&context); - unw_init_local(&cursor, &context); + if (unw_getcontext(&context) != 0) { + fmt::print("unw_getcontext failed"); + } + if (unw_init_local(&cursor, &context) != 0) { + fmt::print("unw_init_local failed"); + } // Unwind frames one by one, going up the frame stack. int i = 0; @@ -67,7 +72,9 @@ DumpStackType dumpStack(int skip) { } unw_word_t offset, pc; - unw_get_reg(&cursor, UNW_REG_IP, &pc); + if (unw_get_reg(&cursor, UNW_REG_IP, &pc) != 0) { + fmt::print("unw_get_reg failed"); + } if (pc == 0) { break; } @@ -89,7 +96,7 @@ DumpStackType dumpStack(int skip) { std::free(demangled); } else { // FIXME! - std::printf(" -- error: unable to obtain symbol name for this frame\n"); + fmt::print(" -- error: unable to obtain symbol name for this frame\n"); } } while (unw_step(&cursor) > 0);