[PATCH] D67337: Add __lsan::ScopedInterceptorDisabler for strerror(3)

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 21 00:43:34 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL372461: Add __lsan::ScopedInterceptorDisabler for strerror(3) (authored by kamil, committed by ).
Herald added a subscriber: delcypher.

Changed prior to commit:
  https://reviews.llvm.org/D67337?vs=220412&id=221159#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67337/new/

https://reviews.llvm.org/D67337

Files:
  compiler-rt/trunk/lib/asan/asan_interceptors.cpp
  compiler-rt/trunk/lib/lsan/lsan_interceptors.cpp
  compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc


Index: compiler-rt/trunk/lib/lsan/lsan_interceptors.cpp
===================================================================
--- compiler-rt/trunk/lib/lsan/lsan_interceptors.cpp
+++ compiler-rt/trunk/lib/lsan/lsan_interceptors.cpp
@@ -383,6 +383,16 @@
 #define LSAN_MAYBE_INTERCEPT_PTHREAD_ATFORK
 #endif
 
+#if SANITIZER_INTERCEPT_STRERROR
+INTERCEPTOR(char *, strerror, int errnum) {
+  __lsan::ScopedInterceptorDisabler disabler;
+  return REAL(strerror)(errnum);
+}
+#define LSAN_MAYBE_INTERCEPT_STRERROR INTERCEPT_FUNCTION(strerror)
+#else
+#define LSAN_MAYBE_INTERCEPT_STRERROR
+#endif
+
 struct ThreadParam {
   void *(*callback)(void *arg);
   void *param;
@@ -496,6 +506,8 @@
   LSAN_MAYBE_INTERCEPT_ATEXIT;
   LSAN_MAYBE_INTERCEPT_PTHREAD_ATFORK;
 
+  LSAN_MAYBE_INTERCEPT_STRERROR;
+
 #if !SANITIZER_NETBSD && !SANITIZER_FREEBSD
   if (pthread_key_create(&g_thread_finalize_key, &thread_finalize)) {
     Report("LeakSanitizer: failed to create thread key.\n");
Index: compiler-rt/trunk/lib/asan/asan_interceptors.cpp
===================================================================
--- compiler-rt/trunk/lib/asan/asan_interceptors.cpp
+++ compiler-rt/trunk/lib/asan/asan_interceptors.cpp
@@ -164,6 +164,11 @@
     ASAN_MEMSET_IMPL(ctx, block, c, size);                  \
   } while (false)
 
+#if CAN_SANITIZE_LEAKS
+#define COMMON_INTERCEPTOR_STRERROR()                       \
+  __lsan::ScopedInterceptorDisabler disabler
+#endif
+
 #include "sanitizer_common/sanitizer_common_interceptors.inc"
 #include "sanitizer_common/sanitizer_signal_interceptors.inc"
 
Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -36,6 +36,7 @@
 //   COMMON_INTERCEPTOR_MMAP_IMPL
 //   COMMON_INTERCEPTOR_COPY_STRING
 //   COMMON_INTERCEPTOR_STRNDUP_IMPL
+//   COMMON_INTERCEPTOR_STRERROR
 //===----------------------------------------------------------------------===//
 
 #include "interception/interception.h"
@@ -301,6 +302,10 @@
   return new_mem;
 #endif
 
+#ifndef COMMON_INTERCEPTOR_STRERROR
+#define COMMON_INTERCEPTOR_STRERROR() {}
+#endif
+
 struct FileMetadata {
   // For open_memstream().
   char **addr;
@@ -3677,6 +3682,7 @@
 INTERCEPTOR(char *, strerror, int errnum) {
   void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, strerror, errnum);
+  COMMON_INTERCEPTOR_STRERROR();
   char *res = REAL(strerror)(errnum);
   if (res) COMMON_INTERCEPTOR_INITIALIZE_RANGE(res, REAL(strlen)(res) + 1);
   return res;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67337.221159.patch
Type: text/x-patch
Size: 2670 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190921/342645fb/attachment.bin>


More information about the llvm-commits mailing list