Export of internal Abseil changes

--
c12db0cff0f0cb0c10731cdf4bf1663e99ecb82e by Samuel Benzaquen <sbenza@google.com>:

Fix incompatibility of retired flags and AddressSanitizer.

PiperOrigin-RevId: 325028944

--
20119dce82503c6ac22f3ec479d0eaea6acc7ba0 by Abseil Team <absl-team@google.com>:

Internal change

PiperOrigin-RevId: 324939694

--
bb1ab1a4e1a551469ad110bdfce3210aeb9bf4b8 by Abseil Team <absl-team@google.com>:

Teach Abseil stack consumption utilities about AArch64.

PiperOrigin-RevId: 324935395

--
987043ffc960f38457478b01c04b47dfaf7ae006 by Evan Brown <ezb@google.com>:

Cleanup: simplify the slot transfer methods a bit.

PiperOrigin-RevId: 324834817

--
ed7081130d3ab93a2c3c916e30fe4367d8e96954 by Abseil Team <absl-team@google.com>:

Pass __FILE__ as const char* instead of as array of chars to internal_log_function

to allow deterministic symbols for AtomicHook wrapper of the InternalLogFunction

PiperOrigin-RevId: 324800499
GitOrigin-RevId: c12db0cff0f0cb0c10731cdf4bf1663e99ecb82e
Change-Id: Ibb92b1cab465e45abc86281f0fba894c82a662df
pull/772/head
Abseil Team 4 years ago committed by Derek Mauro
parent 1995c6a3c2
commit f66bc74928
  1. 2
      absl/BUILD.bazel
  2. 10
      absl/base/internal/raw_logging.h
  3. 30
      absl/container/internal/btree.h
  4. 3
      absl/debugging/internal/stack_consumption.cc
  5. 5
      absl/debugging/internal/stack_consumption.h
  6. 8
      absl/flags/flag.h
  7. 11
      absl/flags/flag_test.cc
  8. 2
      absl/flags/flag_test_defs.cc
  9. 2
      absl/flags/internal/registry.h

