summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/tests
diff options
context:
space:
mode:
authorDimitry Andric <dimitry@andric.com>2017-01-27 22:19:11 +0000
committerDimitry Andric <dimitry@andric.com>2017-01-27 22:19:11 +0000
commit13c02ddee3f4d845307250512c6eb54564f7c39a (patch)
tree18416a60b96c72202716a16894c08130b861eef3 /lib/sanitizer_common/tests
parent164a6f2dc1023111b14c93c1036a9d3c5a55c16b (diff)
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. Reviewers: emaste, kcc Subscribers: hans, joerg, llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D27654 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@293337 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 {