[compiler-rt] r185693 - [msan] Intercept pthread_key_create.
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Fri Jul 5 05:31:07 PDT 2013
Author: eugenis
Date: Fri Jul 5 07:31:07 2013
New Revision: 185693
URL: http://llvm.org/viewvc/llvm-project?rev=185693&view=rev
Log:
[msan] Intercept pthread_key_create.
Modified:
compiler-rt/trunk/lib/msan/msan_interceptors.cc
compiler-rt/trunk/lib/msan/tests/msan_test.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h
Modified: compiler-rt/trunk/lib/msan/msan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_interceptors.cc?rev=185693&r1=185692&r2=185693&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/msan/msan_interceptors.cc Fri Jul 5 07:31:07 2013
@@ -979,6 +979,14 @@ INTERCEPTOR(int, pthread_create, void *t
return res;
}
+INTERCEPTOR(int, pthread_key_create, __sanitizer_pthread_key_t *key, void (*dtor) (void *)) {
+ ENSURE_MSAN_INITED();
+ int res = REAL(pthread_key_create)(key, dtor);
+ if (!res && key)
+ __msan_unpoison(key, sizeof(*key));
+ return res;
+}
+
struct MSanInterceptorContext {
bool in_interceptor_scope;
};
@@ -1220,6 +1228,7 @@ void InitializeInterceptors() {
INTERCEPT_FUNCTION(sigaction);
INTERCEPT_FUNCTION(signal);
INTERCEPT_FUNCTION(pthread_create);
+ INTERCEPT_FUNCTION(pthread_key_create);
inited = 1;
}
} // namespace __msan
Modified: compiler-rt/trunk/lib/msan/tests/msan_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/tests/msan_test.cc?rev=185693&r1=185692&r2=185693&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/tests/msan_test.cc (original)
+++ compiler-rt/trunk/lib/msan/tests/msan_test.cc Fri Jul 5 07:31:07 2013
@@ -2050,6 +2050,15 @@ TEST(MemorySanitizer, pthread_getschedpa
EXPECT_NOT_POISONED(param.sched_priority);
}
+TEST(MemorySanitizer, pthread_key_create) {
+ pthread_key_t key;
+ int res = pthread_key_create(&key, NULL);
+ assert(!res);
+ EXPECT_NOT_POISONED(key);
+ res = pthread_key_delete(key);
+ assert(!res);
+}
+
TEST(MemorySanitizer, posix_memalign) {
void *p;
EXPECT_POISONED(p);
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.cc?rev=185693&r1=185692&r2=185693&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.cc Fri Jul 5 07:31:07 2013
@@ -727,6 +727,7 @@ COMPILER_CHECK(sizeof(__sanitizer::struc
sizeof(__sanitizer::struct_sigaction_sz));
COMPILER_CHECK(sizeof(socklen_t) == sizeof(unsigned));
+CHECK_TYPE_SIZE(pthread_key_t);
#if SANITIZER_LINUX
// There are more undocumented fields in dl_phdr_info that we are not interested
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h?rev=185693&r1=185692&r2=185693&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h Fri Jul 5 07:31:07 2013
@@ -55,6 +55,8 @@ namespace __sanitizer {
uptr iov_len;
};
+ typedef unsigned __sanitizer_pthread_key_t;
+
#if SANITIZER_ANDROID || SANITIZER_MAC
struct __sanitizer_msghdr {
void *msg_name;
More information about the llvm-commits
mailing list