From 1ad62e582aecb656faaf0c30fcf42fca4656cfbc Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Sat, 12 Jan 2019 22:37:31 +0300 Subject: [PATCH] Add comment about async signal safety for PR #70 --- include/boost/stacktrace/detail/collect_unwind.ipp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/boost/stacktrace/detail/collect_unwind.ipp b/include/boost/stacktrace/detail/collect_unwind.ipp index 9b2920c..f03aebf 100644 --- a/include/boost/stacktrace/detail/collect_unwind.ipp +++ b/include/boost/stacktrace/detail/collect_unwind.ipp @@ -71,7 +71,10 @@ std::size_t this_thread_frames::collect(native_frame_ptr_t* out_frames, std::siz skip += 1; #if defined(BOOST_STACKTRACE_USE_LIBC_BACKTRACE_FUNCTION) + // According to https://opensource.apple.com/source/Libc/Libc-1272.200.26/gen/backtrace.c.auto.html + // it looks like the `::backtrace` is async signal safe. frames_count = static_cast(::backtrace(const_cast(out_frames), static_cast(max_frames_count))); + // NOTE: There is no way to pass "skip" count to backtrace function so we need to perform left shift operation. // If number of elements in result backtrace is >= max_frames_count then "skip" elements are wasted. if (frames_count && skip) {