@ -21,7 +21,7 @@ load(
package(default_visibility = ["//visibility:public"])
licenses(["notice"]) # Apache 2.0
licenses(["notice"])
create_llvm_config(
name = "llvm_compiler",

@ -72,10 +72,12 @@
//
// The API is a subset of the above: each macro only takes two arguments. Use
// StrCat if you need to build a richer message.
#define ABSL_INTERNAL_LOG(severity, message) \
do { \
::absl::raw_logging_internal::internal_log_function( \
ABSL_RAW_LOGGING_INTERNAL_##severity, __FILE__, __LINE__, message); \
#define ABSL_INTERNAL_LOG(severity, message) \
do { \
constexpr const char* absl_raw_logging_internal_filename = __FILE__; \
::absl::raw_logging_internal::internal_log_function( \
ABSL_RAW_LOGGING_INTERNAL_##severity, \
absl_raw_logging_internal_filename, __LINE__, message); \
} while (0)
#define ABSL_INTERNAL_CHECK(condition, message) \

@ -817,12 +817,16 @@ class btree_node {
}
}
static void transfer(slot_type *dest, slot_type *src, allocator_type *alloc) {
absl::container_internal::SanitizerUnpoisonObject(dest);
params_type::transfer(alloc, dest, src);
absl::container_internal::SanitizerPoisonObject(src);
}
// Transfers value from slot `src_i` in `src_node` to slot `dest_i` in `this`.
void transfer(const size_type dest_i, const size_type src_i,
btree_node *src_node, allocator_type *alloc) {
absl::container_internal::SanitizerUnpoisonObject(slot(dest_i));
params_type::transfer(alloc, slot(dest_i), src_node->slot(src_i));
absl::container_internal::SanitizerPoisonObject(src_node->slot(src_i));
transfer(slot(dest_i), src_node->slot(src_i), alloc);
}
// Transfers `n` values starting at value `src_i` in `src_node` into the
@ -830,19 +834,11 @@ class btree_node {
void transfer_n(const size_type n, const size_type dest_i,
const size_type src_i, btree_node *src_node,
allocator_type *alloc) {
absl::container_internal::SanitizerUnpoisonMemoryRegion(
slot(dest_i), n * sizeof(slot_type));
for (slot_type *src = src_node->slot(src_i), *end = src + n,
*dest = slot(dest_i);
src != end; ++src, ++dest) {
params_type::transfer(alloc, dest, src);
transfer(dest, src, alloc);
}
// We take care to avoid poisoning transferred-to nodes in case of overlap.
const size_type overlap =
this == src_node ? (std::max)(src_i, dest_i + n) - src_i : 0;
assert(n >= overlap);
absl::container_internal::SanitizerPoisonMemoryRegion(
src_node->slot(src_i + overlap), (n - overlap) * sizeof(slot_type));
}
// Same as above, except that we start at the end and work our way to the
@ -850,19 +846,11 @@ class btree_node {
void transfer_n_backward(const size_type n, const size_type dest_i,
const size_type src_i, btree_node *src_node,
allocator_type *alloc) {
absl::container_internal::SanitizerUnpoisonMemoryRegion(
slot(dest_i), n * sizeof(slot_type));
for (slot_type *src = src_node->slot(src_i + n - 1), *end = src - n,
*dest = slot(dest_i + n - 1);
src != end; --src, --dest) {
params_type::transfer(alloc, dest, src);
transfer(dest, src, alloc);
}
// We take care to avoid poisoning transferred-to nodes in case of overlap.
assert(this != src_node || dest_i >= src_i);
const size_type num_to_poison =
this == src_node ? (std::min)(n, dest_i - src_i) : n;
absl::container_internal::SanitizerPoisonMemoryRegion(
src_node->slot(src_i), num_to_poison * sizeof(slot_type));
}
template <typename P>

@ -42,7 +42,8 @@ namespace {
// one of them is null, the results of p<q, p>q, p<=q, and p>=q are
// unspecified. Therefore, instead we hardcode the direction of the
// stack on platforms we know about.
#if defined(__i386__) || defined(__x86_64__) || defined(__ppc__)
#if defined(__i386__) || defined(__x86_64__) || defined(__ppc__) || \
defined(__aarch64__)
constexpr bool kStackGrowsDown = true;
#else
#error Need to define kStackGrowsDown

@ -24,8 +24,9 @@
// Use this feature test macro to detect its availability.
#ifdef ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION
#error ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION cannot be set directly
#elif !defined(__APPLE__) && !defined(_WIN32) && \
(defined(__i386__) || defined(__x86_64__) || defined(__ppc__))
#elif !defined(__APPLE__) && !defined(_WIN32) && \
(defined(__i386__) || defined(__x86_64__) || defined(__ppc__) || \
defined(__aarch64__))
#define ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION 1
namespace absl {

@ -381,8 +381,10 @@ ABSL_NAMESPACE_END
// unused.
// TODO(rogeeff): replace RETIRED_FLAGS with FLAGS once forward declarations of
// retired flags are cleaned up.
#define ABSL_RETIRED_FLAG(type, name, default_value, explanation) \
ABSL_ATTRIBUTE_UNUSED static const absl::flags_internal::RetiredFlag<type> \
RETIRED_FLAGS_##name(#name)
#define ABSL_RETIRED_FLAG(type, name, default_value, explanation) \
static absl::flags_internal::RetiredFlag<type> RETIRED_FLAGS_##name; \
ABSL_ATTRIBUTE_UNUSED static const auto RETIRED_FLAGS_REG_##name = \
(RETIRED_FLAGS_##name.Retire(#name), \
::absl::flags_internal::FlagRegistrarEmpty{})
#endif // ABSL_FLAGS_FLAG_H_

@ -812,6 +812,17 @@ ABSL_RETIRED_FLAG(bool, old_bool_flag, true, "old descr");
ABSL_RETIRED_FLAG(int, old_int_flag, (int)std::sqrt(10), "old descr");
ABSL_RETIRED_FLAG(std::string, old_str_flag, "", absl::StrCat("old ", "descr"));
bool initializaion_order_fiasco_test = [] {
// Iterate over all the flags during static initialization.
// This should not trigger ASan's initialization-order-fiasco.
auto* handle1 = absl::FindCommandLineFlag("flag_on_separate_file");
auto* handle2 = absl::FindCommandLineFlag("retired_flag_on_separate_file");
if (handle1 != nullptr && handle2 != nullptr) {
return handle1->Name() == handle2->Name();
}
return true;
}();
namespace {
TEST_F(FlagTest, TestRetiredFlagRegistration) {

@ -20,3 +20,5 @@
ABSL_FLAG(int, mistyped_int_flag, 0, "");
ABSL_FLAG(std::string, mistyped_string_flag, "", "");
ABSL_FLAG(bool, flag_on_separate_file, false, "");
ABSL_RETIRED_FLAG(bool, retired_flag_on_separate_file, false, "");

@ -83,7 +83,7 @@ constexpr size_t kRetiredFlagObjAlignment = alignof(void*);
template <typename T>
class RetiredFlag {
public:
explicit RetiredFlag(const char* flag_name) {
void Retire(const char* flag_name) {
flags_internal::Retire(flag_name, base_internal::FastTypeId<T>(), buf_);
}

Loading…
Cancel
Save