[PATCH] [lsan] Make __lsan_do_leak_check() honor the detect_leaks flag.
Sergey Matveev
earthdok at google.com
Mon Jul 22 04:50:10 PDT 2013
- moved detect_leaks to common flags
Hi kcc,
http://llvm-reviews.chandlerc.com/D1193
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D1193?vs=2935&id=2936#toc
Files:
lib/asan/asan_flags.h
lib/asan/asan_rtl.cc
lib/lsan/lsan.cc
lib/lsan/lsan_common.cc
lib/sanitizer_common/sanitizer_flags.cc
lib/sanitizer_common/sanitizer_flags.h
Index: lib/asan/asan_flags.h
===================================================================
--- lib/asan/asan_flags.h
+++ lib/asan/asan_flags.h
@@ -106,8 +106,6 @@
// If true, assume that dynamic initializers can never access globals from
// other modules, even if the latter are already initialized.
bool strict_init_order;
- // Invoke LeakSanitizer at process exit.
- bool detect_leaks;
};
extern Flags asan_flags_dont_use_directly;
Index: lib/asan/asan_rtl.cc
===================================================================
--- lib/asan/asan_rtl.cc
+++ lib/asan/asan_rtl.cc
@@ -124,7 +124,6 @@
ParseFlag(str, &f->use_stack_depot, "use_stack_depot");
ParseFlag(str, &f->strict_memcmp, "strict_memcmp");
ParseFlag(str, &f->strict_init_order, "strict_init_order");
- ParseFlag(str, &f->detect_leaks, "detect_leaks");
}
void InitializeFlags(Flags *f, const char *env) {
@@ -137,6 +136,7 @@
cf->strip_path_prefix = "";
cf->handle_ioctl = false;
cf->log_path = 0;
+ cf->detect_leaks = false;
internal_memset(f, 0, sizeof(*f));
f->quarantine_size = (ASAN_LOW_MEMORY) ? 1UL << 26 : 1UL << 28;
@@ -173,7 +173,6 @@
f->use_stack_depot = true;
f->strict_memcmp = true;
f->strict_init_order = false;
- f->detect_leaks = false;
// Override from compile definition.
ParseFlagsFromString(f, MaybeUseAsanDefaultOptionsCompileDefiniton());
@@ -189,17 +188,17 @@
ParseFlagsFromString(f, env);
#if !CAN_SANITIZE_LEAKS
- if (f->detect_leaks) {
+ if (cf->detect_leaks) {
Report("%s: detect_leaks is not supported on this platform.\n",
SanitizerToolName);
- f->detect_leaks = false;
+ cf->detect_leaks = false;
}
#endif
- if (f->detect_leaks && !f->use_stack_depot) {
+ if (cf->detect_leaks && !f->use_stack_depot) {
Report("%s: detect_leaks is ignored (requires use_stack_depot).\n",
SanitizerToolName);
- f->detect_leaks = false;
+ cf->detect_leaks = false;
}
}
@@ -557,7 +556,7 @@
#if CAN_SANITIZE_LEAKS
__lsan::InitCommonLsan();
- if (flags()->detect_leaks) {
+ if (common_flags()->detect_leaks) {
Atexit(__lsan::DoLeakCheck);
}
#endif // CAN_SANITIZE_LEAKS
Index: lib/lsan/lsan.cc
===================================================================
--- lib/lsan/lsan.cc
+++ lib/lsan/lsan.cc
@@ -30,6 +30,7 @@
cf->strip_path_prefix = "";
cf->fast_unwind_on_malloc = true;
cf->malloc_context_size = 30;
+ cf->detect_leaks = true;
ParseCommonFlagsFromString(GetEnv("LSAN_OPTIONS"));
}
Index: lib/lsan/lsan_common.cc
===================================================================
--- lib/lsan/lsan_common.cc
+++ lib/lsan/lsan_common.cc
@@ -550,8 +550,9 @@
SANITIZER_INTERFACE_ATTRIBUTE
void __lsan_do_leak_check() {
#if CAN_SANITIZE_LEAKS
- __lsan::DoLeakCheck();
-#endif
+ if (common_flags()->detect_leaks)
+ __lsan::DoLeakCheck();
+#endif // CAN_SANITIZE_LEAKS
}
#if !SANITIZER_SUPPORTS_WEAK_HOOKS
Index: lib/sanitizer_common/sanitizer_flags.cc
===================================================================
--- lib/sanitizer_common/sanitizer_flags.cc
+++ lib/sanitizer_common/sanitizer_flags.cc
@@ -29,6 +29,7 @@
ParseFlag(str, &f->symbolize, "symbolize");
ParseFlag(str, &f->handle_ioctl, "handle_ioctl");
ParseFlag(str, &f->log_path, "log_path");
+ ParseFlag(str, &f->detect_leaks, "detect_leaks");
}
static bool GetFlagValue(const char *env, const char *name,
Index: lib/sanitizer_common/sanitizer_flags.h
===================================================================
--- lib/sanitizer_common/sanitizer_flags.h
+++ lib/sanitizer_common/sanitizer_flags.h
@@ -39,6 +39,8 @@
int malloc_context_size;
// Write logs to "log_path.pid" instead of stderr.
const char *log_path;
+ // Enable memory leak detection.
+ bool detect_leaks;
};
extern CommonFlags common_flags_dont_use_directly;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1193.2.patch
Type: text/x-patch
Size: 3901 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130722/4854598e/attachment.bin>
More information about the llvm-commits
mailing list