summaryrefslogtreecommitdiff
path: root/lib/lsan/lsan.cc
AgeCommit message (Collapse)Author
2017-11-09[sanitizers] Rename GetStackTraceWithPcBpAndContextVitaly Buka
Name does not need to enumerate arguments. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@317774 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-09[lsan] Add "static" to internal functionVitaly Buka
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@317772 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-22[lsan] Add __lsan_default_optionsVitaly Buka
For consistency with asan, msan, tsan and ubsan. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@314048 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-22[lsan] Deadly signal handler for lsanVitaly Buka
Summary: Part of https://github.com/google/sanitizers/issues/637 Reviewers: eugenis, alekseyshl Subscribers: llvm-commits, dberris, kubamracek, krytarowski Differential Revision: https://reviews.llvm.org/D37608 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@314041 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-11Implement standalone lsan interceptors for OS XFrancis Ricci
Summary: Mimicks the existing tsan and asan implementations of Darwin interception. Reviewers: kubamracek, kcc, glider Subscribers: llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D31889 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@299979 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27[sanitizer] [SystemZ] Abort if the kernel might be vulnerable to CVE-2016-2143.Marcin Koscielnicki
In short, CVE-2016-2143 will crash the machine if a process uses both >4TB virtual addresses and fork(). ASan, TSan, and MSan will, by necessity, map a sizable chunk of virtual address space, which is much larger than 4TB. Even worse, sanitizers will always use fork() for llvm-symbolizer when a bug is detected. Disable all three by aborting on process initialization if the running kernel version is not known to contain a fix. Unfortunately, there's no reliable way to detect the fix without crashing the kernel. So, we rely on whitelisting - I've included a list of upstream kernel versions that will work. In case someone uses a distribution kernel or applied the fix themselves, an override switch is also included. Differential Revision: http://reviews.llvm.org/D19576 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267747 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-14[LSan] Use __tls_get_addr interceptor to keep track of dynamic TLS.Alexey Samsonov
Summary: We have a way to keep track of allocated DTLS segments: let's use it in LSan. Although this code is fragile and relies on glibc implementation details, in some cases it proves to be better than existing way of tracking DTLS in LSan: marking as "reachable" all memory chunks allocated directly by "ld". The plan is to eventually get rid of the latter, once we are sure it's safe to remove. Reviewers: kcc Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D16164 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@257785 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-21[Sanitizers] Unify the semantics and usage of "exitcode" runtime flag across ↵Alexey Samsonov
all sanitizers. Summary: Merge "exitcode" flag from ASan, LSan, TSan and "exit_code" from MSan into one entity. Additionally, make sure sanitizer_common now uses the value of common_flags()->exitcode when dying on error, so that this flag will automatically work for other sanitizers (UBSan and DFSan) as well. User-visible changes: * "exit_code" MSan runtime flag is now deprecated. If explicitly specified, this flag will take precedence over "exitcode". The users are encouraged to migrate to the new version. * __asan_set_error_exit_code() and __msan_set_exit_code() functions are removed. With few exceptions, we don't support changing runtime flags during program execution - we can't make them thread-safe. The users should use __sanitizer_set_death_callback() that would call _exit() with proper exit code instead. * Plugin tools (LSan and UBSan) now inherit the exit code of the parent tool. In particular, this means that ASan would now crash the program with exit code "1" instead of "23" if it detects leaks. Reviewers: kcc, eugenis Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D12120 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@245734 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-21[sanitizer] Implement include_if_exists with process name substitution.Evgeniy Stepanov
include_if_exists=/path/to/sanitizer/options reads flags from the file if it is present. "%b" in the include file path (for both variants of the flag) is replaced with the basename of the main executable. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@242853 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-17[LSan] Make parent tool responsible for initializing LSan flags.Alexey Samsonov
Summary: LSan can be combined with a parent tool (for now it's only ASan). Also, we allow LSAN_OPTIONS to override certain common flags. It means we have to parse LSAN_OPTIONS early enough, before the rest of the parent tool (including chunks of sanitizer_common) is initialized. In future, we can use the same approach for UBSan, after we embed it into ASan runtime in a similar way. Test Plan: regression test suite Reviewers: earthdok, eugenis Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D7577 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@229519 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-26[asan] Allow enabling coverage at activation.Evgeniy Stepanov
This is a re-commit of r224838 + r224839, previously reverted in r224850. Test failures were likely (still can not reproduce) caused by two lit tests using the same name for an intermediate build target. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224853 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-26Revert r224838, r224839.Evgeniy Stepanov
Flaky failures on the build bots. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224850 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-25[asan] Allow enabling coverage at activation.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224838 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-17[sanitizer] allow -fsanitize-coverage=N w/ -fsanitize=leak, compiler-rt partKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224464 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-10[Sanitizer] Get rid of Symbolizer::Get() and Symbolizer::GetOrNull().Alexey Samsonov
We may as well just use Symbolizer::GetOrInit() in all the cases. Don't call Symbolizer::Get() early in tools initialization: these days it doesn't do any important setup work, and we may as well create the symbolizer the first time it's actually needed. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@217558 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-26[lsan] Implement __sanitizer_print_stack_trace() in standalone LSan.Sergey Matveev
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@216454 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-18[LSan] Parse common flags from LSAN_OPTIONS even if LSan is combined withAlexey Samsonov
another sanitizer. A user may run both LSan and LSan+ASan. It is weird to pass path to leak suppression file (or other common sanitizer flags, like "verbosity") in "LSAN_OPTIONS" in the first case and in "ASAN_OPTIONS" in the second case. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@215949 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-26[Sanitizer] Simplify Symbolizer creation interface.Alexey Samsonov
Get rid of Symbolizer::Init(path_to_external) in favor of thread-safe Symbolizer::GetOrInit(), and use the latter version everywhere. Implicitly depend on the value of external_symbolizer_path runtime flag instead of passing it around manually. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@214005 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-17[Sanitizer] Always initialize a Symbolizer (even if 'symbolize' is false).Alexey Samsonov
If 'symbolize' flag is not set, we still want to transform virtual address to module+offset pair in the call to Symbolizer::SymbolizeCode(). See https://code.google.com/p/address-sanitizer/issues/detail?id=251 for more details. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@197491 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-09[lsan] Make LSan ignore memory poisoned by ASan.Sergey Matveev
Summary: No more (potenital) false negatives due to red zones or fake stack frames. Reviewers: kcc, samsonov Reviewed By: samsonov CC: llvm-commits, samsonov Differential Revision: http://llvm-reviews.chandlerc.com/D2359 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@196778 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-27tsan: fix flags parsingDmitry Vyukov
- running_on_valgrind was not parsed in some contexts - refactor code a bit - add comprehensive tests for flags parsing git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@195831 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-25[lsan] Unbreak standalone LSan's initialization by making it more like ASan's.Sergey Matveev
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@195642 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-12[Sanitizer] Specify a default value for each common runtime flagAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@194479 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-25Overhaul the symbolizer interface.Peter Collingbourne
This moves away from creating the symbolizer object and initializing the external symbolizer as separate steps. Those steps now always take place together. Sanitizers with a legacy requirement to specify their own symbolizer path should use InitSymbolizer to initialize the symbolizer with the desired path, and GetSymbolizer to access the symbolizer. Sanitizers with no such requirement (e.g. UBSan) can use GetOrInitSymbolizer with no need for initialization. The symbolizer interface has been made thread-safe (as far as I can tell) by protecting its member functions with mutexes. Finally, the symbolizer interface no longer relies on weak externals, the introduction of which was probably a mistake on my part. Differential Revision: http://llvm-reviews.chandlerc.com/D1985 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@193448 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-10[Sanitizer] Refactor symbolization interface: use class instead of several ↵Alexey Samsonov
functions. Move some code around to get rid of extra source files git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@190410 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-03ASan, LSan, MSan: try to find llvm-symbolizer binary in PATH if it is not ↵Alexey Samsonov
provided. Now we don't need to explicitly set the location of llvm-symbolizer in lit test configs. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@189801 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-01[lsan] Add leak_check_at_exit flag.Sergey Matveev
We needed a way to tell LSan to invoke leak checking only if __do_leak_check() is called explicitly. This can now be achieved by setting leak_check_at_exit=false. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@187578 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-22[lsan] Make __lsan_do_leak_check() honor the detect_leaks flag.Sergey Matveev
Also move detect_leaks to common flags. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@186821 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-18[lsan] Set current_thread_tid correctly for main thread.Sergey Matveev
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@184189 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-23[lsan] Ensure lsan is initialized when interceptors are called.Sergey Matveev
Also remove unnecessary ifdefs. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@182571 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-21[lsan] Invoke leak detection with atexit().Sergey Matveev
Keeps it consistent between ASan and LSan. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@182399 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-20[lsan] Standalone LSan initialization.Sergey Matveev
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@182248 91177308-0d34-0410-b5e6-96231b3b80d8