diff --git a/be/src/common/stack_trace.cpp b/be/src/common/stack_trace.cpp index 9e951b6532f208..14d72526e06562 100644 --- a/be/src/common/stack_trace.cpp +++ b/be/src/common/stack_trace.cpp @@ -39,6 +39,8 @@ #if USE_UNWIND #include +#else +#include #endif namespace { @@ -294,12 +296,14 @@ StackTrace::StackTrace(const ucontext_t& signal_context) { } void StackTrace::tryCapture() { + // When unw_backtrace is not available, fall back on the standard + // `backtrace` function from execinfo.h. #if USE_UNWIND size = unw_backtrace(frame_pointers.data(), capacity); - __msan_unpoison(frame_pointers.data(), size * sizeof(frame_pointers[0])); #else - size = 0; + size = backtrace(frame_pointers.data(), capacity); #endif + __msan_unpoison(frame_pointers.data(), size * sizeof(frame_pointers[0])); } /// ClickHouse uses bundled libc++ so type names will be the same on every system thus it's safe to hardcode them diff --git a/be/src/util/stack_util.cpp b/be/src/util/stack_util.cpp index dd143ead3fcd95..70606b26e44797 100644 --- a/be/src/util/stack_util.cpp +++ b/be/src/util/stack_util.cpp @@ -45,11 +45,7 @@ std::string get_stack_trace() { } else if (tool == "glibc") { return get_stack_trace_by_glibc(); } else if (tool == "libunwind") { -#if USE_UNWIND return get_stack_trace_by_libunwind(); -#else - return get_stack_trace_by_glog(); -#endif } else { return "no stack"; }