[PATCH] D32303: Define a suppression for known leaks on pthread_exit call.
Aleksey Shlyapnikov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 20 13:35:44 PDT 2017
alekseyshl updated this revision to Diff 96007.
alekseyshl added a comment.
- Define standard suppressions for LSan, start with this one.
https://reviews.llvm.org/D32303
Files:
lib/asan/tests/asan_test_main.cc
lib/lsan/lsan_common.cc
lib/sanitizer_common/sanitizer_platform.h
Index: lib/sanitizer_common/sanitizer_platform.h
===================================================================
--- lib/sanitizer_common/sanitizer_platform.h
+++ lib/sanitizer_common/sanitizer_platform.h
@@ -259,4 +259,15 @@
# define SANITIZER_GO 0
#endif
+// On PowerPC and ARM Thumb, calling pthread_exit() causes LSan to detect leaks.
+// pthread_exit() performs unwinding that leads to dlopen'ing libgcc_s.so.
+// dlopen mallocs "libgcc_s.so" string which confuses LSan, it fails to realize
+// that this allocation happens in dynamic linker and should be ignored.
+#if SANITIZER_PPC || defined(__thumb__)
+# define SANITIZER_SUPPRESS_LEAK_ON_PTHREAD_EXIT 1
+#else
+# define SANITIZER_SUPPRESS_LEAK_ON_PTHREAD_EXIT 0
+#endif
+
+
#endif // SANITIZER_PLATFORM_H
Index: lib/lsan/lsan_common.cc
===================================================================
--- lib/lsan/lsan_common.cc
+++ lib/lsan/lsan_common.cc
@@ -68,14 +68,23 @@
static SuppressionContext *suppression_ctx = nullptr;
static const char kSuppressionLeak[] = "leak";
static const char *kSuppressionTypes[] = { kSuppressionLeak };
+static const char kStdSuppressions[] =
+#if SANITIZER_SUPPRESS_LEAK_ON_PTHREAD_EXIT
+ // The actual string allocation happens here (for more details refer to the
+ // SANITIZER_SUPPRESS_LEAK_ON_PTHREAD_EXIT definition).
+ "leak:*_dl_map_object_deps*";
+#else
+ "";
+#endif // SANITIZER_SUPPRESS_LEAK_ON_PTHREAD_EXIT
void InitializeSuppressions() {
CHECK_EQ(nullptr, suppression_ctx);
suppression_ctx = new (suppression_placeholder) // NOLINT
SuppressionContext(kSuppressionTypes, ARRAY_SIZE(kSuppressionTypes));
suppression_ctx->ParseFromFile(flags()->suppressions);
if (&__lsan_default_suppressions)
suppression_ctx->Parse(__lsan_default_suppressions());
+ suppression_ctx->Parse(kStdSuppressions);
}
static SuppressionContext *GetSuppressionContext() {
Index: lib/asan/tests/asan_test_main.cc
===================================================================
--- lib/asan/tests/asan_test_main.cc
+++ lib/asan/tests/asan_test_main.cc
@@ -22,13 +22,10 @@
// turn symbolization off to speed up testing, especially when not running
// with llvm-symbolizer but with atos.
return "symbolize=false:abort_on_error=0:log_to_syslog=0";
-#elif SANITIZER_PPC || defined(__thumb__)
+#elif SANITIZER_SUPPRESS_LEAK_ON_PTHREAD_EXIT
// On PowerPC and ARM Thumb, a couple tests involving pthread_exit fail due to
- // leaks detected by LSan. pthread_exit tries to perform unwinding that leads
- // to dlopen'ing libgcc_s.so. dlopen mallocs "libgcc_s.so" string which
- // confuses LSan, it fails to realize that this allocation happens in dynamic
- // linker and should be ignored. Symbolized leak report is required to define
- // a suppression for this known problem.
+ // leaks detected by LSan. Symbolized leak report is required to apply a
+ // suppression for this known problem.
return "";
#else
// Let's turn symbolization off to speed up testing (more than 3 times speedup
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32303.96007.patch
Type: text/x-patch
Size: 3049 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170420/b05c2f72/attachment.bin>
More information about the llvm-commits
mailing list