diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-11-30 21:12:22 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2021-11-30 21:12:22 +0000 |
commit | dd8712c17821d19b687ace646824f6e397703bfa (patch) | |
tree | 1c55d107646fdf2e884c7acdba32a92f9ac3fc76 | |
parent | 24305e1f41abad402f6e6eb7cb07d973f2216080 (diff) | |
parent | a35fb266842b5dcbc706c643880ad9ddb5ea7336 (diff) | |
download | bionic-android-vts-12.0_r2.tar.gz |
Merge "Snap for 7955813 from d8fa0f64af4b3ee41b3aa1bc7dd27b2185112b47 to android12-tests-release" into android12-tests-releaseandroid-vts-12.0_r4android-vts-12.0_r3android-vts-12.0_r2android-cts-12.0_r4android-cts-12.0_r3
-rw-r--r-- | tests/malloc_test.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/malloc_test.cpp b/tests/malloc_test.cpp index 30da5c32f..e5e78a5b4 100644 --- a/tests/malloc_test.cpp +++ b/tests/malloc_test.cpp @@ -1373,3 +1373,25 @@ TEST(malloc, allocation_slack) { GTEST_SKIP() << "bionic extension"; #endif } + +// Regression test for b/206701345 -- scudo bug, MTE only. +// Fix: https://reviews.llvm.org/D105261 +// Fix: https://android-review.googlesource.com/c/platform/external/scudo/+/1763655 +TEST(malloc, realloc_mte_crash_b206701345) { + // We want to hit in-place realloc at the very end of an mmap-ed region. Not + // all size classes allow such placement - mmap size has to be divisible by + // the block size. At the time of writing this could only be reproduced with + // 64 byte size class (i.e. 48 byte allocations), but that may change in the + // future. Try several different classes at the lower end. + std::vector<void*> ptrs(10000); + for (int i = 1; i < 32; ++i) { + size_t sz = 16 * i - 1; + for (void*& p : ptrs) { + p = realloc(malloc(sz), sz + 1); + } + + for (void* p : ptrs) { + free(p); + } + } +} |