[compiler-rt] r290393 - Fix interceptors setup broken after r290382

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 22 16:37:07 PST 2016


Author: vitalybuka
Date: Thu Dec 22 18:37:07 2016
New Revision: 290393

URL: http://llvm.org/viewvc/llvm-project?rev=290393&view=rev
Log:
Fix interceptors setup broken after r290382

Summary: We setup these interceptors twice which hangs test on windows.

Reviewers: eugenis

Subscribers: llvm-commits, kubabrecka

Differential Revision: https://reviews.llvm.org/D28070

Modified:
    compiler-rt/trunk/lib/asan/asan_interceptors.cc
    compiler-rt/trunk/lib/msan/msan_interceptors.cc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc

Modified: compiler-rt/trunk/lib/asan/asan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interceptors.cc?rev=290393&r1=290392&r2=290393&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_interceptors.cc Thu Dec 22 18:37:07 2016
@@ -272,6 +272,17 @@ DECLARE_REAL_AND_INTERCEPTOR(void, free,
     ASAN_MEMSET_IMPL(ctx, block, c, size);                  \
   } while (false)
 
+// In asan, REAL(memmove) is not used, but it is used in msan.
+#define COMMON_INTERCEPT_FUNCTION_MEMCPY()           \
+  do {                                               \
+    if (PLATFORM_HAS_DIFFERENT_MEMCPY_AND_MEMMOVE) { \
+      ASAN_INTERCEPT_FUNC(memcpy);                   \
+    } else {                                         \
+      ASSIGN_REAL(memcpy, memmove);                  \
+    }                                                \
+    CHECK(REAL(memcpy));                             \
+  } while (false)
+
 #include "sanitizer_common/sanitizer_common_interceptors.inc"
 
 // Syscall interceptors don't have contexts, we don't support suppressions
@@ -722,17 +733,6 @@ void InitializeAsanInterceptors() {
   was_called_once = true;
   InitializeCommonInterceptors();
 
-  // Intercept mem* functions.
-  ASAN_INTERCEPT_FUNC(memmove);
-  ASAN_INTERCEPT_FUNC(memset);
-  if (PLATFORM_HAS_DIFFERENT_MEMCPY_AND_MEMMOVE) {
-    // In asan, REAL(memmove) is not used, but it is used in msan.
-    ASAN_INTERCEPT_FUNC(memcpy);
-  } else {
-    ASSIGN_REAL(memcpy, memmove);
-  }
-  CHECK(REAL(memcpy));
-
   // Intercept str* functions.
   ASAN_INTERCEPT_FUNC(strcat);  // NOLINT
   ASAN_INTERCEPT_FUNC(strcpy);  // NOLINT

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=290393&r1=290392&r2=290393&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/msan/msan_interceptors.cc Thu Dec 22 18:37:07 2016
@@ -1291,6 +1291,7 @@ int OnExit() {
   } while (0)
 
 #define COMMON_INTERCEPT_FUNCTION(name) MSAN_INTERCEPT_FUNC(name)
+#define COMMON_INTERCEPT_FUNCTION_MEMCPY() MSAN_INTERCEPT_FUNC(memcpy)
 #define COMMON_INTERCEPT_FUNCTION_VER(name, ver)                          \
   MSAN_INTERCEPT_FUNC_VER(name, ver)
 #define COMMON_INTERCEPTOR_UNPOISON_PARAM(count)  \
@@ -1516,11 +1517,8 @@ void InitializeInterceptors() {
   INTERCEPT_FUNCTION(fread);
   MSAN_MAYBE_INTERCEPT_FREAD_UNLOCKED;
   INTERCEPT_FUNCTION(readlink);
-  INTERCEPT_FUNCTION(memcpy);
   INTERCEPT_FUNCTION(memccpy);
   INTERCEPT_FUNCTION(mempcpy);
-  INTERCEPT_FUNCTION(memset);
-  INTERCEPT_FUNCTION(memmove);
   INTERCEPT_FUNCTION(bcopy);
   INTERCEPT_FUNCTION(wmemset);
   INTERCEPT_FUNCTION(wmemcpy);

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc?rev=290393&r1=290392&r2=290393&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc Thu Dec 22 18:37:07 2016
@@ -641,7 +641,7 @@ INTERCEPTOR(void *, memcpy, void *dst, c
   COMMON_INTERCEPTOR_MEMCPY_IMPL(ctx, dst, src, size);
 }
 
-#define INIT_MEMCPY COMMON_INTERCEPT_FUNCTION(memcpy)
+#define INIT_MEMCPY COMMON_INTERCEPT_FUNCTION_MEMCPY()
 #else
 #define INIT_MEMCPY
 #endif




More information about the llvm-commits mailing list