summaryrefslogtreecommitdiff
path: root/tests/malloc_test.cpp
diff options
context:
space:
mode:
authorHaamed Gheibi <haamed@google.com>2022-02-17 15:24:43 -0800
committerHaamed Gheibi <haamed@google.com>2022-02-22 09:46:39 -0800
commitf3d2af29a7965555d717798faee043c536b86b2f (patch)
treeadbbfac0d7c5c098c1eca004477f93adefc158a9 /tests/malloc_test.cpp
parent18e710a4c1d799ac2e1094cee6a65dd719a29c2b (diff)
parent11fa611f2c52e17e23f679869724278e2becc862 (diff)
Merge SP2A.220305.013
Bug: 220074017 Change-Id: Ia2198b401a3a907c785316e0ef4c00bf27fa59b1
Diffstat (limited to 'tests/malloc_test.cpp')
-rw-r--r--tests/malloc_test.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/malloc_test.cpp b/tests/malloc_test.cpp
index d73f2436d..f4a1c0d30 100644
--- a/tests/malloc_test.cpp
+++ b/tests/malloc_test.cpp
@@ -1371,3 +1371,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);
+ }
+ }
+}