diff options
author | Kamil Rytarowski <n54@gmx.com> | 2019-09-21 07:45:02 +0000 |
---|---|---|
committer | Kamil Rytarowski <n54@gmx.com> | 2019-09-21 07:45:02 +0000 |
commit | 16dfa3fc2f2ac2a3ec23e61a448c8595397ffbaf (patch) | |
tree | a2cb08c4a1565cbbbcb3b5d30ef209e6675cc237 /lib/lsan/lsan_interceptors.cpp | |
parent | 54f5dca4b6446825d51b1d0b4bd313079dbfda70 (diff) | |
download | compiler-rt-16dfa3fc2f2ac2a3ec23e61a448c8595397ffbaf.tar.gz |
Add __lsan::ScopedInterceptorDisabler for strerror(3)
Summary:
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.
Reviewers: joerg, vitalybuka, dvyukov, mgorny
Reviewed By: vitalybuka
Subscribers: dmgreen, kristof.beyls, jfb, llvm-commits, #sanitizers
Tags: #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D67337
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@372461 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/lsan/lsan_interceptors.cpp')
-rw-r--r-- | lib/lsan/lsan_interceptors.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/lsan/lsan_interceptors.cpp b/lib/lsan/lsan_interceptors.cpp index 84a6acda4..601a5efe9 100644 --- a/lib/lsan/lsan_interceptors.cpp +++ b/lib/lsan/lsan_interceptors.cpp @@ -383,6 +383,16 @@ INTERCEPTOR(int, pthread_atfork, void (*prepare)(), void (*parent)(), #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 @@ void InitializeInterceptors() { 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"); |