summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/tests
diff options
context:
space:
mode:
authorDimitry Andric <dimitry@andric.com>2017-01-30 19:06:13 +0000
committerDimitry Andric <dimitry@andric.com>2017-01-30 19:06:13 +0000
commit2967dfb22beadb462cbb07c36e0398281935c6b8 (patch)
tree3b9018d75db1277eb77bdd1d22c0a5cbd49a4f73 /lib/sanitizer_common/tests
parent220f64c5cf362c3b2a31b79fd1c606bf3c99933f (diff)
Recommit: Stop intercepting some malloc-related functions on FreeBSD and
macOS Summary: In https://bugs.freebsd.org/215125 I was notified that some configure scripts attempt to test for the Linux-specific `mallinfo` and `mallopt` functions by compiling and linking small programs which references the functions, and observing whether that results in errors. FreeBSD and macOS do not have the `mallinfo` and `mallopt` functions, so normally these tests would fail, but when sanitizers are enabled, they incorrectly succeed, because the sanitizers define interceptors for these functions. This also applies to some other malloc-related functions, such as `memalign`, `pvalloc` and `cfree`. Fix this by not intercepting `mallinfo`, `mallopt`, `memalign`, `pvalloc` and `cfree` for FreeBSD and macOS, in all sanitizers. Also delete the non-functional `cfree` wrapper for Windows, to fix the test cases on that platform. Reviewers: emaste, kcc, rnk Subscribers: timurrrr, eugenis, hans, joerg, llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D27654 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@293536 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/tests')
-rw-r--r--lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc b/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc
index c6dd3c4bb..d2920d8f7 100644
--- a/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc
+++ b/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc
@@ -139,6 +139,7 @@ void *realloc(void *p, size_t size) {
return p;
}
+#if SANITIZER_INTERCEPT_MEMALIGN
void *memalign(size_t alignment, size_t size) {
if (UNLIKELY(!thread_inited))
thread_init();
@@ -146,6 +147,7 @@ void *memalign(size_t alignment, size_t size) {
SANITIZER_MALLOC_HOOK(p, size);
return p;
}
+#endif // SANITIZER_INTERCEPT_MEMALIGN
int posix_memalign(void **memptr, size_t alignment, size_t size) {
if (UNLIKELY(!thread_inited))
@@ -165,18 +167,26 @@ void *valloc(size_t size) {
return p;
}
+#if SANITIZER_INTERCEPT_CFREE
void cfree(void *p) ALIAS("free");
+#endif // SANITIZER_INTERCEPT_CFREE
+#if SANITIZER_INTERCEPT_PVALLOC
void *pvalloc(size_t size) ALIAS("valloc");
+#endif // SANITIZER_INTERCEPT_PVALLOC
+#if SANITIZER_INTERCEPT_MEMALIGN
void *__libc_memalign(size_t alignment, size_t size) ALIAS("memalign");
+#endif // SANITIZER_INTERCEPT_MEMALIGN
void malloc_usable_size() {
}
+#if SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO
void mallinfo() {
}
void mallopt() {
}
+#endif // SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO
} // extern "C"
namespace std {