diff options
author | Arnold Schwaighofer <aschwaighofer@apple.com> | 2014-06-18 19:04:47 +0000 |
---|---|---|
committer | Arnold Schwaighofer <aschwaighofer@apple.com> | 2014-06-18 19:04:47 +0000 |
commit | 9e63682b521d5399a8d338b4e55ad6d4e0b8f623 (patch) | |
tree | 05ba18ec70b488e7b57ae6ff39f5154442756955 | |
parent | 6a3cc4bb69cfad556de58fe30a31629141839fc0 (diff) | |
download | compiler-rt-9e63682b521d5399a8d338b4e55ad6d4e0b8f623.tar.gz |
Revert "[sanitizer] Intercept pthread_*attr_get*."
This reverts commit r211166. It broke public mac os x bots.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@211206 91177308-0d34-0410-b5e6-96231b3b80d8
6 files changed, 11 insertions, 103 deletions
diff --git a/lib/sanitizer_common/sanitizer_common_interceptors.inc b/lib/sanitizer_common/sanitizer_common_interceptors.inc index 8b5ee47b6..e73431c09 100644 --- a/lib/sanitizer_common/sanitizer_common_interceptors.inc +++ b/lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -3294,26 +3294,19 @@ INTERCEPTOR(int, random_r, void *buf, u32 *result) { // FIXME: under ASan the REAL() call below may write to freed memory and corrupt // its metadata. See // https://code.google.com/p/address-sanitizer/issues/detail?id=321. -#if SANITIZER_INTERCEPT_PTHREAD_ATTR_GET || \ - SANITIZER_INTERCEPT_PTHREAD_ATTR_GETINHERITSSCHED || \ - SANITIZER_INTERCEPT_PTHREAD_MUTEXATTR_GET || \ - SANITIZER_INTERCEPT_PTHREAD_RWLOCKATTR_GET || \ - SANITIZER_INTERCEPT_PTHREAD_CONDATTR_GET || \ - SANITIZER_INTERCEPT_PTHREAD_BARRIERATTR_GET -#define INTERCEPTOR_PTHREAD_OBJECT_ATTR_GET(fn, sz) \ - INTERCEPTOR(int, fn, void *attr, void *r) { \ - void *ctx; \ - COMMON_INTERCEPTOR_ENTER(ctx, fn, attr, r); \ - int res = REAL(fn)(attr, r); \ - if (!res && r) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, r, sz); \ - return res; \ +#if SANITIZER_INTERCEPT_PTHREAD_ATTR_GET || \ + SANITIZER_INTERCEPT_PTHREAD_ATTR_GETINHERITSSCHED +#define INTERCEPTOR_PTHREAD_ATTR_GET(what, sz) \ + INTERCEPTOR(int, pthread_attr_get##what, void *attr, void *r) { \ + void *ctx; \ + COMMON_INTERCEPTOR_ENTER(ctx, pthread_attr_get##what, attr, r); \ + int res = REAL(pthread_attr_get##what)(attr, r); \ + if (!res && r) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, r, sz); \ + return res; \ } #endif - #if SANITIZER_INTERCEPT_PTHREAD_ATTR_GET -#define INTERCEPTOR_PTHREAD_ATTR_GET(what, sz) \ - INTERCEPTOR_PTHREAD_OBJECT_ATTR_GET(pthread_attr_get##what, sz) INTERCEPTOR_PTHREAD_ATTR_GET(detachstate, sizeof(int)) INTERCEPTOR_PTHREAD_ATTR_GET(guardsize, sizeof(SIZE_T)) INTERCEPTOR_PTHREAD_ATTR_GET(schedparam, struct_sched_param_sz) @@ -3387,60 +3380,6 @@ INTERCEPTOR(int, pthread_attr_getaffinity_np, void *attr, SIZE_T cpusetsize, #define INIT_PTHREAD_ATTR_GETAFFINITY_NP #endif -#if SANITIZER_INTERCEPT_PTHREAD_MUTEXATTR_GET -#define INTERCEPTOR_PTHREAD_MUTEXATTR_GET(what, sz) \ - INTERCEPTOR_PTHREAD_OBJECT_ATTR_GET(pthread_mutexattr_get##what, sz) -INTERCEPTOR_PTHREAD_MUTEXATTR_GET(pshared, sizeof(int)) -INTERCEPTOR_PTHREAD_MUTEXATTR_GET(type, sizeof(int)) -INTERCEPTOR_PTHREAD_MUTEXATTR_GET(protocol, sizeof(int)) -INTERCEPTOR_PTHREAD_MUTEXATTR_GET(prioceiling, sizeof(int)) -INTERCEPTOR_PTHREAD_MUTEXATTR_GET(robust, sizeof(int)) -INTERCEPTOR_PTHREAD_MUTEXATTR_GET(robust_np, sizeof(int)) -#define INIT_PTHREAD_MUTEXATTR_GET \ - COMMON_INTERCEPT_FUNCTION(pthread_mutexattr_getpshared); \ - COMMON_INTERCEPT_FUNCTION(pthread_mutexattr_gettype); \ - COMMON_INTERCEPT_FUNCTION(pthread_mutexattr_getprotocol); \ - COMMON_INTERCEPT_FUNCTION(pthread_mutexattr_getprioceiling); \ - COMMON_INTERCEPT_FUNCTION(pthread_mutexattr_getrobust); \ - COMMON_INTERCEPT_FUNCTION(pthread_mutexattr_getrobust_np); -#else -#define INIT_PTHREAD_MUTEXATTR_GET -#endif - -#if SANITIZER_INTERCEPT_PTHREAD_RWLOCKATTR_GET -#define INTERCEPTOR_PTHREAD_RWLOCKATTR_GET(what, sz) \ - INTERCEPTOR_PTHREAD_OBJECT_ATTR_GET(pthread_rwlockattr_get##what, sz) -INTERCEPTOR_PTHREAD_RWLOCKATTR_GET(pshared, sizeof(int)) -INTERCEPTOR_PTHREAD_RWLOCKATTR_GET(kind_np, sizeof(int)) -#define INIT_PTHREAD_RWLOCKATTR_GET \ - COMMON_INTERCEPT_FUNCTION(pthread_rwlockattr_getpshared); \ - COMMON_INTERCEPT_FUNCTION(pthread_rwlockattr_getkind_np); -#else -#define INIT_PTHREAD_RWLOCKATTR_GET -#endif - -#if SANITIZER_INTERCEPT_PTHREAD_CONDATTR_GET -#define INTERCEPTOR_PTHREAD_CONDATTR_GET(what, sz) \ - INTERCEPTOR_PTHREAD_OBJECT_ATTR_GET(pthread_condattr_get##what, sz) -INTERCEPTOR_PTHREAD_CONDATTR_GET(pshared, sizeof(int)) -INTERCEPTOR_PTHREAD_CONDATTR_GET(clock, sizeof(__sanitizer_clockid_t)) -#define INIT_PTHREAD_CONDATTR_GET \ - COMMON_INTERCEPT_FUNCTION(pthread_condattr_getpshared); \ - COMMON_INTERCEPT_FUNCTION(pthread_condattr_getclock); -#else -#define INIT_PTHREAD_CONDATTR_GET -#endif - -#if SANITIZER_INTERCEPT_PTHREAD_BARRIERATTR_GET -#define INTERCEPTOR_PTHREAD_BARRIERATTR_GET(what, sz) \ - INTERCEPTOR_PTHREAD_OBJECT_ATTR_GET(pthread_barrierattr_get##what, sz) -INTERCEPTOR_PTHREAD_BARRIERATTR_GET(pshared, sizeof(int)) -#define INIT_PTHREAD_BARRIERATTR_GET \ - COMMON_INTERCEPT_FUNCTION(pthread_barrierattr_getpshared); -#else -#define INIT_PTHREAD_BARRIERATTR_GET -#endif - #if SANITIZER_INTERCEPT_TMPNAM INTERCEPTOR(char *, tmpnam, char *s) { void *ctx; @@ -4667,10 +4606,6 @@ static void InitializeCommonInterceptors() { INIT_PTHREAD_ATTR_GET; INIT_PTHREAD_ATTR_GETINHERITSCHED; INIT_PTHREAD_ATTR_GETAFFINITY_NP; - INIT_PTHREAD_MUTEXATTR_GET; - INIT_PTHREAD_RWLOCKATTR_GET; - INIT_PTHREAD_CONDATTR_GET; - INIT_PTHREAD_BARRIERATTR_GET; INIT_TMPNAM; INIT_TMPNAM_R; INIT_TEMPNAM; diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h index 2b3fe257e..a51a00c69 100644 --- a/lib/sanitizer_common/sanitizer_platform_interceptors.h +++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h @@ -163,10 +163,6 @@ #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GETINHERITSCHED \ SI_MAC || SI_LINUX_NOT_ANDROID #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GETAFFINITY_NP SI_LINUX_NOT_ANDROID -#define SANITIZER_INTERCEPT_PTHREAD_MUTEXATTR_GET SI_NOT_WINDOWS -#define SANITIZER_INTERCEPT_PTHREAD_RWLOCKATTR_GET SI_NOT_WINDOWS -#define SANITIZER_INTERCEPT_PTHREAD_CONDATTR_GET SI_NOT_WINDOWS -#define SANITIZER_INTERCEPT_PTHREAD_BARRIERATTR_GET SI_NOT_WINDOWS #define SANITIZER_INTERCEPT_TMPNAM SI_NOT_WINDOWS #define SANITIZER_INTERCEPT_TMPNAM_R SI_LINUX_NOT_ANDROID #define SANITIZER_INTERCEPT_TEMPNAM SI_NOT_WINDOWS diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc index 4d43e7243..d6f3e4352 100644 --- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc +++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc @@ -1058,7 +1058,6 @@ CHECK_SIZE_AND_OFFSET(shmid_ds, shm_nattch); #endif CHECK_TYPE_SIZE(clock_t); -CHECK_TYPE_SIZE(clockid_t); #if !SANITIZER_ANDROID CHECK_TYPE_SIZE(ifaddrs); diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/lib/sanitizer_common/sanitizer_platform_limits_posix.h index c14da7a2a..998832417 100644 --- a/lib/sanitizer_common/sanitizer_platform_limits_posix.h +++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.h @@ -440,8 +440,6 @@ namespace __sanitizer { typedef long __sanitizer_clock_t; #endif - typedef int __sanitizer_clockid_t; - #if SANITIZER_LINUX || SANITIZER_FREEBSD #if defined(_LP64) || defined(__x86_64__) || defined(__powerpc__) typedef unsigned __sanitizer___kernel_uid_t; diff --git a/lib/tsan/rtl/tsan_interceptors.cc b/lib/tsan/rtl/tsan_interceptors.cc index cd44f2b50..8d294e017 100644 --- a/lib/tsan/rtl/tsan_interceptors.cc +++ b/lib/tsan/rtl/tsan_interceptors.cc @@ -47,7 +47,7 @@ DECLARE_REAL(int, pthread_attr_getdetachstate, void *, void *) extern "C" int pthread_attr_setstacksize(void *attr, uptr stacksize); extern "C" int pthread_key_create(unsigned *key, void (*destructor)(void* v)); extern "C" int pthread_setspecific(unsigned key, const void *v); -DECLARE_REAL(int, pthread_mutexattr_gettype, void *, void *) +extern "C" int pthread_mutexattr_gettype(void *a, int *type); extern "C" int pthread_yield(); extern "C" int pthread_sigmask(int how, const __sanitizer_sigset_t *set, __sanitizer_sigset_t *oldset); @@ -1029,7 +1029,7 @@ TSAN_INTERCEPTOR(int, pthread_mutex_init, void *m, void *a) { bool recursive = false; if (a) { int type = 0; - if (REAL(pthread_mutexattr_gettype)(a, &type) == 0) + if (pthread_mutexattr_gettype(a, &type) == 0) recursive = (type == PTHREAD_MUTEX_RECURSIVE || type == PTHREAD_MUTEX_RECURSIVE_NP); } diff --git a/test/sanitizer_common/TestCases/pthread_mutexattr_get.cc b/test/sanitizer_common/TestCases/pthread_mutexattr_get.cc deleted file mode 100644 index 2e4483eac..000000000 --- a/test/sanitizer_common/TestCases/pthread_mutexattr_get.cc +++ /dev/null @@ -1,20 +0,0 @@ -// RUN: %clangxx -O0 %s -o %t && %run %t -// XFAIL: arm-linux-gnueabi - -#include <assert.h> -#include <pthread.h> - -int main(void) { - pthread_mutexattr_t ma; - int res = pthread_mutexattr_init(&ma); - assert(res == 0); - res = pthread_mutexattr_setpshared(&ma, 1); - assert(res == 0); - int pshared; - res = pthread_mutexattr_getpshared(&ma, &pshared); - assert(res == 0); - assert(pshared == 1); - res = pthread_mutexattr_destroy(&ma); - assert(res == 0); - return 0; -} |