[PATCH] D67337: Add __lsan::ScopedInterceptorDisabler for strerror(3)/NetBSD
Kamil Rytarowski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 8 16:38:54 PDT 2019
krytarowski created this revision.
krytarowski added reviewers: joerg, vitalybuka, dvyukov, mgorny.
krytarowski added a project: Sanitizers.
Herald added subscribers: llvm-commits, jfb, kristof.beyls.
Herald added a project: LLVM.
strerror(3) on NetBSD uses internally TSD with a destructor that is never
fired for exit(3). It's correctly called for pthread_exit(3) scenarios.
This is a case when a leak on exit(3) is expected, unavoidable and harmless.
Repository:
rL LLVM
https://reviews.llvm.org/D67337
Files:
lib/lsan/lsan_interceptors.cpp
lib/sanitizer_common/sanitizer_common_interceptors.inc
Index: lib/sanitizer_common/sanitizer_common_interceptors.inc
===================================================================
--- lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -46,6 +46,8 @@
#include "sanitizer_symbolizer.h"
#include "sanitizer_tls_get_addr.h"
+#include "lsan/lsan_common.h"
+
#include <stdarg.h>
#if SANITIZER_INTERCEPTOR_HOOKS
@@ -3676,6 +3678,9 @@
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;
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");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67337.219281.patch
Type: text/x-patch
Size: 1669 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190908/f3f4089f/attachment.bin>
More information about the llvm-commits
mailing list