Merge "Random HWASan cleanups." am: b34d313d17
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1830382 Change-Id: If9ace9c23ccaff70f9022ab090886f28ebc9a74c
This commit is contained in:
commit
2014e706a6
4 changed files with 26 additions and 5 deletions
|
@ -714,7 +714,7 @@ void DlExtRelroSharingTest::SpawnChildrenAndMeasurePss(const char* lib, const ch
|
|||
}
|
||||
|
||||
std::string DlExtRelroSharingTest::FindMappingName(void* ptr) {
|
||||
uint64_t addr = reinterpret_cast<uint64_t>(ptr);
|
||||
uint64_t addr = reinterpret_cast<uint64_t>(untag_address(ptr));
|
||||
std::string found_name = "<not found>";
|
||||
|
||||
EXPECT_TRUE(android::procinfo::ReadMapFile("/proc/self/maps",
|
||||
|
|
|
@ -52,6 +52,9 @@ TEST(heap_tagging_level, tagged_pointer_dies) {
|
|||
if (mte_supported()) {
|
||||
GTEST_SKIP() << "Tagged pointers are not used on MTE hardware.";
|
||||
}
|
||||
if (running_with_hwasan()) {
|
||||
GTEST_SKIP() << "Tagged heap pointers feature is disabled under HWASan.";
|
||||
}
|
||||
|
||||
void *x = malloc(1);
|
||||
|
||||
|
@ -119,6 +122,9 @@ TEST(heap_tagging_level, sync_async_bad_accesses_die) {
|
|||
|
||||
TEST(heap_tagging_level, none_pointers_untagged) {
|
||||
#if defined(__BIONIC__)
|
||||
if (running_with_hwasan()) {
|
||||
GTEST_SKIP() << "HWASan is unaffected by heap tagging level.";
|
||||
}
|
||||
EXPECT_TRUE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_NONE));
|
||||
std::unique_ptr<int[]> p = std::make_unique<int[]>(4);
|
||||
EXPECT_EQ(untag_address(p.get()), p.get());
|
||||
|
@ -135,7 +141,13 @@ TEST(heap_tagging_level, tagging_level_transitions) {
|
|||
|
||||
EXPECT_FALSE(SetHeapTaggingLevel(static_cast<HeapTaggingLevel>(12345)));
|
||||
|
||||
if (mte_supported() && running_with_mte()) {
|
||||
if (running_with_hwasan()) {
|
||||
// NONE -> ...
|
||||
EXPECT_FALSE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_TBI));
|
||||
EXPECT_FALSE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_ASYNC));
|
||||
EXPECT_FALSE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_SYNC));
|
||||
EXPECT_TRUE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_NONE));
|
||||
} else if (mte_supported() && running_with_mte()) {
|
||||
// ASYNC -> ...
|
||||
EXPECT_FALSE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_TBI));
|
||||
EXPECT_TRUE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_ASYNC));
|
||||
|
|
|
@ -112,11 +112,17 @@ std::ostream& operator<<(std::ostream& os, const LeakChecker& lc) {
|
|||
TEST(pthread_leak, join) {
|
||||
SKIP_WITH_NATIVE_BRIDGE; // http://b/37920774
|
||||
|
||||
// Warm up. HWASan allocates an extra page on the first iteration, but never after.
|
||||
pthread_t thread;
|
||||
ASSERT_EQ(0, pthread_create(
|
||||
&thread, nullptr, [](void*) -> void* { return nullptr; }, nullptr));
|
||||
ASSERT_EQ(0, pthread_join(thread, nullptr));
|
||||
|
||||
LeakChecker lc;
|
||||
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
pthread_t thread;
|
||||
ASSERT_EQ(0, pthread_create(&thread, nullptr, [](void*) -> void* { return nullptr; }, nullptr));
|
||||
ASSERT_EQ(0, pthread_create(
|
||||
&thread, nullptr, [](void*) -> void* { return nullptr; }, nullptr));
|
||||
ASSERT_EQ(0, pthread_join(thread, nullptr));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -700,7 +700,10 @@ static void GetAllocatorVersion(bool* allocator_scudo) {
|
|||
FILE* fp = fdopen(tf.fd, "w+");
|
||||
tf.release();
|
||||
ASSERT_TRUE(fp != nullptr);
|
||||
ASSERT_EQ(0, malloc_info(0, fp));
|
||||
if (malloc_info(0, fp) != 0) {
|
||||
*allocator_scudo = false;
|
||||
return;
|
||||
}
|
||||
ASSERT_EQ(0, fclose(fp));
|
||||
|
||||
std::string contents;
|
||||
|
|
Loading…
Reference in a new issue