Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/gpl3/gcc/dist/libsanitizer Add __lsan::ScopedInterc...
details: https://anonhg.NetBSD.org/src/rev/3a75dff46790
branches: trunk
changeset: 976000:3a75dff46790
user: kamil <kamil%NetBSD.org@localhost>
date: Fri Sep 11 01:03:31 2020 +0000
description:
Add __lsan::ScopedInterceptorDisabler for strerror(3)
Cherry-pick and adapt:
commit 1b58389428ed07a7322ba9c2bcaeec99807f9457
Author: Kamil Rytarowski <n54%gmx.com@localhost>
Date: Sat Sep 21 07:45:02 2019 +0000
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
llvm-svn: 372461
diffstat:
external/gpl3/gcc/dist/libsanitizer/asan/asan_interceptors.cc | 5 ++++
external/gpl3/gcc/dist/libsanitizer/lsan/lsan_interceptors.cc | 12 ++++++++++
external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc | 6 +++++
3 files changed, 23 insertions(+), 0 deletions(-)
diffs (74 lines):
diff -r d19c9d8a6cfa -r 3a75dff46790 external/gpl3/gcc/dist/libsanitizer/asan/asan_interceptors.cc
--- a/external/gpl3/gcc/dist/libsanitizer/asan/asan_interceptors.cc Fri Sep 11 01:01:14 2020 +0000
+++ b/external/gpl3/gcc/dist/libsanitizer/asan/asan_interceptors.cc Fri Sep 11 01:03:31 2020 +0000
@@ -163,6 +163,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"
diff -r d19c9d8a6cfa -r 3a75dff46790 external/gpl3/gcc/dist/libsanitizer/lsan/lsan_interceptors.cc
--- a/external/gpl3/gcc/dist/libsanitizer/lsan/lsan_interceptors.cc Fri Sep 11 01:01:14 2020 +0000
+++ b/external/gpl3/gcc/dist/libsanitizer/lsan/lsan_interceptors.cc Fri Sep 11 01:03:31 2020 +0000
@@ -338,6 +338,16 @@
#define LSAN_MAYBE_INTERCEPT_THR_EXIT
#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;
@@ -447,6 +457,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");
diff -r d19c9d8a6cfa -r 3a75dff46790 external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc
--- a/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc Fri Sep 11 01:01:14 2020 +0000
+++ b/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc Fri Sep 11 01:03:31 2020 +0000
@@ -35,6 +35,7 @@
// COMMON_INTERCEPTOR_MMAP_IMPL
// COMMON_INTERCEPTOR_COPY_STRING
// COMMON_INTERCEPTOR_STRNDUP_IMPL
+// COMMON_INTERCEPTOR_STRERROR
//===----------------------------------------------------------------------===//
#include "interception/interception.h"
@@ -290,6 +291,10 @@
return new_mem;
#endif
+#ifndef COMMON_INTERCEPTOR_STRERROR
+#define COMMON_INTERCEPTOR_STRERROR() {}
+#endif
+
struct FileMetadata {
// For open_memstream().
char **addr;
@@ -3631,6 +3636,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;
Home |
Main Index |
Thread Index |
Old Index