summaryrefslogtreecommitdiff
path: root/lib/tsan/tests
diff options
context:
space:
mode:
authorKostya Kortchinsky <kostyak@google.com>2017-08-02 22:47:54 +0000
committerKostya Kortchinsky <kostyak@google.com>2017-08-02 22:47:54 +0000
commit5dea2733b9b133262190ffec6f967e81d0e8b27b (patch)
treeb1c21f8de778e82b3869de2b727562e0580b8b67 /lib/tsan/tests
parentac2979953f5a661ebb67eb8f4a36d63ae0db19c3 (diff)
downloadcompiler-rt-5dea2733b9b133262190ffec6f967e81d0e8b27b.tar.gz
[tsan] Check for pvalloc overlow
Summary: `CheckForPvallocOverflow` was introduced with D35818 to detect when pvalloc would wrap when rounding up to the next multiple of the page size. Add this check to TSan's pvalloc implementation. Reviewers: alekseyshl Reviewed By: alekseyshl Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D36245 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@309897 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/tsan/tests')
-rw-r--r--lib/tsan/tests/unit/tsan_mman_test.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/tsan/tests/unit/tsan_mman_test.cc b/lib/tsan/tests/unit/tsan_mman_test.cc
index ed08247fa..05ae42867 100644
--- a/lib/tsan/tests/unit/tsan_mman_test.cc
+++ b/lib/tsan/tests/unit/tsan_mman_test.cc
@@ -139,6 +139,7 @@ TEST(Mman, Stats) {
TEST(Mman, Valloc) {
ThreadState *thr = cur_thread();
+ uptr page_size = GetPageSizeCached();
void *p = user_valloc(thr, 0, 100);
EXPECT_NE(p, (void*)0);
@@ -150,8 +151,13 @@ TEST(Mman, Valloc) {
p = user_pvalloc(thr, 0, 0);
EXPECT_NE(p, (void*)0);
- EXPECT_EQ(GetPageSizeCached(), __sanitizer_get_allocated_size(p));
+ EXPECT_EQ(page_size, __sanitizer_get_allocated_size(p));
user_free(thr, 0, p);
+
+ EXPECT_DEATH(p = user_pvalloc(thr, 0, (uptr)-(page_size - 1)),
+ "allocator is terminating the process instead of returning 0");
+ EXPECT_DEATH(p = user_pvalloc(thr, 0, (uptr)-1),
+ "allocator is terminating the process instead of returning 0");
}
#if !SANITIZER_DEBUG