[PATCH] [asan] LSan hooks in asan_rtl
Sergey Matveev
earthdok at google.com
Mon May 20 09:03:45 PDT 2013
Hi kcc, glider,
http://llvm-reviews.chandlerc.com/D831
Files:
lib/asan/asan_flags.h
lib/asan/asan_rtl.cc
Index: lib/asan/asan_flags.h
===================================================================
--- lib/asan/asan_flags.h
+++ lib/asan/asan_flags.h
@@ -108,6 +108,8 @@
// 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 sanitize_leaks;
};
extern Flags asan_flags_dont_use_directly;
Index: lib/asan/asan_rtl.cc
===================================================================
--- lib/asan/asan_rtl.cc
+++ lib/asan/asan_rtl.cc
@@ -24,6 +24,7 @@
#include "sanitizer_common/sanitizer_flags.h"
#include "sanitizer_common/sanitizer_libc.h"
#include "sanitizer_common/sanitizer_symbolizer.h"
+#include "lsan/lsan_common.h"
namespace __asan {
@@ -124,6 +125,7 @@
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->sanitize_leaks, "sanitize_leaks");
}
void InitializeFlags(Flags *f, const char *env) {
@@ -171,6 +173,7 @@
f->use_stack_depot = true;
f->strict_memcmp = true;
f->strict_init_order = false;
+ f->sanitize_leaks = false;
// Override from compile definition.
ParseFlagsFromString(f, MaybeUseAsanDefaultOptionsCompileDefiniton());
@@ -184,6 +187,14 @@
// Override from command line.
ParseFlagsFromString(f, env);
+
+#if SANITIZE_LEAKS
+ if (f->sanitize_leaks && !f->use_stack_depot) {
+ Report("%s: sanitize_leaks is ignored (requires use_stack_depot).\n",
+ SanitizerToolName);
+ f->sanitize_leaks = false;
+ }
+#endif
}
// -------------------------- Globals --------------------- {{{1
@@ -448,6 +459,12 @@
Atexit(asan_atexit);
}
+#if SANITIZE_LEAKS
+ if (flags()->sanitize_leaks) {
+ Atexit(__lsan::DoLeakCheck);
+ }
+#endif
+
// interceptors
InitializeAsanInterceptors();
@@ -527,6 +544,10 @@
main_thread->ThreadStart(internal_getpid());
force_interface_symbols(); // no-op.
+#ifdef SANITIZE_LEAKS
+ __lsan::InitCommonLsan();
+#endif
+
InitializeAllocator();
if (flags()->verbosity) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D831.1.patch
Type: text/x-patch
Size: 2216 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130520/6ed7d50e/attachment.bin>
More information about the llvm-commits
mailing list