Evgeniy Stepanov
72a9d25060
[sanitizer] Simplify interceptors with user callbacks.
...
Get rid of the context argument in UNPOISON_PARAM and INITIALIZE_RANGE.
Get rid of all the thread-local contexts in interceptors.
llvm-svn: 203119
2014-03-06 13:26:09 +00:00
Dmitry Vyukov
2516974e83
tsan: weaken concurrency guarantees in deadlock detector mutex hashmap
...
read locking on every access is too expensive
llvm-svn: 203112
2014-03-06 12:04:26 +00:00
Alexey Samsonov
d52b9ba38d
[FreeBSD] Enable procmaps on FreeBSD.
...
This is not the final patch for procmaps, but it's enough for building
sanitizers and tests on FreeBSD.
Patch by Viktor Kutuzov!
llvm-svn: 203099
2014-03-06 08:58:24 +00:00
Alexey Samsonov
e062e4c7eb
Enable memrchr interceptor only on Linux
...
llvm-svn: 202981
2014-03-05 14:07:19 +00:00
Dmitry Vyukov
792d4b1559
tsan: add missing header file to sanitizer_common cmake file
...
llvm-svn: 202979
2014-03-05 13:55:32 +00:00
Dmitry Vyukov
e73e0a04d7
tsan: fix deadlock detector build for SANITIZER_DEADLOCK_DETECTOR_VERSION=2
...
llvm-svn: 202977
2014-03-05 13:53:29 +00:00
Dmitry Vyukov
9b410fb627
tsan: implement new version of standalong deadlock detector
...
intercept pthread_cond (it is required to properly track state of mutexes)
detect cycles in mutex graph
llvm-svn: 202975
2014-03-05 13:41:21 +00:00
Dmitry Vyukov
cd3583a4c7
tsan: include what you use
...
VPrintf uses common_flags()
llvm-svn: 202974
2014-03-05 13:40:05 +00:00
Alexey Samsonov
6dece3c99f
Add common interceptors for memchr/memrchr
...
llvm-svn: 202972
2014-03-05 13:25:32 +00:00
Alexey Samsonov
c8c38dbb18
Increase threshold in StackTrace::LocatePcInTrace
...
llvm-svn: 202950
2014-03-05 08:29:56 +00:00
Dmitry Vyukov
30076b0244
tsan: add another missing windows atomic operation
...
llvm-svn: 202852
2014-03-04 14:21:42 +00:00
Dmitry Vyukov
0a650fe711
tsan: attempt to fix darwin build
...
everything except linux does not need this hackery with pthread_cond
llvm-svn: 202850
2014-03-04 14:16:28 +00:00
Alexey Samsonov
359c105c92
Fix StackTrace::LocatePcInTrace, add more unit tests for generic StackTrace
...
llvm-svn: 202849
2014-03-04 14:06:11 +00:00
Alexey Samsonov
d964e7cd81
[CMake] Test for libdl and libpthread presence
...
llvm-svn: 202847
2014-03-04 13:28:21 +00:00
Dmitry Vyukov
d1d8653742
tsan: add dynamic library target for standalone deadlock detector
...
it's LD_PRELOAD-able
llvm-svn: 202843
2014-03-04 12:52:20 +00:00
Alexey Samsonov
3e8467b8b9
Avoid doing any work when unwinding stack traces with 0 or 1 frame
...
llvm-svn: 202837
2014-03-04 12:21:28 +00:00
Dmitry Vyukov
9e3a217adb
tsan: fix windows build
...
llvm-svn: 202831
2014-03-04 11:57:25 +00:00
Dmitry Vyukov
54a0303fa8
tsan: add concurrent hashmap for standalone deadlock detector
...
llvm-svn: 202826
2014-03-04 11:39:56 +00:00
Dmitry Vyukov
e69df1f928
tsan: fix pthread_cond interceptors
...
currently tsan hangs when linked with a shared library linked against an old version of pthread
this change is another attempt to fix pthread_cond interceptors in different scenarios
see the comment for implementation details
llvm-svn: 202820
2014-03-04 11:11:40 +00:00
Dmitry Vyukov
975b02ad71
tsan: move all pthread_cond interceptors into sanitizer_common
...
llvm-svn: 202813
2014-03-04 10:17:40 +00:00
Alexey Samsonov
a7c602ac29
A set of trivial changes to support sanitizers on FreeBSD.
...
Patch by Viktor Kutuzov!
llvm-svn: 202801
2014-03-04 08:55:41 +00:00
Dmitry Vyukov
9cffc9550b
tsan: allow to force use of __libc_malloc in sanitizer_common
...
llvm-svn: 202504
2014-02-28 14:46:53 +00:00
Dmitry Vyukov
7210cdd473
tsan: add include guards
...
llvm-svn: 202503
2014-02-28 14:46:05 +00:00
Kostya Serebryany
eae464f911
[sanitizer] speedup deadlock detector for the case when we acquire the first lock in a thread
...
llvm-svn: 202492
2014-02-28 11:56:14 +00:00
Kostya Serebryany
afc4f2af76
[sanitizer] speedup deadlock detector for the case when we destroy a mutex that has never been locked
...
llvm-svn: 202487
2014-02-28 10:59:33 +00:00
Dmitry Vyukov
6cfab724ec
tsan: refactor deadlock detector
...
Introduce DDetector interface between the tool and the DD itself.
It will help to experiment with other DD implementation,
as well as reuse DD in other tools.
llvm-svn: 202485
2014-02-28 10:48:13 +00:00
Dmitry Vyukov
6403c34c2a
tsan: add new line at the end of error message
...
llvm-svn: 202470
2014-02-28 06:29:42 +00:00
Alexander Potapenko
e8c311a40c
[ASan] Make sure IOC_DIRMASK is undefined before redefining it.
...
llvm-svn: 202410
2014-02-27 16:46:06 +00:00
Dmitry Vyukov
d8c2fbd57f
tsan: another attempt to fix the tls_get_addr crash
...
llvm-svn: 202405
2014-02-27 15:07:45 +00:00
Dmitry Vyukov
46ebecc1fe
tsan: work around known bug in libstdc++
...
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58066
llvm-svn: 202403
2014-02-27 14:43:31 +00:00
Kostya Serebryany
2ff42d98fa
[sanitizer] do not acquire a global mutex in deadlock detector when dealing with Unlock (it is essentially a thread-local operation)
...
llvm-svn: 202401
2014-02-27 14:38:42 +00:00
Evgeniy Stepanov
037c271f41
[sanitizer] Fix iOS build.
...
llvm-svn: 202374
2014-02-27 10:09:21 +00:00
Evgeniy Stepanov
a16f327c27
[sanitizer] Sizes and layouts for sanitizers on FreeBSD.
...
Patch by Viktor Kutuzov.
llvm-svn: 202364
2014-02-27 09:02:08 +00:00
Evgeniy Stepanov
6edfad4811
[asan] Don't disable SEGV handler on Android by default.
...
This is done mostly for consistency, because this setting is normally overridden in cmake.
llvm-svn: 202359
2014-02-27 08:23:00 +00:00
Joerg Sonnenberger
9d09e2fe90
Reapply r201910. MSVC gets __func__ defined explicitly, even though it
...
can't build anything here.
llvm-svn: 202297
2014-02-26 20:33:22 +00:00
Alexey Samsonov
14e061d7cc
Support 'q' length modifier in scanf/printf interceptors
...
llvm-svn: 202268
2014-02-26 14:42:38 +00:00
Evgeniy Stepanov
f4dcf77623
[asan] Fix printing of long reports to logcat on Android.
...
__android_log_write has an implicit message length limit.
Print one line at a time.
llvm-svn: 202250
2014-02-26 09:39:55 +00:00
Evgeniy Stepanov
e23add20ae
[sanitizer] Add a flag to enable/disable report colorization.
...
llvm-svn: 202249
2014-02-26 09:06:59 +00:00
Richard Trieu
a170f08109
Remove 'tctx->name' from a logical statement since it is a pointer and always
...
is converted to a true value. Detected by Clang's improved -Wbool-conversion
llvm-svn: 202223
2014-02-26 03:12:51 +00:00
Alexey Samsonov
98aa08c0e9
Update sanitizers' bash scripts.
...
* Fix bash scripts to work on FreeBSD (patch by Viktor Kutuzov)
* Update locations of lit tests in check_lint script.
llvm-svn: 202145
2014-02-25 12:09:25 +00:00
Kostya Serebryany
11f4f30fa7
[sanitizer] add support for try_lock in deadlock detector
...
llvm-svn: 202120
2014-02-25 08:24:15 +00:00
Kostya Serebryany
6d54611fd4
[sanitizer] fix epoch handling in deadlock detector (before the fix, we could have had edges from locks in the previous epoch to locks in the current epoch)
...
llvm-svn: 202118
2014-02-25 07:34:41 +00:00
Kostya Serebryany
cf5d8e4f29
AdjustStackSizeLinux() is used in Lsan, Tsan and Msan non-Linux-specific code so it seems it should have more generic name and moved to a common scope.
...
Renamed to AdjustStackSize.
Patch by Viktor Kutuzov.
llvm-svn: 202011
2014-02-24 08:53:26 +00:00
Kostya Serebryany
04f2bf0f07
[sanitizer] Interception macros for sanitizers on FreeBSD; patch by Viktor Kutuzov
...
llvm-svn: 202009
2014-02-24 08:37:41 +00:00
Reid Kleckner
324eee45a7
Revert "Replace __FUNCTION__ with __func__, the latter being standard C99/C++11."
...
This reverts commit r201910.
While __func__ may be standard in C++11, it was only recently added to
MSVC in 2013 CTP, and LLVM supports MSVC 2012. __FUNCTION__ may not be
standard, but it's *very* portable.
llvm-svn: 201916
2014-02-22 00:37:45 +00:00
Joerg Sonnenberger
b15779f307
Replace __FUNCTION__ with __func__, the latter being standard C99/C++11.
...
llvm-svn: 201910
2014-02-21 23:55:15 +00:00
Alexey Samsonov
35a66d15d4
Move config for sanitizer_common tests under test/ for consistency
...
llvm-svn: 201779
2014-02-20 12:18:08 +00:00
Alexey Samsonov
11705b2f10
[CMake] break dependency between unit tests and runtimes in standalone build
...
llvm-svn: 201778
2014-02-20 12:03:56 +00:00
Evgeniy Stepanov
cba008e9c5
[asan] A different way of detectinb stack overflow.
...
Instead of checking stack limits that are not well defined for the main thread,
we rely on siginfo::si_code and distance from SP.
llvm-svn: 201673
2014-02-19 13:40:41 +00:00
Alexey Samsonov
cd8535a96d
[CMake] Introduce COMPILER_RT_INCLUDE_TESTS option
...
llvm-svn: 201666
2014-02-19 11:18:47 +00:00
Kostya Serebryany
37ce26cb16
[sanitizer] when reporting a deadlock also report the lock cycle
...
llvm-svn: 201576
2014-02-18 14:56:19 +00:00
Kostya Serebryany
bd86a29a2a
[sanitizer] make sure the deadlock detector survives the change of epochs; add a test and a comment
...
llvm-svn: 201572
2014-02-18 13:41:49 +00:00
Evgeniy Stepanov
50bef914a6
[asan] Override default sigaltstack setting on Android.
...
Android libc always sets altstack on non-main threads, but it is too small for
our unwinder. With use_sigaltstack=1, override this setting with a larger one.
llvm-svn: 201557
2014-02-18 11:14:30 +00:00
Alexey Samsonov
63a4af7346
[CMake] Add top-level target for each compiler-rt library, and add 'compiler-rt' target encompassing them all.
...
llvm-svn: 201556
2014-02-18 09:33:45 +00:00
Alexey Samsonov
b73db72a17
[CMake] Simplify setting compile flag disabling RTTI
...
llvm-svn: 201547
2014-02-18 07:52:40 +00:00
Evgeniy Stepanov
2eea2850a4
[asan] Make __cxa_demangle non-weak symbol on Android.
...
This fixes global-demangle.cc test on Android.
https://code.google.com/p/address-sanitizer/issues/detail?id=264
llvm-svn: 201545
2014-02-18 07:34:52 +00:00
Alexey Samsonov
9a1ffce25a
[CMake] Simplify code for detecting/setting compiler flags
...
llvm-svn: 201543
2014-02-18 07:26:58 +00:00
Kostya Serebryany
6774f2241d
[sanitizer] add tests for DeadlockDetector, minor fix in onLock
...
llvm-svn: 201514
2014-02-17 14:57:49 +00:00
Kostya Serebryany
73325589dc
[sanitizer] implement node removal in Deadlock graph
...
llvm-svn: 201509
2014-02-17 11:21:52 +00:00
Kostya Serebryany
ec68429c5d
[sanitizer] simplify DeadlockDetectorTLS
...
llvm-svn: 201505
2014-02-17 08:47:48 +00:00
Kostya Serebryany
46177baddb
[sanitizer] add one more test for deadlock detection stuff
...
llvm-svn: 201503
2014-02-17 07:39:44 +00:00
Evgeniy Stepanov
a21280307f
[sanitizer] Fix getpwuid_r (and similar) interceptors missing one of the arguments.
...
llvm-svn: 201410
2014-02-14 12:32:15 +00:00
Kostya Serebryany
e233d8618d
[sanitizer] add iterators to bit vectors; make bit vector operations use little stack; add common flag 'detect_deadlocks'
...
llvm-svn: 201405
2014-02-14 12:08:23 +00:00
Evgeniy Stepanov
05938a23f5
[sanitizer] Use mmap to zero-fill large shadow regions.
...
This is covered by existing ASan test.
This does not change anything for TSan by default (but provides a flag to
change the threshold size).
Based on a patch by florent.bruneau here:
https://code.google.com/p/address-sanitizer/issues/detail?id=256
llvm-svn: 201400
2014-02-14 11:41:26 +00:00
Alexey Samsonov
81a2b466e9
Move shared configs for lit test suites to test/ and unittests/ directories
...
llvm-svn: 201399
2014-02-14 11:00:07 +00:00
Alexander Potapenko
0b28ea9c47
[libsanitizer] Create SanitizerCommonDecorator which provides the Warning() and EndWarning() methods
...
(needed for SEGV handling in sanitizer_common)
llvm-svn: 201392
2014-02-14 08:59:42 +00:00
Kostya Serebryany
efe2f7e2c8
[sanitizer] replace MostSignificantSetBitIndex with LeastSignificantSetBitIndex in bit vector (to iterate bits in increasing order)
...
llvm-svn: 201339
2014-02-13 15:59:00 +00:00
Kostya Serebryany
67d419736a
[sanitizer] optimize TwoLevelBitVector::intersectsWith, extend tests, fix a check
...
llvm-svn: 201338
2014-02-13 15:45:20 +00:00
Evgeniy Stepanov
8978389a32
[asan] Enable SEGV handler on Android by default.
...
Seems stable enough.
Fixes null_deref.cc test.
llvm-svn: 201326
2014-02-13 13:43:47 +00:00
Evgeniy Stepanov
3bec7a9c77
[sanitizer] Fix off-by-one-line in SEGV reports on Android.
...
This will be covered by null_deref.cc test (requires one more fix to pass).
llvm-svn: 201325
2014-02-13 13:32:24 +00:00
Kostya Serebryany
07526fb4a0
[sanitizer] address some of the dvyukov's comments on previous commits
...
llvm-svn: 201322
2014-02-13 12:39:21 +00:00
Kostya Serebryany
f6cb35abb4
[sanitizer] findPath for deadlock detector
...
llvm-svn: 201306
2014-02-13 09:52:15 +00:00
Evgeniy Stepanov
14ca0627d5
[asan] Avoid deadlock in CovDump.
...
llvm-svn: 201304
2014-02-13 08:50:36 +00:00
Kostya Serebryany
c98ce28533
[sanitizer] AArch64 sanitizer support; patch by Christophe Lyon and Yvan Roux
...
llvm-svn: 201303
2014-02-13 07:50:20 +00:00
Kostya Serebryany
5e52d48e3a
[sanitizer] more code for deadlock detector, nothing really works yet (except for small unit tests).
...
llvm-svn: 201302
2014-02-13 07:44:51 +00:00
Sergey Matveev
2a01b2f86f
[sanitizer] Intercept capget()/capset().
...
Also, fix incorrect syscall hooks for the corresponding syscalls.
llvm-svn: 201252
2014-02-12 19:29:49 +00:00
Evgeniy Stepanov
8ab205fb74
[asan] Handle OpenFile errors in CovDump.
...
llvm-svn: 201240
2014-02-12 15:29:22 +00:00
Evgeniy Stepanov
254c7636cf
[sanitizer] Fix wait4 interceptor on Android.
...
It's called __wait4 there.
llvm-svn: 201235
2014-02-12 13:05:17 +00:00
Kostya Serebryany
be1d22b631
[sanitizer] added class BVGraph, to be used in a deadlock detector; added more methods to the bit vectors
...
llvm-svn: 201226
2014-02-12 11:28:09 +00:00
Alexey Samsonov
7304b4201f
[Sanitizer] Teach external symbolizer to work with addr2line if llvm-symbolizer is unavailable. Allow this mode in TSan.
...
llvm-svn: 201218
2014-02-12 08:29:42 +00:00
Alexey Samsonov
167c15a98f
[Sanitizer] Build sanitizer_common with -Wframe-larger-than=512 flag
...
llvm-svn: 201213
2014-02-12 07:26:40 +00:00
Alexey Samsonov
7e97768f2f
[Sanitizer] Reduce stack frame size of SlowUnwindStackWithContext
...
llvm-svn: 201212
2014-02-12 07:24:11 +00:00
Kostya Serebryany
083d657845
[sanitizer] added a bit vector class to be used in a deadlock detector
...
llvm-svn: 201210
2014-02-12 07:05:24 +00:00
Evgeniy Stepanov
e5a447d947
[asan] Fix Windows build.
...
llvm-svn: 201154
2014-02-11 13:57:17 +00:00
Evgeniy Stepanov
2629e575db
[sanitizer] Fix build.
...
llvm-svn: 201152
2014-02-11 13:45:01 +00:00
Evgeniy Stepanov
769d46f373
[sanitizer] Use system unwinder in signal handlers on Android.
...
Because of the way Bionic sets up signal stack frames, libc unwinder is unable
to step through it, resulting in broken SEGV stack traces.
Luckily, libcorkscrew.so on Android implements an unwinder that can start with
a signal context, thus sidestepping the issue.
llvm-svn: 201151
2014-02-11 13:38:57 +00:00
Alexey Samsonov
ca183eed55
[Sanitizer] External symbolizer refactoring: split protocol for communicating with
...
llvm-symbolizer binary and external process handling into separate classes.
No functionality change.
llvm-svn: 201150
2014-02-11 13:03:09 +00:00
Evgeniy Stepanov
791a7e1603
[msan] Return EINVAL instead of crashing from mmap of an invalid address.
...
llvm-svn: 201074
2014-02-10 09:37:03 +00:00
Alexey Samsonov
adcf48fa35
[Sanitizer] Don't #include the same system header twice.
...
llvm-svn: 201071
2014-02-10 08:57:28 +00:00
Evgeniy Stepanov
d1e68a5ce1
[sanitizer] Disable 3 more syscall hooks on Android.
...
llvm-svn: 201070
2014-02-10 08:35:58 +00:00
Evgeniy Stepanov
c75ef739a1
[sanitizer] struct ustat and a bunch of other definitions are missing on Android.
...
llvm-svn: 201068
2014-02-10 08:00:24 +00:00
Nick Lewycky
af2064f7ab
Add throw() specifiers to more redeclarations of operator delete and operator delete[].
...
llvm-svn: 201016
2014-02-08 01:42:08 +00:00
Sergey Matveev
4a03fa4f60
[sanitizer] Intercept if_indextoname() and if_nametoindex().
...
llvm-svn: 200945
2014-02-06 20:39:33 +00:00
Sergey Matveev
f3a8acf38a
[sanitizer] Fix build.
...
llvm-svn: 200942
2014-02-06 19:36:10 +00:00
Sergey Matveev
544d07f861
[sanitizer] One does not simply intercept getifaddrs().
...
Upgrade the interceptor, and attempt to fix the Android build.
llvm-svn: 200936
2014-02-06 18:48:23 +00:00
Sergey Matveev
07802a090a
[sanitizer] Intercept getifaddrs().
...
llvm-svn: 200926
2014-02-06 17:42:36 +00:00
Sergey Matveev
0c62992d6e
[sanitizer] Intercept getresuid and getresgid.
...
llvm-svn: 200925
2014-02-06 15:12:56 +00:00
Dmitry Vyukov
a5d1fcfde1
tsan: improve error message for Go
...
llvm-svn: 200914
2014-02-06 09:22:29 +00:00
Sergey Matveev
efefe5e225
[sanitizer] Fix build.
...
llvm-svn: 200873
2014-02-05 20:04:12 +00:00
Sergey Matveev
c5c84a1d86
[sanitizer] Implement ioctl decoding.
...
When an unknown ioctl is encountered, try to guess the parameter size from the
request id.
llvm-svn: 200872
2014-02-05 19:35:24 +00:00
Kostya Serebryany
9ebd483017
[sanitizer] hide two functions in the __sanitizer namespace to avoid exporting them (gold complained)
...
llvm-svn: 200844
2014-02-05 15:06:32 +00:00
Timur Iskhodzhanov
aeefb6abce
[ASan/Win] Fall back to stdout if we can't print the reports to stderr
...
llvm-svn: 200804
2014-02-04 23:28:30 +00:00
Dmitry Vyukov
a538aac8ce
tsan: fix windows build
...
llvm-svn: 200778
2014-02-04 17:27:29 +00:00
Alexander Potapenko
2e7dc60ee3
[ASan] Replace the call to "vname" with "WRAP(vname)" in FORMAT_INTERCEPTOR_IMPL
...
It's incorrect to call the function by its name in the interceptor, because that means WRAP(vname) on Linux and REAL(vname) on OSX.
This patch fixes asan/lit_tests/TestCases/printf-3.c on Mac.
llvm-svn: 200749
2014-02-04 09:35:09 +00:00
Kostya Serebryany
f6e085cf89
[sanitizer] make __tls_get_addr interceptor (more) AS-safe. No good test so far, will keep trying.
...
llvm-svn: 200734
2014-02-04 05:22:00 +00:00
Kostya Serebryany
51f135d820
[sanitizer] Handle TLS sizes for glibc < 2.13; As discussed in http://gcc.gnu.org/PR60038 , the hardcoded sizeof(struct thread); patch by Jakub Jelinek
...
llvm-svn: 200733
2014-02-04 04:09:38 +00:00
Alexander Potapenko
f6ff6b0929
[libsanitizer] Workaround for https://code.google.com/p/address-sanitizer/issues/detail?id=261
...
If pthread_get_stacksize_np() returns 512K for the main thread on Mavericks, obtain the stack size from the current stack rlimit.
llvm-svn: 200703
2014-02-03 16:42:29 +00:00
Alexander Potapenko
8d58767b34
[libsanitizer] Follow-up for r200700: add the new header to CMakeLists.txt and make it empty on non-Mac.
...
llvm-svn: 200701
2014-02-03 15:45:03 +00:00
Alexander Potapenko
768e315a74
[ASan] Move GetMacosVersion() to sanitizer_common.
...
llvm-svn: 200700
2014-02-03 15:32:19 +00:00
Sergey Matveev
c18b36625e
[sanitizer] Partial revert of recent ioctl changes.
...
Some build environments are missing the required headers.
This reverts r200544, r200547, r200551. This does not revert the change that
introduced READWRITE ioctl type.
llvm-svn: 200567
2014-01-31 19:19:45 +00:00
Alexander Potapenko
ea4a0dbb8d
[ASan] Implement __sanitizer::InstallDeadlySignalHandlers() and __asan::AsanOnSIGSEGV() on Windows.
...
llvm-svn: 200554
2014-01-31 15:11:11 +00:00
Evgeniy Stepanov
a78dbe2e6f
[asan] Fix Android build.
...
llvm-svn: 200551
2014-01-31 14:46:37 +00:00
Evgeniy Stepanov
01cd8ae204
[asan] Read extra flags from a system property on activation on Android.
...
llvm-svn: 200550
2014-01-31 14:36:55 +00:00
Alexander Potapenko
36b18dfe64
[libsanitizer] Fix compilation for gotsan.
...
llvm-svn: 200549
2014-01-31 14:30:12 +00:00
Sergey Matveev
dffda4cfec
[sanitizer] Attempt to fix Android build.
...
llvm-svn: 200547
2014-01-31 14:28:32 +00:00
Sergey Matveev
6b3397546e
[sanitizer] Support most ioctls from /usr/include/sound/.
...
llvm-svn: 200544
2014-01-31 14:02:21 +00:00
Alexander Potapenko
789e3e1b7c
[ASan] Move the SIGSEGV/SIGBUS handling to sanitizer_common
...
This change is a part of refactoring intended to have common signal handling behavior in all tools.
This particular CL moves InstallSignalHandlers() into sanitizer_common (making it InstallDeadlySignalHandlers()), but doesn't enable default signal handlers for any tool other than ASan.
llvm-svn: 200542
2014-01-31 13:10:07 +00:00
Alexander Potapenko
e925e53114
Fix compilation: don't convert NULL to a pointer-incompatible type.
...
llvm-svn: 200536
2014-01-31 11:44:15 +00:00
Alexander Potapenko
d5802fe548
Make signal-related functions use __sanitizer_* structures instead of __sanitizer_kernel_* ones.
...
Also rename internal_sigaction() into internal_sigaction_norestorer(), as this function doesn't fully
implement the sigaction() functionality on Linux.
This change is a part of refactoring intended to have common signal handling behavior in all tools.
llvm-svn: 200535
2014-01-31 11:29:51 +00:00
Dmitry Vyukov
e63a09adb6
tsan: fix Go build
...
Go linker does not like function-static objects.
llvm-svn: 200534
2014-01-31 11:20:55 +00:00
Timur Iskhodzhanov
00aa75b774
Move /FS to SANITIZER_COMMON_CFLAGS
...
llvm-svn: 200485
2014-01-30 19:48:13 +00:00
Timur Iskhodzhanov
272502656e
Add an /FS flag to the sanitizer_common CMake to make it buildable with VS2013
...
llvm-svn: 200480
2014-01-30 18:56:06 +00:00
Evgeniy Stepanov
3f6af151df
[sanitizer] Fix typo that breaks shmctl() interceptor.
...
https://code.google.com/p/address-sanitizer/issues/detail?id=259
llvm-svn: 200468
2014-01-30 14:31:26 +00:00
Sergey Matveev
be68311660
[msan] Intercept *getxattr and *listxattr.
...
llvm-svn: 200464
2014-01-30 12:21:12 +00:00
Kostya Serebryany
b22298af9a
[asan] re-enable __tls_get_addr interceptor with a proper fix (use __attribute__((tls_model(initial-exec))))
...
llvm-svn: 200463
2014-01-30 09:25:48 +00:00
Kostya Serebryany
409d26ac5e
[asan] disable __tls_get_addr interceptor while I am investigating why it causes trouble; few more debugging
...
llvm-svn: 200462
2014-01-30 09:00:42 +00:00
Kostya Serebryany
cda06acd31
[asan] fix build on Mac (hopefully)
...
llvm-svn: 200386
2014-01-29 10:26:38 +00:00
Kostya Serebryany
71788fac2a
[asan] experimental intercetor for __tls_get_addr. So far it does nothing interesting, actual usage will come later. See https://groups.google.com/forum/#!topic/address-sanitizer/BfwYD8HMxTM for background
...
llvm-svn: 200384
2014-01-29 09:29:16 +00:00
Alexander Potapenko
b0930f5c04
[ASan] Reinstate ASAN_LOW_MEMORY, which has nothing to do with signal handling and thus should not be moved to common.
...
llvm-svn: 200319
2014-01-28 14:17:16 +00:00
Alexander Potapenko
31e24962f4
[ASan] Remove an accidentally added include of signal.h
...
llvm-svn: 200318
2014-01-28 14:10:06 +00:00
Alexander Potapenko
d8d490ed50
[ASan] Move the sigaltstack() bits to sanitizer_common.
...
This change is a part of refactoring intended to have common signal handling behavior in all tools.
Note that this particular change doesn't enable use_sigaltstack support in every tool.
llvm-svn: 200310
2014-01-28 11:12:29 +00:00
Alexander Potapenko
cf4bef3161
[ASan] Move the signal handling-related flags to sanitizer_common.
...
This change is a part of refactoring intended to have common signal handling behavior in all tools.
llvm-svn: 200295
2014-01-28 09:28:57 +00:00
Kostya Serebryany
7fe86589f1
[sanitizer] revert r200197: the buggy kernel ( https://bugzilla.kernel.org/show_bug.cgi?id=67651 ) is almost unusable with asan even with this workaround (too slow), so this workaround makes no sense. The asan/msan bootstrap bot was changed to use a non-buggy kernel
...
llvm-svn: 200217
2014-01-27 13:05:09 +00:00
Evgeniy Stepanov
067f54718f
[msan] Disable mmap outside of application address range.
...
llvm-svn: 200200
2014-01-27 09:12:22 +00:00
Kostya Serebryany
0a5049b780
[sanitizer] increase the mmap granularity in sanitizer allocator from 2^16 to 2^18. This is a partial workaround for the fresh Kernel bug https://bugzilla.kernel.org/show_bug.cgi?id=67651
...
llvm-svn: 200197
2014-01-27 07:35:32 +00:00
Dmitry Vyukov
16e7a758b0
tsan: do not deadlock on fork
...
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
llvm-svn: 199993
2014-01-24 12:33:35 +00:00
Alexey Samsonov
1d028b8a9f
[Sanitizer] Fix false positive in snprintf interceptor - take the number of actually written symbols from real snprintf call.
...
llvm-svn: 199899
2014-01-23 15:09:38 +00:00
Alexey Samsonov
902bb51612
[Sanitizer] Fix false positive in printf interceptors: properly handle precision for %s
...
llvm-svn: 199895
2014-01-23 14:35:28 +00:00
Evgeniy Stepanov
350fe4b1af
[asan] Android logging.
...
This change duplicates all ASan output to system log on Android.
llvm-svn: 199887
2014-01-23 11:34:41 +00:00
Evgeniy Stepanov
6975704f62
[sanitizer] Replace inline with INLINE.
...
llvm-svn: 199883
2014-01-23 11:22:04 +00:00
Evgeniy Stepanov
04c5a836a2
[sanitizer] Add a sanity check.
...
llvm-svn: 199880
2014-01-23 11:01:07 +00:00
Evgeniy Stepanov
43d1888285
[sanitizer] Fix format string mismatches found by format attributes added in r199874.
...
llvm-svn: 199879
2014-01-23 10:57:08 +00:00
Evgeniy Stepanov
29b7866c6c
[sanitizer] Add printf format attributes.
...
These were lost in a refactoring a long time ago.
llvm-svn: 199874
2014-01-23 08:58:34 +00:00
Dmitry Vyukov
db1ad12ae2
asan: fix atomic operations on ARM
...
implement correct atomic load/store for ARM
add test for atomic load/store
http://llvm-reviews.chandlerc.com/D2582
llvm-svn: 199802
2014-01-22 14:13:37 +00:00
Alexey Samsonov
8c03475f01
[Sanitizer] try harder to fix Werror build break after r199729
...
llvm-svn: 199736
2014-01-21 13:06:38 +00:00
Alexey Samsonov
39dbd7cc2c
[Sanitizer] Update file names now that we intercept both scanf and printf
...
llvm-svn: 199735
2014-01-21 13:01:20 +00:00
Alexey Samsonov
20494ca293
Fix unused function warning from r199729
...
llvm-svn: 199730
2014-01-21 12:16:19 +00:00
Alexey Samsonov
00cd273c46
Sanitize printf functions.
...
Intercept and sanitize arguments passed to printf functions in ASan and TSan
(don't do this in MSan for now). The checks are controlled by runtime flag
(off by default for now).
Patch http://llvm-reviews.chandlerc.com/D2480 by Yuri Gribov!
llvm-svn: 199729
2014-01-21 11:58:33 +00:00
Evgeniy Stepanov
e676aadecf
[asan] Enable frame pointer based unwinder on ARM.
...
This code works with AAPCS-style {fp, lr} frames. Unlike linux perf, it does
not unwind through code compiled with -mapcs-frame (which Clang does not
support anyway).
llvm-svn: 199725
2014-01-21 11:04:58 +00:00
Alexey Samsonov
0714b7b31b
[Sanitizer] Support %.*s in internal printf implementation. Patch by Yuri Gribov.
...
llvm-svn: 199724
2014-01-21 10:59:44 +00:00
Kostya Serebryany
714c67c31e
[asan] extend asan-coverage (still experimental).
...
- add a mode for collecting per-block coverage (-asan-coverage=2).
So far the implementation is naive (all blocks are instrumented),
the performance overhead on top of asan could be as high as 30%.
- Make sure the one-time calls to __sanitizer_cov are moved to function buttom,
which in turn required to copy the original debug info into the call insn.
Here is the performance data on SPEC 2006
(train data, comparing asan with asan-coverage={0,1,2}):
asan+cov0 asan+cov1 diff 0-1 asan+cov2 diff 0-2 diff 1-2
400.perlbench, 65.60, 65.80, 1.00, 76.20, 1.16, 1.16
401.bzip2, 65.10, 65.50, 1.01, 75.90, 1.17, 1.16
403.gcc, 1.64, 1.69, 1.03, 2.04, 1.24, 1.21
429.mcf, 21.90, 22.60, 1.03, 23.20, 1.06, 1.03
445.gobmk, 166.00, 169.00, 1.02, 205.00, 1.23, 1.21
456.hmmer, 88.30, 87.90, 1.00, 91.00, 1.03, 1.04
458.sjeng, 210.00, 222.00, 1.06, 258.00, 1.23, 1.16
462.libquantum, 1.73, 1.75, 1.01, 2.11, 1.22, 1.21
464.h264ref, 147.00, 152.00, 1.03, 160.00, 1.09, 1.05
471.omnetpp, 115.00, 116.00, 1.01, 140.00, 1.22, 1.21
473.astar, 133.00, 131.00, 0.98, 142.00, 1.07, 1.08
483.xalancbmk, 118.00, 120.00, 1.02, 154.00, 1.31, 1.28
433.milc, 19.80, 20.00, 1.01, 20.10, 1.02, 1.01
444.namd, 16.20, 16.20, 1.00, 17.60, 1.09, 1.09
447.dealII, 41.80, 42.20, 1.01, 43.50, 1.04, 1.03
450.soplex, 7.51, 7.82, 1.04, 8.25, 1.10, 1.05
453.povray, 14.00, 14.40, 1.03, 15.80, 1.13, 1.10
470.lbm, 33.30, 34.10, 1.02, 34.10, 1.02, 1.00
482.sphinx3, 12.40, 12.30, 0.99, 13.00, 1.05, 1.06
llvm-svn: 199488
2014-01-17 11:00:30 +00:00
Alexey Samsonov
a64851bccb
[Sanitizer] Remove empty method
...
llvm-svn: 199481
2014-01-17 08:39:05 +00:00
Alexey Samsonov
4d075df406
[Sanitizer] Add basic support for using libbacktrace in symbolizer.
...
This change allows to compile sanitizer sources so that *san runtime
will attempt to use libbacktrace and/or libiberty for symbolization
(instead of communicating with llvm-symbolizer).
I've tested this patch by manually defining SANITIZER_LIBBACKTRACE and/or
SANITIZER_CP_DEMANGLE, linking with necessary libraries and verifying that
all tests from ASan test suite work.
Based on patches by Jakub Jelinek!
llvm-svn: 199384
2014-01-16 13:48:15 +00:00
Kostya Serebryany
47d5569de1
[asan] Include <sys/stat.h> if __x86_64__ is defined
...
struct stat defined in <asm/stat.h> is incorrect for x32. <asm/stat.h>
is included to get struct __old_kernel_stat. But struct __old_kernel_stat
isn't used for x86-64 nor x32. This patch includes <sys/stat.h> instead
of <asm/stat.h> and comments out size check of struct __old_kernel_stat
for x86-64.
Patch by H.J. Lu
llvm-svn: 199192
2014-01-14 07:38:53 +00:00
Kostya Serebryany
d651412cd4
[asan] fix the ppc32 build (by Jakub Jelinek). Note that the LLVM build still builds only for 64-bit PowerPC, and not for 32-bit
...
llvm-svn: 199090
2014-01-13 10:19:12 +00:00
Dmitry Vyukov
5b57ea7a24
tsan: fix Go build
...
Currently fails with:
gotsan.cc:7686:40: error: the address of 'int __sanitizer_pthread_attr_getstack(void*, void**, size_t*)' will always evaluate as 'true' [-Werror=address]
llvm-svn: 198261
2013-12-31 09:38:23 +00:00
Chandler Carruth
a989fb5ce7
Fix an ODR violation in the sanitizer runtimes.
...
A helper function is a C++ function, and so even though one of the two
definitions is weak, it still technically triggers the ODR. Perhaps
these two definitions are ODR equivalent, but I'm not even confident in
that.
Instead, just define the function once, declare it as weak, and use
a wrapper that is clearly file-local. This avoids two definitions. Also
make the function extern "C" so that we can't even mess up the type
signature somehow or otherwise fail to match up the weak declaration
here with the interceptor defined elsewhere.
llvm-svn: 198253
2013-12-30 23:36:11 +00:00
Alexander Potapenko
79bb924e17
[libsanitizer] fix lint errors
...
llvm-svn: 198209
2013-12-30 11:12:11 +00:00
Alexander Potapenko
e93e87369f
[libsanitizer] Remove the redundant spaces between '#' and 'define'.
...
These definitions weren't included in any #ifdef blocks, and the spaces were placed inconsistently.
llvm-svn: 198207
2013-12-30 09:22:06 +00:00
Kostya Serebryany
2b5fddbc75
[asan] allow asan to use SizeClassAllocator32 on a 64-bit platform (if SANITIZER_CAN_USE_ALLOCATOR64=0). No functionality change by default is intended
...
llvm-svn: 198044
2013-12-26 13:52:38 +00:00
Alexey Samsonov
23347de6ef
[Sanitizer] Add Symbolizer::GetModuleNameAndOffsetForPC() and use it in LSan suppression matching.
...
This allows us to avoid retrieving file/line info for suppressed modules.
llvm-svn: 198025
2013-12-25 20:15:46 +00:00
Alexey Samsonov
782ad0eb71
[Sanitizer] Remove now unused symbolization functionality from MemoryMappingLayout
...
llvm-svn: 198014
2013-12-25 12:11:06 +00:00
Alexey Samsonov
5746c07629
[Sanitizer] Use different MemoryMappingLayout::DumpListOfModules on Linux and Mac.
...
Make a unit test added in r198004 more robust.
llvm-svn: 198012
2013-12-25 11:29:19 +00:00
Alexey Samsonov
bf658026c1
[Sanitizer] Properly specify linux-only unit test.
...
llvm-svn: 198007
2013-12-25 09:31:42 +00:00
Alexey Samsonov
ca7a213118
[Sanitizer] Don't use MemoryMappingLayout in StackTrace::PrintStack - it is now a responsibility of Symbolizer class.
...
llvm-svn: 198006
2013-12-25 09:29:54 +00:00
Alexey Samsonov
64ffa598ce
[Sanitizer] Teach MemoryMappingLayout to dump all loaded modules.
...
Use this to implement GetListOfModules() on Mac and on Android
(on Linux we use dl_iterate_phdr).
llvm-svn: 198004
2013-12-25 08:39:38 +00:00
Alexey Samsonov
2f392d237c
[Sanitizer] Move OS-specific code for MemoryMappingLayout into separate source files.
...
llvm-svn: 198003
2013-12-25 08:01:16 +00:00
Alexey Samsonov
6322e036aa
[Sanitizer] Replace Symbolizer::IsAvailable and Symbolizer::IsExternalAvailable with Symbolizer::CanReturnFileLineInfo.
...
Remove now redundant checks in symbolizer initialization in TSan and MSan.
llvm-svn: 198000
2013-12-25 07:09:44 +00:00
Evgeniy Stepanov
3d0edea4e1
[sanitizer] Add missing file comment.
...
llvm-svn: 197807
2013-12-20 13:13:49 +00:00
Evgeniy Stepanov
66297cac72
[msan] Wrap indirect calls to REAL(x) in interceptors.
...
llvm-svn: 197806
2013-12-20 12:20:15 +00:00
Evgeniy Stepanov
61628196e4
[msan] Replace wrap_indirect_calls runtime flag with an interface method.
...
llvm-svn: 197799
2013-12-20 11:05:19 +00:00
Alexey Samsonov
f2c7659cf8
[ASan] Get rid of ASan-specific functions for printing stack traces
...
llvm-svn: 197672
2013-12-19 11:25:05 +00:00
Alexey Samsonov
3efe401db0
[Sanitizer] Delete unused StackTrace::PrintStack argument
...
llvm-svn: 197671
2013-12-19 11:14:26 +00:00
Timur Iskhodzhanov
caf7c0cdcd
[Sanitizers] Fix CL compile-time warning in the symbolizer
...
llvm-svn: 197573
2013-12-18 14:39:23 +00:00
Timur Iskhodzhanov
1c84bd64db
[Sanitizer] Implement Symbolizer class on Windows
...
llvm-svn: 197571
2013-12-18 14:29:16 +00:00
Timur Iskhodzhanov
b5f983e4b0
[Sanitizers] Rename Symbolizer::SymbolizeCode to Symbolizer::SymbolizePC
...
llvm-svn: 197569
2013-12-18 14:17:39 +00:00
Alexey Samsonov
33a2cc1e10
Fix gen_dynamic_list.py for Python 3. Patch by Marcoen Hirschberg.
...
llvm-svn: 197493
2013-12-17 12:19:16 +00:00
Alexey Samsonov
25d010a98d
[Sanitizer] Always initialize a Symbolizer (even if 'symbolize' is false).
...
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.
llvm-svn: 197491
2013-12-17 11:15:39 +00:00
Evgeniy Stepanov
59bb0878e2
[msan] Tweak gethostbyname_r interceptor some more.
...
This is covered by msan_test depending on glibc version and/or resolver setup.
llvm-svn: 197484
2013-12-17 09:13:54 +00:00
Evgeniy Stepanov
43fc44007d
[msan] Fix gethostbyname_r and similar interceptors.
...
*h_errno is written not on success, but on failure.
In fact, it seems like it can be written even when return value signals
success, so we just unpoison it in all cases.
llvm-svn: 197383
2013-12-16 13:24:33 +00:00
Kostya Serebryany
57bfdb080b
[asan] add flag uar_noreserve to use noreserve mmap for fake stack. uar_noreserve=1 will save some memory but also negatively affect performance
...
llvm-svn: 197233
2013-12-13 15:03:49 +00:00
Evgeniy Stepanov
a643a754be
[sanitizer] Disable call wrapping when building for Go.
...
llvm-svn: 197232
2013-12-13 14:58:21 +00:00
Evgeniy Stepanov
879c552dd9
[msan] Wrap indirect calls from sanitizer rtl when running under DR.
...
llvm-svn: 197226
2013-12-13 13:13:46 +00:00
Timur Iskhodzhanov
89a346c2a1
[ASan] Fix StackTrace::SlowUnwindStack on Windows
...
llvm-svn: 196894
2013-12-10 08:30:39 +00:00
Chandler Carruth
3f697191bb
Revert a final patch that was committed without the author contributing
...
it to the LLVM project through the appropriate channels.
This reverts:
r195837: "[Sanitizer] Add rudimentary support for using libbacktrace in ..."
llvm-svn: 196875
2013-12-10 04:40:39 +00:00
Richard Smith
ab788cdc81
Unbreak build by adding an implementation of PopStackFrames function.
...
llvm-svn: 196809
2013-12-09 19:52:39 +00:00
Chandler Carruth
736f9fd229
Revert three patches which were committed without explicit contribution
...
by their authors.
This may break builds where others added code relying on these patches,
but please *do not* revert this commit. Instead, we will prepare patches
which fix the failures.
Reverts the following commits:
r168306: "[asan] support x32 mode in the fast stack unwinder. Patch by H.J. Lu"
r168356: "[asan] more support for powerpc, patch by Peter Bergner"
r196489: "[sanitizer] fix the ppc32 build (patch by Jakub Jelinek)"
llvm-svn: 196802
2013-12-09 19:25:51 +00:00
Alexey Samsonov
9f6218bf44
PR17977: don't assume EOWNERDEAD is always defined
...
Summary: See details in http://llvm.org/bugs/show_bug.cgi?id=17977
Reviewers: dvyukov
Reviewed By: dvyukov
CC: glider, llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D2340
llvm-svn: 196779
2013-12-09 13:21:43 +00:00
Sergey Matveev
9be70fbda9
[sanitizer] Introduce VReport and VPrintf macros and use them in sanitizer code.
...
Instead of "if (common_flags()->verbosity) Report(...)" we now have macros.
llvm-svn: 196497
2013-12-05 12:04:51 +00:00
Kostya Serebryany
f2c93b2973
[sanitizer] fix the ppc32 build (patch by Jakub Jelinek)
...
llvm-svn: 196489
2013-12-05 08:51:48 +00:00
Kostya Serebryany
14e92c2c62
[sanitizer] support toolchains that don't understand CFI directives
...
Summary: Support toolchains that don't understand CFI directives.
Reviewers: dvyukov
Reviewed By: dvyukov
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D2336
llvm-svn: 196480
2013-12-05 07:44:35 +00:00
Sergey Matveev
7bc300c8fc
[sanitizer] Fix log_path behavior with StopTheWorld.
...
Summary:
Fix race on report_fd/report_fd_pid between the parent process and the
tracer task.
Reviewers: samsonov
Reviewed By: samsonov
CC: llvm-commits, kcc, dvyukov
Differential Revision: http://llvm-reviews.chandlerc.com/D2306
llvm-svn: 196385
2013-12-04 14:37:01 +00:00
Alexey Samsonov
907eb5b630
[Sanitizer] Use more appropriate InternalScopedString in GetCodeRangeForFile
...
llvm-svn: 196264
2013-12-03 09:29:23 +00:00
Alexey Samsonov
8dd33a27c3
[Sanitizer] Fix a bug introduced in r196112. Add a test.
...
llvm-svn: 196263
2013-12-03 09:21:08 +00:00
Sergey Matveev
b748d46019
[sanitizer] Allow InternalMmapVector construction with zero capacity.
...
llvm-svn: 196112
2013-12-02 15:41:04 +00:00
Evgeniy Stepanov
c0378e72d1
[sanitizer] Intercept textdomain.
...
Patch by Alexander Taran.
llvm-svn: 196098
2013-12-02 13:43:26 +00:00
Kostya Serebryany
5774faf5b0
[sanitizer] disable shmctl intercetor in 32-bit -- it is rotten (bug filed)
...
llvm-svn: 195958
2013-11-29 14:09:13 +00:00
Timur Iskhodzhanov
5ca41e3800
Increase the LocatePcInTrace PC threshold now that GET_STACK_TRACE_WITH_PC_AND_BP has grown
...
llvm-svn: 195957
2013-11-29 13:15:25 +00:00
Timur Iskhodzhanov
bbf2ff8193
[ASan] Also print <empty stack> when size==0
...
llvm-svn: 195955
2013-11-29 12:08:59 +00:00
Evgeniy Stepanov
f2cddc3e64
[sanitizer] Disable iconv interceptor in OSX.
...
iconv is defined in an optional DSO, and our interception logic on OSX does not
support that.
llvm-svn: 195919
2013-11-28 14:42:59 +00:00