diff options
author | Sergey Matveev <earthdok@google.com> | 2013-11-25 14:25:36 +0000 |
---|---|---|
committer | Sergey Matveev <earthdok@google.com> | 2013-11-25 14:25:36 +0000 |
commit | 2d3f8d7840de016c082d601a7e704b7c196119f0 (patch) | |
tree | 4561d6a92dd88f7eeb85494365b87f24a9b124ac /compiler-rt/lib/lsan/lsan.cc | |
parent | [ARM] Enable FeatureMP for Cortex-A5 by default. (diff) | |
download | llvm-project-2d3f8d7840de016c082d601a7e704b7c196119f0.tar.gz llvm-project-2d3f8d7840de016c082d601a7e704b7c196119f0.tar.bz2 llvm-project-2d3f8d7840de016c082d601a7e704b7c196119f0.zip |
[lsan] Unbreak standalone LSan's initialization by making it more like ASan's.
No longer allow interceptors to be called during initialization, use the preinit
array (instead of initializing at the first call to an intercepted function) and
adopt the calloc() hack from ASan.
llvm-svn: 195642
Diffstat (limited to 'compiler-rt/lib/lsan/lsan.cc')
-rw-r--r-- | compiler-rt/lib/lsan/lsan.cc | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/compiler-rt/lib/lsan/lsan.cc b/compiler-rt/lib/lsan/lsan.cc index 1424f3b28060..058bbdba3907 100644 --- a/compiler-rt/lib/lsan/lsan.cc +++ b/compiler-rt/lib/lsan/lsan.cc @@ -20,6 +20,9 @@ #include "lsan_common.h" #include "lsan_thread.h" +bool lsan_inited; +bool lsan_init_is_running; + namespace __lsan { static void InitializeCommonFlags() { @@ -32,11 +35,15 @@ static void InitializeCommonFlags() { ParseCommonFlagsFromString(GetEnv("LSAN_OPTIONS")); } -void Init() { - static bool inited; - if (inited) +} // namespace __lsan + +using namespace __lsan; // NOLINT + +extern "C" void __lsan_init() { + CHECK(!lsan_init_is_running); + if (lsan_inited) return; - inited = true; + lsan_init_is_running = true; SanitizerToolName = "LeakSanitizer"; InitializeCommonFlags(); InitializeAllocator(); @@ -58,6 +65,7 @@ void Init() { InitCommonLsan(); if (common_flags()->detect_leaks && common_flags()->leak_check_at_exit) Atexit(DoLeakCheck); + lsan_inited = true; + lsan_init_is_running = false; } -} // namespace __lsan |