diff options
author | Alexey Samsonov <vonosmas@gmail.com> | 2014-07-01 18:01:20 +0000 |
---|---|---|
committer | Alexey Samsonov <vonosmas@gmail.com> | 2014-07-01 18:01:20 +0000 |
commit | 5ed1ca723a900b0fd7ce1ae3d18f71267c75629c (patch) | |
tree | 8db56d378c1dccf1d410a71d8c2bbdb7ebc7934c /lib/tsan/tests | |
parent | 255b8163f56950d936207a38b0a8b50a72504dc1 (diff) |
[TSan] Equalize the behavior of __tsan_get_allocated_size and user_alloc_usable_size.
The former used to crash with a null deref if it was given a not owned pointer,
while the latter returned 0. Now they both return 0. This is still not the best possible
behavior: it is better to print an error report with a stack trace, pointing
to the error in user code, as we do in ASan.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@212112 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/tsan/tests')
-rw-r--r-- | lib/tsan/tests/unit/tsan_mman_test.cc | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/tsan/tests/unit/tsan_mman_test.cc b/lib/tsan/tests/unit/tsan_mman_test.cc index d8afeaf4d..e52a85aac 100644 --- a/lib/tsan/tests/unit/tsan_mman_test.cc +++ b/lib/tsan/tests/unit/tsan_mman_test.cc @@ -51,8 +51,8 @@ TEST(Mman, User) { char *p2 = (char*)user_alloc(thr, pc, 20); EXPECT_NE(p2, (char*)0); EXPECT_NE(p2, p); - EXPECT_EQ(user_alloc_usable_size(thr, pc, p), (uptr)10); - EXPECT_EQ(user_alloc_usable_size(thr, pc, p2), (uptr)20); + EXPECT_EQ(10U, user_alloc_usable_size(p)); + EXPECT_EQ(20U, user_alloc_usable_size(p2)); user_free(thr, pc, p); user_free(thr, pc, p2); } @@ -107,11 +107,12 @@ TEST(Mman, UsableSize) { uptr pc = 0; char *p = (char*)user_alloc(thr, pc, 10); char *p2 = (char*)user_alloc(thr, pc, 20); - EXPECT_EQ(0U, user_alloc_usable_size(thr, pc, NULL)); - EXPECT_EQ(10U, user_alloc_usable_size(thr, pc, p)); - EXPECT_EQ(20U, user_alloc_usable_size(thr, pc, p2)); + EXPECT_EQ(0U, user_alloc_usable_size(NULL)); + EXPECT_EQ(10U, user_alloc_usable_size(p)); + EXPECT_EQ(20U, user_alloc_usable_size(p2)); user_free(thr, pc, p); user_free(thr, pc, p2); + EXPECT_EQ(0U, user_alloc_usable_size((void*)0x123)); } TEST(Mman, Stats) { |