diff --git a/compiler-rt/lib/scudo/standalone/allocator_config.h b/compiler-rt/lib/scudo/standalone/allocator_config.h --- a/compiler-rt/lib/scudo/standalone/allocator_config.h +++ b/compiler-rt/lib/scudo/standalone/allocator_config.h @@ -156,7 +156,7 @@ }; #endif -#if SCUDO_ANDROID +#if SCUDO_ANDROID || (SCUDO_LINUX && defined(__aarch64__)) typedef AndroidConfig Config; #elif SCUDO_FUCHSIA typedef FuchsiaConfig Config; diff --git a/compiler-rt/lib/scudo/standalone/tests/scudo_unit_test_main.cpp b/compiler-rt/lib/scudo/standalone/tests/scudo_unit_test_main.cpp --- a/compiler-rt/lib/scudo/standalone/tests/scudo_unit_test_main.cpp +++ b/compiler-rt/lib/scudo/standalone/tests/scudo_unit_test_main.cpp @@ -17,12 +17,24 @@ #define DEALLOC_TYPE_MISMATCH "true" #endif +static void EnableMemoryTaggingIfSupported() { + if (!scudo::archSupportsMemoryTagging()) + return; + static bool Done = []() { + if (!scudo::systemDetectsMemoryTagFaultsTestOnly()) + scudo::enableSystemMemoryTaggingTestOnly(); + return true; + }(); + (void)Done; +} + // This allows us to turn on/off a Quarantine for specific tests. The Quarantine // parameters are on the low end, to avoid having to loop excessively in some // tests. bool UseQuarantine = true; extern "C" __attribute__((visibility("default"))) const char * __scudo_default_options() { + EnableMemoryTaggingIfSupported(); if (!UseQuarantine) return "dealloc_type_mismatch=" DEALLOC_TYPE_MISMATCH; return "quarantine_size_kb=256:thread_local_quarantine_size_kb=128:" @@ -34,8 +46,7 @@ // for Fuchsia builds. #if !SCUDO_FUCHSIA int main(int argc, char **argv) { - if (scudo::archSupportsMemoryTagging()) - scudo::enableSystemMemoryTaggingTestOnly(); + EnableMemoryTaggingIfSupported(); testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/compiler-rt/lib/scudo/standalone/tests/wrappers_cpp_test.cpp b/compiler-rt/lib/scudo/standalone/tests/wrappers_cpp_test.cpp --- a/compiler-rt/lib/scudo/standalone/tests/wrappers_cpp_test.cpp +++ b/compiler-rt/lib/scudo/standalone/tests/wrappers_cpp_test.cpp @@ -6,6 +6,7 @@ // //===----------------------------------------------------------------------===// +#include "memtag.h" #include "tests/scudo_unit_test.h" #include @@ -107,6 +108,11 @@ } TEST(ScudoWrappersCppTest, ThreadedNew) { +#if !SCUDO_ANDROID + // TODO: Investigate why libc sometimes crashes with tag missmatch in + // __pthread_clockjoin_ex. + scudo::ScopedDisableMemoryTagChecks NoTags; +#endif Ready = false; std::thread Threads[32]; for (size_t I = 0U; I < sizeof(Threads) / sizeof(Threads[0]); I++)