Skip to content

Commit a2f52e1

Browse files
Abseil Teamderekmauro
authored andcommitted
Export of internal Abseil changes
-- b008f3aaab60f1f0eb5987b50336543cca7151be by Martijn Vels <[email protected]>: 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 <[email protected]>: Add missing CMake alias for gmock_main. Remove unused variable ABSL_TEST_COMMON_LIBRARIES Fixes abseil#709 Fixes abseil#1043 PiperOrigin-RevId: 403950358 -- 86695f6d06915b56d807303c37ee81487998cd58 by Abseil Team <[email protected]>: 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 <[email protected]>: Internal optimization. PiperOrigin-RevId: 403413291 GitOrigin-RevId: b008f3aaab60f1f0eb5987b50336543cca7151be Change-Id: I1665f0efd484f53e0ed22d8940ef2fa60b03cc5b
1 parent 7e44607 commit a2f52e1

File tree

7 files changed

+30
-14
lines changed

7 files changed

+30
-14
lines changed

CMakeLists.txt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,22 +160,16 @@ if(BUILD_TESTING)
160160

161161
if (NOT ABSL_FIND_GOOGLETEST)
162162
# When Google Test is included directly rather than through find_package, the aliases are missing.
163-
add_library(GTest::gtest_main ALIAS gtest_main)
164163
add_library(GTest::gtest ALIAS gtest)
164+
add_library(GTest::gtest_main ALIAS gtest_main)
165165
add_library(GTest::gmock ALIAS gmock)
166+
add_library(GTest::gmock_main ALIAS gmock_main)
166167
endif()
167168

168169
check_target(GTest::gtest)
169170
check_target(GTest::gtest_main)
170171
check_target(GTest::gmock)
171172
check_target(GTest::gmock_main)
172-
173-
list(APPEND ABSL_TEST_COMMON_LIBRARIES
174-
GTest::gtest_main
175-
GTest::gtest
176-
GTest::gmock
177-
${CMAKE_THREAD_LIBS_INIT}
178-
)
179173
endif()
180174

181175
add_subdirectory(absl)

absl/debugging/internal/stacktrace_x86-inl.inc

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#include <cassert>
2929
#include <cstdint>
30+
#include <limits>
3031

3132
#include "absl/base/macros.h"
3233
#include "absl/base/port.h"
@@ -158,7 +159,8 @@ static uintptr_t GetFP(const void *vuc) {
158159
template <bool STRICT_UNWINDING, bool WITH_CONTEXT>
159160
ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS // May read random elements from stack.
160161
ABSL_ATTRIBUTE_NO_SANITIZE_MEMORY // May read random elements from stack.
161-
static void **NextStackFrame(void **old_fp, const void *uc) {
162+
static void **NextStackFrame(void **old_fp, const void *uc,
163+
size_t stack_low, size_t stack_high) {
162164
void **new_fp = (void **)*old_fp;
163165

164166
#if defined(__linux__) && defined(__i386__)
@@ -257,6 +259,18 @@ static void **NextStackFrame(void **old_fp, const void *uc) {
257259
// at a greater address that the current one.
258260
if (new_fp_u <= old_fp_u) return nullptr;
259261
if (new_fp_u - old_fp_u > kMaxFrameBytes) return nullptr;
262+
263+
if (stack_low < old_fp_u && old_fp_u <= stack_high) {
264+
// Old BP was in the expected stack region...
265+
if (!(stack_low < new_fp_u && new_fp_u <= stack_high)) {
266+
// ... but new BP is outside of expected stack region.
267+
// It is most likely bogus.
268+
return nullptr;
269+
}
270+
} else {
271+
// We may be here if we are executing in a co-routine with a
272+
// separate stack. We can't do safety checks in this case.
273+
}
260274
} else {
261275
if (new_fp == nullptr) return nullptr; // skip AddressIsReadable() below
262276
// 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,
296310
int n = 0;
297311
void **fp = reinterpret_cast<void **>(__builtin_frame_address(0));
298312

313+
size_t stack_low = getpagesize(); // Assume that the first page is not stack.
314+
size_t stack_high = std::numeric_limits<size_t>::max() - sizeof(void *);
315+
299316
while (fp && n < max_depth) {
300317
if (*(fp + 1) == reinterpret_cast<void *>(0)) {
301318
// In 64-bit code, we often see a frame that
302319
// points to itself and has a return address of 0.
303320
break;
304321
}
305-
void **next_fp = NextStackFrame<!IS_STACK_FRAMES, IS_WITH_CONTEXT>(fp, ucp);
322+
void **next_fp = NextStackFrame<!IS_STACK_FRAMES, IS_WITH_CONTEXT>(
323+
fp, ucp, stack_low, stack_high);
306324
if (skip_count > 0) {
307325
skip_count--;
308326
} else {
@@ -325,7 +343,8 @@ static int UnwindImpl(void **result, int *sizes, int max_depth, int skip_count,
325343
const int kMaxUnwind = 1000;
326344
int j = 0;
327345
for (; fp != nullptr && j < kMaxUnwind; j++) {
328-
fp = NextStackFrame<!IS_STACK_FRAMES, IS_WITH_CONTEXT>(fp, ucp);
346+
fp = NextStackFrame<!IS_STACK_FRAMES, IS_WITH_CONTEXT>(fp, ucp, stack_low,
347+
stack_high);
329348
}
330349
*min_dropped_frames = j;
331350
}

absl/status/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ cc_library(
4747
"//absl/container:inlined_vector",
4848
"//absl/debugging:stacktrace",
4949
"//absl/debugging:symbolize",
50+
"//absl/functional:function_ref",
5051
"//absl/strings",
5152
"//absl/strings:cord",
5253
"//absl/strings:str_format",

absl/status/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ absl_cc_library(
2929
absl::atomic_hook
3030
absl::config
3131
absl::core_headers
32+
absl::function_ref
3233
absl::raw_logging_internal
3334
absl::inlined_vector
3435
absl::stacktrace

absl/status/status.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ bool Status::ErasePayload(absl::string_view type_url) {
161161
}
162162

163163
void Status::ForEachPayload(
164-
const std::function<void(absl::string_view, const absl::Cord&)>& visitor)
164+
absl::FunctionRef<void(absl::string_view, const absl::Cord&)> visitor)
165165
const {
166166
if (auto* payloads = GetPayloads()) {
167167
bool in_reverse =

absl/status/status.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#include <string>
5656

5757
#include "absl/container/inlined_vector.h"
58+
#include "absl/functional/function_ref.h"
5859
#include "absl/status/internal/status_internal.h"
5960
#include "absl/strings/cord.h"
6061
#include "absl/strings/string_view.h"
@@ -590,7 +591,7 @@ class Status final {
590591
// NOTE: Any mutation on the same 'absl::Status' object during visitation is
591592
// forbidden and could result in undefined behavior.
592593
void ForEachPayload(
593-
const std::function<void(absl::string_view, const absl::Cord&)>& visitor)
594+
absl::FunctionRef<void(absl::string_view, const absl::Cord&)> visitor)
594595
const;
595596

596597
private:

absl/strings/internal/cord_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class CordzInfo;
3737

3838
// Default feature enable states for cord ring buffers
3939
enum CordFeatureDefaults {
40-
kCordEnableBtreeDefault = false,
40+
kCordEnableBtreeDefault = true,
4141
kCordEnableRingBufferDefault = false,
4242
kCordShallowSubcordsDefault = false
4343
};

0 commit comments

Comments
 (0)