[PATCH] D67337: Add __lsan::ScopedInterceptorDisabler for strerror(3)/NetBSD
Kamil Rytarowski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 11 08:00:57 PDT 2019
krytarowski updated this revision to Diff 219718.
krytarowski added a comment.
- restrict __lsan::ScopedInterceptorDisabler to ASan and LSan
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D67337/new/
https://reviews.llvm.org/D67337
Files:
lib/asan/asan_interceptors.cpp
lib/lsan/lsan_interceptors.cpp
Index: lib/lsan/lsan_interceptors.cpp
===================================================================
--- lib/lsan/lsan_interceptors.cpp
+++ lib/lsan/lsan_interceptors.cpp
@@ -345,6 +345,16 @@
#define LSAN_MAYBE_INTERCEPT_THR_EXIT
#endif
+#if SANITIZER_NETBSD
+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;
@@ -454,6 +464,8 @@
LSAN_MAYBE_INTERCEPT__LWP_EXIT;
LSAN_MAYBE_INTERCEPT_THR_EXIT;
+ 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: lib/asan/asan_interceptors.cpp
===================================================================
--- lib/asan/asan_interceptors.cpp
+++ lib/asan/asan_interceptors.cpp
@@ -164,6 +164,8 @@
ASAN_MEMSET_IMPL(ctx, block, c, size); \
} while (false)
+#undef SANITIZER_INTERCEPT_STRERROR
+
#include "sanitizer_common/sanitizer_common_interceptors.inc"
#include "sanitizer_common/sanitizer_signal_interceptors.inc"
@@ -248,6 +250,19 @@
DEFINE_REAL_PTHREAD_FUNCTIONS
#endif // ASAN_INTERCEPT_PTHREAD_CREATE
+#if SANITIZER_INTERCEPT_STRERROR
+INTERCEPTOR(char *, strerror, int errnum) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, strerror, errnum);
+#if CAN_SANITIZE_LEAKS
+ __lsan::ScopedInterceptorDisabler disabler;
+#endif
+ char *res = REAL(strerror)(errnum);
+ if (res) COMMON_INTERCEPTOR_INITIALIZE_RANGE(res, REAL(strlen)(res) + 1);
+ return res;
+}
+#endif
+
#if ASAN_INTERCEPT_SWAPCONTEXT
static void ClearShadowMemoryForContextStack(uptr stack, uptr ssize) {
// Align to page size.
@@ -620,6 +635,9 @@
#if ASAN_INTERCEPT_SWAPCONTEXT
ASAN_INTERCEPT_FUNC(swapcontext);
#endif
+#if SANITIZER_INTERCEPT_STRERROR
+ ASAN_INTERCEPT_FUNC(strerror);
+#endif
#if ASAN_INTERCEPT__LONGJMP
ASAN_INTERCEPT_FUNC(_longjmp);
#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67337.219718.patch
Type: text/x-patch
Size: 2182 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190911/3153b5f4/attachment.bin>
More information about the llvm-commits
mailing list