Skip to content

Commit

Permalink
[tsan] Fix CallocOverflow unit test on OS X
Browse files Browse the repository at this point in the history
On OS X, interceptors don't work in unit tests, so calloc() calls the system allocator. We need to use user_calloc() instead.

Differential Revision: http://reviews.llvm.org/D14918

llvm-svn: 253979
  • Loading branch information
kubamracek committed Nov 24, 2015
1 parent d4b566d commit 377cafb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler-rt/lib/tsan/tests/unit/tsan_mman_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,13 @@ TEST(Mman, CallocOverflow) {
// which is overflown by tsan memory accesses functions in debug mode.
return;
#endif
ThreadState *thr = cur_thread();
uptr pc = 0;
size_t kArraySize = 4096;
volatile size_t kMaxSizeT = std::numeric_limits<size_t>::max();
volatile size_t kArraySize2 = kMaxSizeT / kArraySize + 10;
volatile void *p = NULL;
EXPECT_DEATH(p = calloc(kArraySize, kArraySize2),
EXPECT_DEATH(p = user_calloc(thr, pc, kArraySize, kArraySize2),
"allocator is terminating the process instead of returning 0");
EXPECT_EQ(0L, p);
}
Expand Down

0 comments on commit 377cafb

Please sign in to comment.