[compiler-rt] 03dc87e - Revert "[sanitizer][asan][win] Intercept _strdup on Windows instead of strdup"

Mitch Phillips via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 18 03:20:53 PDT 2023


Author: Mitch Phillips
Date: 2023-07-18T12:19:56+02:00
New Revision: 03dc87e93937bf25a48bc77d0006c59f37b1855d

URL: https://github.com/llvm/llvm-project/commit/03dc87e93937bf25a48bc77d0006c59f37b1855d
DIFF: https://github.com/llvm/llvm-project/commit/03dc87e93937bf25a48bc77d0006c59f37b1855d.diff

LOG: Revert "[sanitizer][asan][win] Intercept _strdup on Windows instead of strdup"

This reverts commit 31263211c6a4ef454216f2edbf9b2083a4c1474d.

Reason: Broke the ASan Windows bot: https://reviews.llvm.org/rG31263211c6a4ef454216f2edbf9b2083a4c1474d

Added: 
    

Modified: 
    compiler-rt/lib/asan/asan_interceptors.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/asan/asan_interceptors.cpp b/compiler-rt/lib/asan/asan_interceptors.cpp
index 0e128c3da68267..b9b82564b33035 100644
--- a/compiler-rt/lib/asan/asan_interceptors.cpp
+++ b/compiler-rt/lib/asan/asan_interceptors.cpp
@@ -539,17 +539,6 @@ INTERCEPTOR(char *, strcpy, char *to, const char *from) {
   return REAL(strcpy)(to, from);
 }
 
-// Windows doesn't always define the strdup identifier,
-// and when it does it's a macro defined to either _strdup
-// or _strdup_dbg, _strdup_dbg ends up calling _strdup, so
-// we want to intercept that. push/pop_macro are used to avoid problems
-// if this file ends up including <string.h> in the future.
-#  if SANITIZER_WINDOWS
-#    pragma push_macro("strdup")
-#    undef strdup
-#    define strdup _strdup
-#  endif
-
 INTERCEPTOR(char*, strdup, const char *s) {
   void *ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, strdup);
@@ -567,7 +556,7 @@ INTERCEPTOR(char*, strdup, const char *s) {
   return reinterpret_cast<char*>(new_mem);
 }
 
-#  if ASAN_INTERCEPT___STRDUP
+#if ASAN_INTERCEPT___STRDUP
 INTERCEPTOR(char*, __strdup, const char *s) {
   void *ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, strdup);
@@ -753,7 +742,7 @@ void InitializeAsanInterceptors() {
   ASAN_INTERCEPT_FUNC(strncat);
   ASAN_INTERCEPT_FUNC(strncpy);
   ASAN_INTERCEPT_FUNC(strdup);
-#  if ASAN_INTERCEPT___STRDUP
+#if ASAN_INTERCEPT___STRDUP
   ASAN_INTERCEPT_FUNC(__strdup);
 #endif
 #if ASAN_INTERCEPT_INDEX && ASAN_USE_ALIAS_ATTRIBUTE_FOR_INDEX
@@ -842,10 +831,6 @@ void InitializeAsanInterceptors() {
   VReport(1, "AddressSanitizer: libc interceptors initialized\n");
 }
 
-#  if SANITIZER_WINDOWS
-#    pragma pop_macro("strdup")
-#  endif
-
 } // namespace __asan
 
 #endif  // !SANITIZER_FUCHSIA


        


More information about the llvm-commits mailing list