summaryrefslogtreecommitdiff
path: root/lib/tsan/rtl/tsan_flags.cc
AgeCommit message (Collapse)Author
2017-03-26tsan: add new mutex annotationsDmitry Vyukov
There are several problems with the current annotations (AnnotateRWLockCreate and friends): - they don't fully support deadlock detection (we need a hook _before_ mutex lock) - they don't support insertion of random artificial delays to perturb execution (again we need a hook _before_ mutex lock) - they don't support setting extended mutex attributes like read/write reentrancy (only "linker init" was bolted on) - they don't support setting mutex attributes if a mutex don't have a "constructor" (e.g. static, Java, Go mutexes) - they don't ignore synchronization inside of lock/unlock operations which leads to slowdown and false negatives The new annotations solve of the above problems. See tsan_interface.h for the interface specification and comments. Reviewed in https://reviews.llvm.org/D31093 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298809 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-28tsan: always define SANITIZER_GODmitry Vyukov
Currently we either define SANITIZER_GO for Go or don't define it at all for C++. This works fine with preprocessor (ifdef/ifndef/defined), but does not work for C++ if statements (e.g. if (SANITIZER_GO) {...}). Also this is different from majority of SANITIZER_FOO macros which are always defined to either 0 or 1. Always define SANITIZER_GO to either 0 or 1. This allows to use SANITIZER_GO in expressions and in flag default values. Also remove kGoMode and kCppMode, which were meant to be used in expressions, but they are not defined in sanitizer_common code, so SANITIZER_GO become prevalent. Also convert some preprocessor checks to C++ if's or ternary expressions. Majority of this change is done mechanically with: sed "s#ifdef SANITIZER_GO#if SANITIZER_GO#g" sed "s#ifndef SANITIZER_GO#if \!SANITIZER_GO#g" sed "s#defined(SANITIZER_GO)#SANITIZER_GO#g" git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@285443 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-02tsan: clean up dynamic TLS memory between reuseDmitry Vyukov
Currently the added test produces false race reports with glibc 2.19, because DLTS memory is reused by pthread under the hood. Use the DTLS machinery to intercept new DTLS ranges. __tls_get_addr known to cause issues for tsan in the past, so write the interceptor more carefully. Reviewed in http://reviews.llvm.org/D20927 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@271568 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-18[sancov] common flags initialization.Mike Aizatsky
Summary: Introducing InitializeCommonFlags accross all sanitizers to simplify common flags management. Setting coverage=1 when html_cov_report is requested. Differential Revision: http://reviews.llvm.org/D18273 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@263820 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-30[tsan] Fix weakly imported functions on OS XKuba Brecka
On OS X, for weak function (that user can override by providing their own implementation in the main binary), we need extern `"C" SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE NOINLINE`. Fixes a broken test case on OS X, java_symbolization.cc, which uses a weak function __tsan_symbolize_external. Differential Revision: http://reviews.llvm.org/D14907 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@254298 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-16tsan: replace macro check with constant checkDmitry Vyukov
As per comments in 252892 commit. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@253216 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-12tsan: disable abort_on_error for GoDmitry Vyukov
It does not work as expected. Go runtime handles SIGABRT and crashes with a loud message. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@252892 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-04-28Allow UBSan+MSan and UBSan+TSan combinations (Clang part).Alexey Samsonov
Embed UBSan runtime into TSan and MSan runtimes in the same as we do in ASan. Extend UBSan test suite to also run tests for these combinations. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@235954 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-14tsan: fix parsing of second_deadlock_stack flagDmitry Vyukov
It was broken during flag parsing refactoring. Enable test for the flag. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234878 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13tsan: disable deadlock detector in Go modeDmitry Vyukov
Go does not use that. https://code.google.com/p/thread-sanitizer/issues/detail?id=89 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@229116 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-20[asan] Allow changing verbosity in activation flags.Evgeniy Stepanov
This change removes some debug output in asan_flags.cc that was reading the verbosity level before all the flags were parsed. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@226566 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19[sanitizer] Make unrecognized flags not fatal.Evgeniy Stepanov
Print a warning at verbosity=1 and higher instead of dying immediately. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@226458 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-15[sanitizer] Flag parser rewrite.Evgeniy Stepanov
The new parser is a lot stricter about syntax, reports unrecognized flags, and will make it easier to implemented some of the planned features. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@226169 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-07[Sanitizer] Change the runtime flag representation.Alexey Samsonov
This mirrors r225239 to all the rest sanitizers: ASan, DFSan, LSan, MSan, TSan, UBSan. Now the runtime flag type, name, default value and description is located in the single place in the .inc file. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@225327 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-02Revert "Revert r224736: "[Sanitizer] Make CommonFlags immutable after ↵Alexey Samsonov
initialization."" Fix test failures by introducing CommonFlags::CopyFrom() to make sure compiler doesn't insert memcpy() calls into runtime code. Original commit message: Protect CommonFlags singleton by adding const qualifier to common_flags() accessor. The only ways to modify the flags are SetCommonFlagsDefaults(), ParseCommonFlagsFromString() and OverrideCommonFlags() functions, which are only supposed to be called during initialization. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@225088 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-02Revert r224736: "[Sanitizer] Make CommonFlags immutable after initialization."Chandler Carruth
We've got some internal users that either aren't compatible with this or have found a bug with it. Either way, this is an isolated cleanup and so I'm reverting it to un-block folks while we investigate. Alexey and I will be working on fixing everything up so this can be re-committed soon. Sorry for the noise and any inconvenience. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@225079 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-22[Sanitizer] Make CommonFlags immutable after initialization.Alexey Samsonov
Summary: Protect CommonFlags singleton by adding const qualifier to common_flags() accessor. The only ways to modify the flags are SetCommonFlagsDefaults(), ParseCommonFlagsFromString() and OverrideCommonFlags() functions, which are only supposed to be called during initialization. Test Plan: regression test suite Reviewers: kcc, eugenis, glider Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D6741 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224736 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-19[Sanitizer] Refactor CommonFlags interface. NFC.Alexey Samsonov
Add CommonFlags::SetDefaults() and CommonFlags::ParseFromString(), so that this object can be easily tested. Enforce that ParseCommonFlagsFromString() and SetCommonFlagsDefaults() work only with singleton CommonFlags, shared across all sanitizer runtimes. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224617 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-06[Sanitizer] Introduce "stack_trace_format" runtime flag.Alexey Samsonov
This flag can be used to specify the format of stack frames - user can now provide a string with placeholders, which should be printed for each stack frame with placeholders replaced with actual data. For example "%p" will be replaced by PC, "%s" will be replaced by the source file name etc. "DEFAULT" value enforces default stack trace format currently used in all the sanitizers except TSan. This change also implements __sanitizer_print_stack_trace interface function in TSan. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@221469 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-10[TSan] Use common flags in the same way as all the other sanitizersAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@217559 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-05tsan: allocate vector clocks using slab allocatorDmitry Vyukov
Vector clocks is the most actively allocated object in tsan runtime. Current internal allocator is not scalable enough to handle allocation of clocks in scalable way (too small caches). This changes transforms clocks to 2-level array with 512-byte blocks. Since all blocks are of the same size, it's possible to cache them more efficiently in per-thread caches. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@214912 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-30[Sanitizer] Make "suppressions" and "print_suppressions" common runtime flags.Alexey Samsonov
No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@214343 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-15tsan: remove special handling of false reports coming from JVMDmitry Vyukov
There is now a more common functionality in the form of called_from_lib suppressions. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@213057 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-08[tsan] Enable tsan's deadlock detector by default.Kostya Serebryany
The tsan's deadlock detector has been used in Chromium for a while; it found a few real bugs and reported no false positives. So, it's time to give it a bit more exposure. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@212533 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-25tsan: better reports for "double lock of a mutex"Dmitry Vyukov
+ fixes crashes due to races on symbolizer, see: https://code.google.com/p/thread-sanitizer/issues/detail?id=55 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@207204 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-20[libsanitizer] Introduce flag descriptions.Alexander Potapenko
Extend ParseFlag to accept the |description| parameter, add dummy values for all existing flags. As the flags are parsed their descriptions are stored in a global linked list. The tool can later call __sanitizer::PrintFlagDescriptions() to dump all the flag names and their descriptions. Add the 'help' flag and make ASan, TSan and MSan print the flags if 'help' is set to 1. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@204339 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-20tsan: deobfuscate global ctx variableDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@204327 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-18tsan: deadlock detector: add deadlock detector flagsDmitry Vyukov
the first flags is to enable printing of the second stack per edge git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@204150 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-12[Sanitizer] Teach external symbolizer to work with addr2line if ↵Alexey Samsonov
llvm-symbolizer is unavailable. Allow this mode in TSan. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@201218 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-04tsan: add SANITIZER_INTERFACE_ATTRIBUTE to more callbacksDmitry Vyukov
so that it's possible to override them from a dynamic library. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@200747 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-24tsan: do not deadlock on forkDmitry Vyukov
Currently correct programs can deadlock after fork, because atomic operations and async-signal-safe calls are not async-signal-safe under tsan. With this change: - if a single-threaded program forks, the child continues running with verification enabled (the tsan background thread is recreated as well) - if a multi-threaded program forks, then the child runs with verification disabled (memory accesses, atomic operations and interceptors are disabled); it's expected that it will exec soon anyway - if the child tries to create more threads after multi-threaded fork, the program aborts with error message - die_after_fork flag is added that allows to continue running, but all bets are off http://llvm-reviews.chandlerc.com/D2614 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@199993 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-11[TSan] Replace __tsan::OverrideFlags with __tsan::OnInitializeAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@197014 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-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-17tsan: add a test for __tsan_default_options()Dmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@192873 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-15tsan: introduce __tsan_default_options() functionDmitry Vyukov
The function allows to statically setup default values for flags. The interafece matches what asan/msan provide. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@192715 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-15tsan: move verbosity flag to CommonFlagsDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@192701 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-15tsan: use sanitizer::CommonFlags in tsanDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@192692 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-04Refactor the usage of strip_path_prefix option and make it more consistent ↵Alexey Samsonov
across sanitizers git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@191943 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-03tsan: add memory_limit_mb flagDmitry Vyukov
The flag allows to bound maximum process memory consumption (best effort). If RSS reaches memory_limit_mb, tsan flushes all shadow memory. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@191913 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-27tsan: support allocator_may_return_null flagDmitry Vyukov
Fixes https://code.google.com/p/thread-sanitizer/issues/detail?id=29 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@191482 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-13tsan/msan: add halt_on_error flagDmitry Vyukov
If halt_on_error==true, program terminates after reporting first error. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@188279 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-28tsan: print statistics about benign race annotationsDmitry Vyukov
(total count, unique, matched) if requested with print_benign=1 flag. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@178245 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-27tsan: print matched suppressions if print_suppressions=1 flag is providedDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@178159 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-21tsan: add flag to control symbolizer flush frequencyDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177638 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-01tsan: add flag to not report races between atomic and plain memory accessesDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@174165 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-18tsan: add io_sync flag that controls amount of IO synchronizationDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@170427 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-30tsan: suppress weird race reports when JVM is embed into the processDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@169019 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-28tsan: address several review commentsDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@168789 91177308-0d34-0410-b5e6-96231b3b80d8