[compiler-rt] r253979 - [tsan] Fix CallocOverflow unit test on OS X

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 24 05:27:33 PST 2015


Author: kuba.brecka
Date: Tue Nov 24 07:27:33 2015
New Revision: 253979

URL: http://llvm.org/viewvc/llvm-project?rev=253979&view=rev
Log:
[tsan] Fix CallocOverflow unit test on OS X

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


Modified:
    compiler-rt/trunk/lib/tsan/tests/unit/tsan_mman_test.cc

Modified: compiler-rt/trunk/lib/tsan/tests/unit/tsan_mman_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/tests/unit/tsan_mman_test.cc?rev=253979&r1=253978&r2=253979&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/tests/unit/tsan_mman_test.cc (original)
+++ compiler-rt/trunk/lib/tsan/tests/unit/tsan_mman_test.cc Tue Nov 24 07:27:33 2015
@@ -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);
 }




More information about the llvm-commits mailing list