diff options
author | Abseil Team <absl-team@google.com> | 2021-10-18 08:24:39 -0700 |
---|---|---|
committer | Derek Mauro <dmauro@google.com> | 2021-10-18 15:06:33 -0400 |
commit | a2f52e1177b87bdc747f8d0b7745c8f967bceb9d (patch) | |
tree | 81fb235516b6034ebda5e1718dc9a69c7d176d47 /absl/debugging/internal | |
parent | 7e446075d4aff4601c1e7627c7c0be2c4833a53a (diff) |
Export of internal Abseil changes
--
b008f3aaab60f1f0eb5987b50336543cca7151be by Martijn Vels <mvels@google.com>:
Enable Cord Btree as the default Cord implementation.
The Cord Btree implementation has been extensively tested by google. This changes makes the Cord Btree implementation the default implementation. This change should have no impact on current use cases and does not effect any public API or behavior.
PiperOrigin-RevId: 403966449
--
3d82052b5819d1244942c59d5cb4e51d75ada287 by Derek Mauro <dmauro@google.com>:
Add missing CMake alias for gmock_main.
Remove unused variable ABSL_TEST_COMMON_LIBRARIES
Fixes #709
Fixes #1043
PiperOrigin-RevId: 403950358
--
86695f6d06915b56d807303c37ee81487998cd58 by Abseil Team <absl-team@google.com>:
FunctionRef is cheaper to construct than a std::function, and the argument is only used during the call, so this is safe. This has the added advantage of allowing the caller to provide a non-movable callable, which can't be converted to a std::function.
PiperOrigin-RevId: 403457615
--
196c1109ba519d4ff00c856bbb4bff754468359f by Abseil Team <absl-team@google.com>:
Internal optimization.
PiperOrigin-RevId: 403413291
GitOrigin-RevId: b008f3aaab60f1f0eb5987b50336543cca7151be
Change-Id: I1665f0efd484f53e0ed22d8940ef2fa60b03cc5b
Diffstat (limited to 'absl/debugging/internal')
-rw-r--r-- | absl/debugging/internal/stacktrace_x86-inl.inc | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/absl/debugging/internal/stacktrace_x86-inl.inc b/absl/debugging/internal/stacktrace_x86-inl.inc index 70f79dfc..847a5473 100644 --- a/absl/debugging/internal/stacktrace_x86-inl.inc +++ b/absl/debugging/internal/stacktrace_x86-inl.inc @@ -27,6 +27,7 @@ #include <cassert> #include <cstdint> +#include <limits> #include "absl/base/macros.h" #include "absl/base/port.h" @@ -158,7 +159,8 @@ static uintptr_t GetFP(const void *vuc) { template <bool STRICT_UNWINDING, bool WITH_CONTEXT> ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS // May read random elements from stack. ABSL_ATTRIBUTE_NO_SANITIZE_MEMORY // May read random elements from stack. -static void **NextStackFrame(void **old_fp, const void *uc) { +static void **NextStackFrame(void **old_fp, const void *uc, + size_t stack_low, size_t stack_high) { void **new_fp = (void **)*old_fp; #if defined(__linux__) && defined(__i386__) @@ -257,6 +259,18 @@ static void **NextStackFrame(void **old_fp, const void *uc) { // at a greater address that the current one. if (new_fp_u <= old_fp_u) return nullptr; if (new_fp_u - old_fp_u > kMaxFrameBytes) return nullptr; + + if (stack_low < old_fp_u && old_fp_u <= stack_high) { + // Old BP was in the expected stack region... + if (!(stack_low < new_fp_u && new_fp_u <= stack_high)) { + // ... but new BP is outside of expected stack region. + // It is most likely bogus. + return nullptr; + } + } else { + // We may be here if we are executing in a co-routine with a + // separate stack. We can't do safety checks in this case. + } } else { if (new_fp == nullptr) return nullptr; // skip AddressIsReadable() below // In the non-strict mode, allow discontiguous stack frames. @@ -296,13 +310,17 @@ static int UnwindImpl(void **result, int *sizes, int max_depth, int skip_count, int n = 0; void **fp = reinterpret_cast<void **>(__builtin_frame_address(0)); + size_t stack_low = getpagesize(); // Assume that the first page is not stack. + size_t stack_high = std::numeric_limits<size_t>::max() - sizeof(void *); + while (fp && n < max_depth) { if (*(fp + 1) == reinterpret_cast<void *>(0)) { // In 64-bit code, we often see a frame that // points to itself and has a return address of 0. break; } - void **next_fp = NextStackFrame<!IS_STACK_FRAMES, IS_WITH_CONTEXT>(fp, ucp); + void **next_fp = NextStackFrame<!IS_STACK_FRAMES, IS_WITH_CONTEXT>( + fp, ucp, stack_low, stack_high); if (skip_count > 0) { skip_count--; } else { @@ -325,7 +343,8 @@ static int UnwindImpl(void **result, int *sizes, int max_depth, int skip_count, const int kMaxUnwind = 1000; int j = 0; for (; fp != nullptr && j < kMaxUnwind; j++) { - fp = NextStackFrame<!IS_STACK_FRAMES, IS_WITH_CONTEXT>(fp, ucp); + fp = NextStackFrame<!IS_STACK_FRAMES, IS_WITH_CONTEXT>(fp, ucp, stack_low, + stack_high); } *min_dropped_frames = j; } |