Commit Graph

541 Commits

Author SHA1 Message Date
Alexey Samsonov 0a779d7e3d [Sanitizer] Initialize common flags to default values in unit tests.
llvm-svn: 245363
2015-08-18 21:54:32 +00:00
Reid Kleckner e96833e648 [Windows] Implement FileExists, ReadFromFile, and FindPathToBinary
Summary: These are needed to talk to llvm-symbolizer on Windows.

Reviewers: samsonov

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D11920

llvm-svn: 244533
2015-08-10 23:40:27 +00:00
Alexey Samsonov 1e156011d1 [Sanitizer] Try to fix sanitizer_libc_test on FreeBSD.
llvm-svn: 243797
2015-07-31 23:02:51 +00:00
Evgeniy Stepanov 7fb865ea8e [asan] Only link liblog on Android when it exists.
With r242975, liblog is only used on certain older platforms.

llvm-svn: 243139
2015-07-24 19:00:16 +00:00
Evgeniy Stepanov 5a268b10b3 [sanitizer] Implement logging to syslog.
Previously, Android target had a logic of duplicating all sanitizer
output to logcat. This change extends it to all posix platforms via
the use of syslog, controlled by log_to_syslog flag. Enabled by
default on Android, off everywhere else.

A bit of cmake magic is required to allow Printf() to call a libc
function. I'm adding a stub implementation to support no-libc builds
like dfsan and safestack.

This is a second attempt. I believe I've fixed all the issues that
prompted the revert: Mac build, and all kinds of non-CMake builds
(there are 3 of those).

llvm-svn: 243051
2015-07-23 22:05:20 +00:00
Evgeniy Stepanov ffbc4ec790 Revert r242975.
Breaks Mac build.

llvm-svn: 242978
2015-07-23 01:29:26 +00:00
Evgeniy Stepanov 4f03227fa2 [sanitizer] Implement logging to syslog.
Previously, Android target had a logic of duplicating all sanitizer
output to logcat. This change extends it to all posix platforms via
the use of syslog, controlled by log_to_syslog flag. Enabled by
default on Android, off everywhere else.

A bit of cmake magic is required to allow Printf() to call a libc
function. I'm adding a stub implementation to support no-libc builds
like dfsan and safestack.

llvm-svn: 242975
2015-07-22 23:57:19 +00:00
Evgeniy Stepanov fdcaafa2b8 [asan] Fix sanitizer_allocator_test on AArch64.
llvm-svn: 242582
2015-07-17 22:29:05 +00:00
Evgeniy Stepanov 856b11199f [asan] Fix SanitizerCommon.PthreadDestructorIterations test on Android L.
On Android L, TSD destructors run 8 times instead of 4.
Back to 4 times on the current master branch (as well as on K).

llvm-svn: 240992
2015-06-29 20:28:55 +00:00
Evgeniy Stepanov 609af9098c [asan] Link sanitizer_common tests on Android as -pie.
llvm-svn: 240825
2015-06-26 20:39:30 +00:00
Filipe Cabecinhas 215046bf98 [sanitizer_common] Added VS-style output for source locations
Summary:
With this patch, we have a flag to toggle displaying source locations in
the regular style:
file:line:column

or Visual Studio style:
file(line,column)

This way, they get picked up on the Visual Studio output window and one
can double-click them to get to that file location.

Reviewers: samsonov, rnk

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D10113

llvm-svn: 239000
2015-06-04 01:20:06 +00:00
Evgeniy Stepanov 8e9c70be7f Add descriptive names to sanitizer entries in /proc/self/maps. Helps debugging.
This is done by creating a named shared memory region, unlinking it
and setting up a private (i.e. copy-on-write) mapping of that instead
of a regular anonymous mapping. I've experimented with regular
(sparse) files, but they can not be scaled to the size of MSan shadow
mapping, at least on Linux/X86_64 and ext3 fs.

Controlled by a common flag, decorate_proc_maps, disabled by default.

This patch has a few shortcomings:
* not all mappings are annotated, especially in TSan.
* our handling of memset() of shadow via mmap() puts small anonymous
  mappings inside larger named mappings, which looks ugly and can, in
  theory, hit the mapping number limit.

llvm-svn: 238621
2015-05-29 22:31:28 +00:00
Reid Kleckner 60bdf6e4c0 Disable exceptions with Clang on Windows in lib/sanitizer-common/tests
While I'm here, fix a copy-paste bug so we get debug info for these
tests.

llvm-svn: 236505
2015-05-05 16:52:50 +00:00
Timur Iskhodzhanov ea1f332b79 Split Mprotect into MmapNoAccess and MprotectNoAccess to be more portable
On Windows, we have to know if a memory to be protected is mapped or not.
On POSIX, Mprotect was semantically different from mprotect most people know.

llvm-svn: 234602
2015-04-10 15:02:19 +00:00
Timur Iskhodzhanov 5df4d0471f Move more POSIX-specific functions to sanitizer_posix.h
llvm-svn: 234482
2015-04-09 12:54:06 +00:00
Timur Iskhodzhanov 864308a78d Introduce CloseFile to be used instead of internal_close on non-POSIX
llvm-svn: 234481
2015-04-09 12:37:05 +00:00
Timur Iskhodzhanov 3745303c5b Move some POSIX-specific functions from sanitizer_libc.h to a new sanitizer_posix.h
llvm-svn: 234418
2015-04-08 17:08:24 +00:00
Timur Iskhodzhanov daa9e2d4e8 [Sanitizers] Make OpenFile more portable
llvm-svn: 234410
2015-04-08 16:03:22 +00:00
Timur Iskhodzhanov b97bcc4981 [ASan] Unify handling of loaded modules between POSIX and Windows
Reviewed at http://reviews.llvm.org/D8805

llvm-svn: 234150
2015-04-06 12:49:30 +00:00
Alexander Potapenko f0581dda03 [sanitizer] Fix file access modes in SanitizerCommon.InternalMmapWithOffset and SanitizerCommon.FileOps
llvm-svn: 232972
2015-03-23 17:55:19 +00:00
Alexander Potapenko 141e420a81 [ASan] Distinguish between read, write and read-write file access modes in OpenFile.
This is to fix mapping coverage files into memory on OSX.

llvm-svn: 232936
2015-03-23 10:10:46 +00:00
Kuba Brecka 656e184f6c Adding the implementation of atos and dladdr symbolizers for OS X.
They are currently still *not* used, "llvm-symbolizer" is still the default symbolizer on OS X.

Reviewed at http://reviews.llvm.org/D6588

llvm-svn: 232026
2015-03-12 10:53:18 +00:00
Kostya Serebryany 4bdf5ada18 [asan] more fixes for x32, patches by H.J. Lu
llvm-svn: 231174
2015-03-03 23:46:40 +00:00
Kuba Brecka 59e8c3b342 Symbolizer refactoring: ExtractToken and friends
Reviewed at http://reviews.llvm.org/D7867

llvm-svn: 231027
2015-03-02 22:15:14 +00:00
Dmitry Vyukov b79ac88155 asan: fix signal handling during stoptheworld
The problem is that without SA_RESTORER flag, kernel ignores the handler. So tracer actually did not setup any handler.
Add SA_RESTORER flag when setting up handlers.
Add a test that causes SIGSEGV in stoptheworld callback.
Move SignalContext from asan to sanitizer_common to print better diagnostics about signal in the tracer thread.

http://reviews.llvm.org/D8005

llvm-svn: 230978
2015-03-02 17:36:02 +00:00
Alexey Samsonov d1c318657b [Sanitizer] Refactor SuppressionContext class.
SuppressionContext is no longer a singleton, shared by all sanitizers,
but a regular class. Each of ASan, LSan, UBSan and TSan now have their
own SuppressionContext, which only parses suppressions specific to
that sanitizer.

"suppressions" flag is moved away from common flags into tool-specific
flags, so the user now may pass
  ASAN_OPTIONS=suppressions=asan_supp.txt LSAN_OPIONS=suppressions=lsan_supp.txt
in a single invocation.

llvm-svn: 230026
2015-02-20 17:41:59 +00:00
Mohit K. Bhakkad 36f974d76b [LSan] [MIPS] adding support of LSan for mips64/mips64el arch
Patch by Sagar Thakur

Reviewers: petarj, earthdok, kcc.

Subscribers:  samsonov, dsanders, mohit.bhakkad, Anand.Takale, llvm-commits.

Differential Revision: http://reviews.llvm.org/D7013

llvm-svn: 229830
2015-02-19 07:30:39 +00:00
Alexey Samsonov e41a26e4b4 Revert "Remove unused function."
This reverts commit r227633. SetEnv was prematurely deleted.

llvm-svn: 227665
2015-01-31 01:27:18 +00:00
Alexey Samsonov df0b22c5a8 Remove unused function.
llvm-svn: 227633
2015-01-30 23:04:54 +00:00
Evgeniy Stepanov a2edd9159a [sanitizer] Make unrecognized flags not fatal.
Print a warning at verbosity=1 and higher instead of dying immediately.

llvm-svn: 226458
2015-01-19 12:22:57 +00:00
Evgeniy Stepanov f294d5b829 [sanitizer] Flag parser rewrite.
The new parser is a lot stricter about syntax, reports unrecognized
flags, and will make it easier to implemented some of the planned features.

llvm-svn: 226169
2015-01-15 15:13:43 +00:00
Alexey Samsonov a04ca22edf Fix memory leaks in GetListOfModules() users.
llvm-svn: 225472
2015-01-08 22:31:14 +00:00
Viktor Kutuzov e01a595dad [Sanitizers] Fix internal_lseek() to work on FreeBSD
Differential Revision: http://reviews.llvm.org/D6825

llvm-svn: 225443
2015-01-08 13:28:22 +00:00
Alexey Samsonov df3aeb8e71 Remove TSAN_DEBUG in favor of SANITIZER_DEBUG.
llvm-svn: 225111
2015-01-03 04:29:12 +00:00
Evgeniy Stepanov 9e609426a7 [sanitizer] Treat \r, \n, \t as flag separators.
llvm-svn: 224858
2014-12-26 16:09:15 +00:00
Evgeniy Stepanov 5a09b2cdeb [sanitizer] Disable InternalMmapWithOffset test on OSX.
llvm-svn: 224822
2014-12-24 13:59:35 +00:00
Evgeniy Stepanov 40b16f4037 [sanitizer] Disable InternalMmapWithOffset test on Windows.
llvm-svn: 224820
2014-12-24 13:05:21 +00:00
Evgeniy Stepanov 98211121ab [sanitizer] mmap2 syscall works with 4096-byte units instead of bytes.
Ouch.

llvm-svn: 224819
2014-12-24 12:58:09 +00:00
Viktor Kutuzov d4c3ffc5bf [Sanitizers] Intercept snprintf_l() on FreeBSD
Differential Revision: http://reviews.llvm.org/D6418

llvm-svn: 224700
2014-12-22 12:29:40 +00:00
Alexey Samsonov 2f8c8d59b2 [Sanitizer] Refactor CommonFlags interface. NFC.
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.

llvm-svn: 224617
2014-12-19 21:40:04 +00:00
Alexey Samsonov 6334f46db8 [Sanitizer] Introduce Allocator::may_return_null bool flag.
Summary:
Turn "allocator_may_return_null" common flag into an
Allocator::may_return_null bool flag. We want to make sure
that common flags are immutable after initialization. There
are cases when we want to change this flag in the allocator
at runtime: e.g. in unit tests and during ASan activation
on Android.

Test Plan: regression test suite, real-life applications

Reviewers: kcc, eugenis

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D6623

llvm-svn: 224148
2014-12-12 20:07:35 +00:00
Kumar Sukhani adb3864744 [mips] [test] Enable COMPILER_RT_INCLUDE_TESTS for MIPS
Enabling COMPILER_RT_INCLUDE_TESTS and updating tests/sanitizer_allocator_test.cc to remove Allocator64 related tests for MIPS.

Reviewed By: samsonov

llvm-svn: 224101
2014-12-12 07:08:12 +00:00
Kuba Brecka dde00302c7 Implement AddressSanitizer suppressions.
Adds 3 new suppression types, "interceptor_name", "interceptor_via_fun", "interceptor_via_lib".

Reviewed at http://reviews.llvm.org/D6280.

llvm-svn: 223508
2014-12-05 20:26:09 +00:00
Kuba Brecka 4bd88e3deb Add a HasSuppressionType method into SuppressionContext
Extending SuppressionContext to add a HasSuppressionType method that tells whether a certain suppression type is currently used or not. It's a step to implement issue suppressions for ASan, see http://reviews.llvm.org/D6280.

Reviewed at http://reviews.llvm.org/D6443

llvm-svn: 222954
2014-11-29 14:18:05 +00:00
Alexey Samsonov 70f3897b0a [Sanitizer] Introduce generic stack frame rendering machinery
Summary:
This commit introduces function __sanitizer::RenderFrame()
that allows to render the contents of AddressInfo (essentially, symbolized stack frame)
using the custom format string. This function can be used to
implement stack frame formatting for both ThreadSanitizer and
generic StackTrace::Print(), used in another places. This paves the
way towards allowing user to control the format of stack frames,
obtaining them in any format he desires, and/or enforcing the consistent
output from all sanitizers.

Test Plan: compiler-rt test suite

Reviewers: kcc

Reviewed By: kcc

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D6140

llvm-svn: 221409
2014-11-05 22:44:36 +00:00
Alexey Samsonov 3741ab82ba Change StackDepot interface to use StackTrace more extensively
llvm-svn: 220637
2014-10-26 06:23:07 +00:00
Alexey Samsonov 9c85927012 [Sanitizer] Make StackTrace a lightweight reference to array of PCs, and
introduce a BufferedStackTrace class, which owns this array.

Summary:
This change splits __sanitizer::StackTrace class into a lightweight
__sanitizer::StackTrace, which doesn't own array of PCs, and BufferedStackTrace,
which owns it. This would allow us to simplify the interface of StackDepot,
and eventually merge __sanitizer::StackTrace with __tsan::StackTrace.

Test Plan: regression test suite.

Reviewers: kcc, dvyukov

Reviewed By: dvyukov

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D5985

llvm-svn: 220635
2014-10-26 03:35:14 +00:00
Dan Albert c5d4bc7581 Fix checks for Android.
__ANDROID__ is a define that comes from the toolchain when building
for Android targets. ANDROID has a different meaning. ANDROID is
defined for _every_ Android build, including those done for host
modules. For host modules, we want to build the regular Linux
sanitizers and builtins, not the one for Android devices. This hasn't
been a problem until now because we only just started building the
sanitizers for the host.

llvm-svn: 220203
2014-10-20 15:35:01 +00:00
Kuba Brecka 14c0c5901d [compiler-rt] compiler-rt's CMake append_if function clashes with LLVM's, let's rename it to append_list_if
Doing s/append_if/append_list_if/, no functional change.

http://reviews.llvm.org/D5739

llvm-svn: 219860
2014-10-15 22:47:54 +00:00
Evgeniy Stepanov 9e984c5137 [sanitizer] Fix a crash in FP unwinder on ARM.
This change fixes 2 issues in the fast unwinder from r217079:
* A crash if a frame pointer points below current stack head, but
  inside the current thread stack limits. That memory may be
  unmapped. A check for this was lost in r217079.
* The last valid stack frame (the first one with an invalid next
  frame pointer) is always interpreted as a GCC layout frame. This
  results in garbled last PC in the (expected) case when the last
  frame has LLVM layout.

llvm-svn: 219683
2014-10-14 13:46:07 +00:00
Evgeniy Stepanov 9e922e7d24 [sanitizer] Android build cleanup.
* Detect Android toolchain target arch and set correct runtime library name.
* Merged a lot of Android and non-Android code paths.
* Android is only supported in standalone build of compiler-rt now.
* Linking lsan-common in ASan-Android (makes lsan annotations work).
* Relying on -fsanitize=address linker flag when building tests (again,
  unification with non-Android path).
* Runtime library moved from lib/asan to lib/linux.

llvm-svn: 218605
2014-09-29 13:18:55 +00:00
Alexey Samsonov 1947bf9921 PR20721: Don't let UBSan print inaccessible memory
Summary:
UBSan needs to check if memory snippet it's going to print resides
in addressable memory. Similar check might be helpful in ASan with
dump_instruction_bytes option (see http://reviews.llvm.org/D5167).

Instead of scanning /proc/self/maps manually, delegate this check to
the OS kernel: try to write this memory in a syscall and assume that
memory is inaccessible if the syscall failed (e.g. with EFAULT).

Fixes PR20721.

Test Plan: compiler-rt test suite

Reviewers: eugenis, glider

Reviewed By: glider

Subscribers: emaste, ygribov, llvm-commits, glider, rsmith

Differential Revision: http://reviews.llvm.org/D5253

llvm-svn: 217971
2014-09-17 17:56:15 +00:00
Dmitry Vyukov 6466f43688 tsan: fix crash when a program registers zillions of atexit callbacks
I don't remember that crash on mmap in internal allocator
ever yielded anything useful, only crashes in rare wierd untested situations.
One of the reasons for crash was to catch if tsan starts allocating
clocks using mmap. Tsan does not allocate clocks using internal_alloc anymore.
Solve it once and for all by allowing mmaps.

llvm-svn: 217929
2014-09-17 00:12:50 +00:00
Kuba Brecka fa2de77a14 Make compiler-rt tests work with relocatable SDKs on OS X
Reviewed at http://reviews.llvm.org/D4047

llvm-svn: 217523
2014-09-10 17:23:58 +00:00
Alexey Samsonov 2428359e23 Fixup test case after r217079
llvm-svn: 217111
2014-09-03 23:46:12 +00:00
Dmitry Vyukov dc1caa7cb8 tsan: address comments in r214912
See http://reviews.llvm.org/D4794

llvm-svn: 216900
2014-09-02 09:34:34 +00:00
Alexey Samsonov 408d2152c4 Fixup Android tests build rules
llvm-svn: 215264
2014-08-09 00:23:11 +00:00
Alexey Samsonov ff24fd2516 [UBSan] Allow to suppress reports from vptr checker for specified types.
Based on http://reviews.llvm.org/D4702 by Byoungyoung Lee!

llvm-svn: 214833
2014-08-05 01:24:22 +00:00
Dan Albert 1c71fde161 Exclude Android from the tests for valloc/pvalloc.
These functions are being removed from Android because they were removed
from POSIX 2004.

llvm-svn: 210962
2014-06-14 00:50:03 +00:00
Evgeniy Stepanov 9cc3ebdd3b [sanitizer] Relax sanity checks in ioctl decoding.
Standard KVM ioctls don't pass currect ioctl_decode().

llvm-svn: 210533
2014-06-10 13:54:15 +00:00
Evgeniy Stepanov 3641cd43b2 [asan] Use -pthread instead of -lpthread in tests.
llvm-svn: 210255
2014-06-05 12:22:37 +00:00
Dmitry Vyukov afdcc96d9f tsan: optimize memory access functions
The optimization is two-fold:
First, the algorithm now uses SSE instructions to
handle all 4 shadow slots at once. This makes processing
faster.
Second, if shadow contains the same access, we do not
store the event into trace. This increases effective
trace size, that is, tsan can remember up to 10x more
previous memory accesses.

Perofrmance impact:
Before:
[       OK ] DISABLED_BENCH.Mop8Read (2461 ms)
[       OK ] DISABLED_BENCH.Mop8Write (1836 ms)
After:
[       OK ] DISABLED_BENCH.Mop8Read (1204 ms)
[       OK ] DISABLED_BENCH.Mop8Write (976 ms)
But this measures only fast-path.
On large real applications the speedup is ~20%.

Trace size impact:
On app1:
Memory accesses                   :       1163265870
  Including same                  :        791312905 (68%)
on app2:
Memory accesses                   :        166875345
  Including same                  :        150449689 (90%)
90% of filtered events means that trace size is effectively 10x larger.

llvm-svn: 209897
2014-05-30 13:36:29 +00:00
Timur Iskhodzhanov 1b42b81549 [Sanitizers Win] Move duplicate Windows-specific compiler flags to a common CMake variable
Reviewed at http://reviews.llvm.org/D3952

llvm-svn: 209889
2014-05-30 12:42:57 +00:00
Evgeniy Stepanov 50c1532a1a [sanitizer] Update flags test.
llvm-svn: 209818
2014-05-29 14:55:12 +00:00
Viktor Kutuzov 76d35f47d3 Fix building 32-bit common sanitizer tests on FreeBSD 9.2
llvm-svn: 209804
2014-05-29 11:35:05 +00:00
Timur Iskhodzhanov 82ee0433da [ASan/Win] Use clang rather than clang-cl by default for lit tests. Make Windows-only tests explicitly use clang-cl.
Reviewed at http://reviews.llvm.org/D3893

llvm-svn: 209719
2014-05-28 08:38:13 +00:00
Timur Iskhodzhanov 930ffe94aa [Sanitizer tests] Don't need to use -lstdc++ thanks to --driver-mode=g++
Reviewed at http://reviews.llvm.org/D3796

llvm-svn: 209115
2014-05-19 08:19:38 +00:00
Timur Iskhodzhanov 5812350591 [Sanitizer tests] Exclude three tests that fail on Windows
llvm-svn: 208698
2014-05-13 13:34:00 +00:00
Timur Iskhodzhanov e33158bcd1 [Sanitizer tests] Land the sanitizer twin of the asan-only change r208682
llvm-svn: 208697
2014-05-13 13:29:11 +00:00
Timur Iskhodzhanov 339e8c98f8 [Sanitizer tests] Add sanitizer_test_config.h to make the inclusion of gtest.h conditional
Reviewed at http://reviews.llvm.org/D3744

llvm-svn: 208696
2014-05-13 13:25:12 +00:00
Timur Iskhodzhanov 2e9136c2da [Sanitizer/ASan tests] Automatically detect the presence of libstdc++
llvm-svn: 208695
2014-05-13 12:57:50 +00:00
Timur Iskhodzhanov e5e92fac4a [Sanitizer tests] Fix most of the build problems on Windows
E.g. use the pthread helpers introduced in r208674

llvm-svn: 208692
2014-05-13 12:02:53 +00:00
Timur Iskhodzhanov 711269966c [Sanitizer tests] Make simple pthread tests compile and pass on Windows
Reviewed at http://reviews.llvm.org/D3725

llvm-svn: 208674
2014-05-13 08:07:09 +00:00
Timur Iskhodzhanov 1ac44dd087 [Sanitizer tests] Fix a comment that got out of sync with the #if
llvm-svn: 208602
2014-05-12 17:33:00 +00:00
Timur Iskhodzhanov 9a205ed8ee [ASan tests] Use the proper attribute on RunStrChrTest helper functions to avoid "unused function" warnings
llvm-svn: 208568
2014-05-12 14:31:57 +00:00
Timur Iskhodzhanov 76f43eecb0 [ASan] Update sanitizer_common and asan test_util headers to support building on Windows
llvm-svn: 208306
2014-05-08 12:43:33 +00:00
Alexey Samsonov d94e87db3f [Sanitizer] Add rudimentary support for wide-character strings to scanf/printf interceptors
llvm-svn: 207443
2014-04-28 20:40:25 +00:00
Viktor Kutuzov f9eba2f51d Fix building Asan and common sanitizers tests on FreeBSD 9.2
llvm-svn: 207408
2014-04-28 10:33:01 +00:00
Kostya Serebryany 683d55f50e [sanitizer] speed up the bitvector-based deadlock detector by ~15% (iterate over the currently held locks using the array, not the bitvector. Bitvector is not the best data structure to iterate over)
llvm-svn: 205168
2014-03-31 07:23:50 +00:00
Alexey Samsonov c41ca6d31a [CMake] Rename the variable
llvm-svn: 204602
2014-03-24 13:29:20 +00:00
Alexey Samsonov 1847401332 [CMake] Respect CMAKE_CXX_FLAGS in custom clang_compile commands
llvm-svn: 204593
2014-03-24 09:42:12 +00:00
Kostya Serebryany 3df5d87da4 [sanitizer] print threads in deadlock report
llvm-svn: 204461
2014-03-21 13:00:18 +00:00
Alexander Potapenko 1296436cbf [libsanitizer] Introduce flag descriptions.
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.

llvm-svn: 204339
2014-03-20 12:52:52 +00:00
Alexey Samsonov 17703c1092 [CMake] Build sanitizer unit tests with -std=c++11
llvm-svn: 204234
2014-03-19 13:57:33 +00:00
Kostya Serebryany 2483acce21 [sanitizer] when recycling deadlock graph nodes, properly recycle edges
llvm-svn: 204233
2014-03-19 13:53:37 +00:00
Kostya Serebryany 2ea796e05f [sanitizer] deadlock detector: a) initial support for suppressions, b) be more robust in case we failed to extract a stack trace for one of the locks
llvm-svn: 204225
2014-03-19 12:26:33 +00:00
Kostya Serebryany a0eb97a50b [sanitizer] allow to store the lock context (stack trace id) with all currently held locks in a thread. This will allow the deadlock detector to provide better warnings (more changes to go)
llvm-svn: 204039
2014-03-17 12:27:42 +00:00
Kostya Serebryany 61a0f1c564 [sanitizer] partially implement racy fast path in bitset-based deadlock detector
llvm-svn: 203904
2014-03-14 08:06:15 +00:00
Kostya Serebryany c067864b6f [sanitizer] in bitset-based deadlock detector collect edge's stack trace when an edge is added to the graph (in following CLs these stack traces will be added to the report)
llvm-svn: 203902
2014-03-14 07:09:01 +00:00
Kostya Serebryany 65dbf46950 [sanitizer] in bitvector-based deadlock detector split onLock into onLockBefore and onLockAfter hooks
llvm-svn: 203796
2014-03-13 13:21:30 +00:00
Kostya Serebryany de3f20cf4b [sanitizer] support recursive rwlocks in bitset-based deadlock detector
llvm-svn: 203779
2014-03-13 10:26:03 +00:00
Alexey Samsonov 32956d651a [CMake] Make append_if semantics similar to those used in LLVM
llvm-svn: 203773
2014-03-13 09:31:36 +00:00
Alexey Samsonov fefeecc7b0 [ASan] Better way to disable tests for functions unavailable on certain platforms
llvm-svn: 203224
2014-03-07 09:39:01 +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
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 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
Alexey Samsonov 14e061d7cc Support 'q' length modifier in scanf/printf interceptors
llvm-svn: 202268
2014-02-26 14:42:38 +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
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
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
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 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
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
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
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
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
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
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
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 2629e575db [sanitizer] Fix build.
llvm-svn: 201152
2014-02-11 13:45:01 +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 efefe5e225 [sanitizer] Fix build.
llvm-svn: 200873
2014-02-05 20:04:12 +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
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 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
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
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 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 8dd33a27c3 [Sanitizer] Fix a bug introduced in r196112. Add a test.
llvm-svn: 196263
2013-12-03 09:21:08 +00:00
Kostya Serebryany ccfc0481f1 [sanitizer] Implement TwoLevelByteMap and use it for the internal allocator on 64-bit.
Summary:
Implement TwoLevelByteMap and use it for the internal allocator on 64-bit.
This reduces bss on 64-bit by ~8Mb because we don't use FlatByteMap on 64-bits any more.

Dmitry, please check my understanding of atomics.

Reviewers: dvyukov

Reviewed By: dvyukov

CC: samsonov, llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D2259

llvm-svn: 195637
2013-11-25 11:33:41 +00:00
Dmitry Vyukov 70fcec46e9 tsan: remove debug output from test
llvm-svn: 195347
2013-11-21 11:50:45 +00:00
Alexey Samsonov 4d369187ec [Sanitizer] Print symbolized stack frame using a single Printf() call.
This reduces the number of "write" syscalls performed to print a single
stack frame description, and makes sanitizer output less intermixed with
program output. Also, add a number of unit tests.

llvm-svn: 194686
2013-11-14 09:41:24 +00:00
Alexey Samsonov 9ff4598225 [ASan] Do not rely on malloc context in allocator reports.
Invoke a fatal stack trace unwinder when ASan prints allocator-relevant
error reports (double-free, alloc-dealloc-mismatch, invalid-free).
Thus we'll be able to print complete stack trace even if allocation/free
stacks are not stored (malloc_context_size=0).

Based on the patch by Yuri Gribov!

llvm-svn: 194579
2013-11-13 14:46:58 +00:00
Alexey Samsonov b3d939902a [Sanitizer] Make StackTrace::Unwind the only public way to unwind a stack trace.
llvm-svn: 194196
2013-11-07 07:28:33 +00:00
Peter Collingbourne 50cb32e614 Introduce an operator new for LowLevelAllocator, and convert most users to it.
llvm-svn: 193308
2013-10-24 06:23:39 +00:00
Kostya Serebryany f04ae33106 [asan] Fix a deadlock between asan's allocator and lsan
Summary:
This fixes a deadlock which happens in lsan
on a large memalign-allocated chunk that resides in lsan's root set.

Reviewers: samsonov, earthdok

Reviewed By: earthdok

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1957

llvm-svn: 192885
2013-10-17 11:18:11 +00:00
Alexey Samsonov 7f5823844a [Sanitizer] Remove StackTrace::max_depth field
llvm-svn: 192534
2013-10-12 12:40:47 +00:00
Sergey Matveev 53e61b1acf [sanitizer] Define kPthreadDestructorIterations on POSIX systems.
llvm-svn: 192453
2013-10-11 14:19:14 +00:00
Sergey Matveev 6c5e943953 [sanitizer] Ninja style fix to r192442.
llvm-svn: 192443
2013-10-11 12:15:45 +00:00
Sergey Matveev dc75cf3368 [sanitizer] Move the PTHREAD_DESTRUCTOR_ITERATIONS constant to sanitizer_linux.h.
Add a test.

llvm-svn: 192442
2013-10-11 12:09:49 +00:00
Alexey Samsonov 9d8385453b [Sanitizer] Simplify StackTrace::FastUnwindStack interface and fix a bug with one-frame stack traces
llvm-svn: 192428
2013-10-11 09:58:30 +00:00
Alexey Samsonov f2b811a618 Refactor the usage of strip_path_prefix option and make it more consistent across sanitizers
llvm-svn: 191943
2013-10-04 08:55:03 +00:00
Dmitry Vyukov 5ba736457c tsan: ignore interceptors coming from specified libraries
LibIgnore allows to ignore all interceptors called from a particular set
of dynamic libraries. LibIgnore remembers all "called_from_lib" suppressions
from the provided SuppressionContext; finds code ranges for the libraries;
and checks whether the provided PC value belongs to the code ranges.

Also make malloc and friends interceptors use SCOPED_INTERCEPTOR_RAW instead of
SCOPED_TSAN_INTERCEPTOR, because if they are called from an ignored lib,
then must call our internal allocator instead of libc malloc.

llvm-svn: 191897
2013-10-03 13:37:17 +00:00
Dmitry Vyukov 4e9c091dd7 tsan: allow to obtain code range for a particular module
this is required to ignore interceptors when called from the module

llvm-svn: 191149
2013-09-21 21:41:08 +00:00
Alexey Samsonov ad7925e0c1 Minor enhancements for sanitizer_common build rules
llvm-svn: 190786
2013-09-16 15:43:23 +00:00
Eli Friedman abc1a5cb9b Delete unused variables.
llvm-svn: 190383
2013-09-10 03:27:07 +00:00
Alexey Samsonov a302a1affc [Sanitizer] Use generic configs for running sanitizer_common unit tests
llvm-svn: 190276
2013-09-08 13:52:07 +00:00
Alexey Samsonov 16516b9b00 Migrate ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS to new spelling - ATTRIBUTE_NO_SANITIZE_ADDRESS
llvm-svn: 190136
2013-09-06 11:07:33 +00:00
Kostya Serebryany ada5a7b7ef [sanitizer] make the allocator crash instead of returning 0 on huge size (controlled by the allocator_may_return_null flag)
llvm-svn: 190127
2013-09-06 09:25:11 +00:00
Alexey Samsonov 5b2000e4d9 Disable FindPathToBinary test on Android
llvm-svn: 189923
2013-09-04 06:40:48 +00:00
Alexey Samsonov de647ddc8b [Sanitizer] Add the way to find binary in PATH
llvm-svn: 189799
2013-09-03 13:20:48 +00:00
Alexey Samsonov 249c7fb10e Add internal_strchrnul function
llvm-svn: 189797
2013-09-03 13:09:28 +00:00
Sergey Matveev 69931c5841 [sanitizer_common] Add internal_clone().
Add a wrapper for the clone syscall for use in StopTheWorld. We
implement it only for x86_64, so stop building StopTheWorld for other platforms
(no one uses it outside x86_64 anyway).

See https://code.google.com/p/address-sanitizer/issues/detail?id=214 for why we
can't use the glibc clone() wrapper.

llvm-svn: 189753
2013-09-02 11:36:19 +00:00
Alexey Samsonov 5a2f073926 [sanitizer] Refine CMake rules for generating exported symbols and lint checking
llvm-svn: 189577
2013-08-29 10:49:04 +00:00
Alexey Samsonov d875c39be6 Check code style in check-sanitizer command
llvm-svn: 189475
2013-08-28 11:27:31 +00:00
Alexey Samsonov ef643ce471 [sanitizer] fix code style
llvm-svn: 189474
2013-08-28 11:26:09 +00:00
Sergey Matveev 9e3e80208f [sanitizer] Add a fast version of StackDepotGet() for use in LSan.
Add a class that holds a snapshot of the StackDepot optimized for querying by
ID. This allows us to speed up LSan dramatically.

llvm-svn: 189217
2013-08-26 13:24:43 +00:00
Daniel Dunbar bc5dbc435e [tests] Update to use lit_config and lit package, as appropriate.
llvm-svn: 188116
2013-08-09 22:14:01 +00:00
Evgeniy Stepanov 7f915cf8a5 [sanitizer] Fix handling of %n in scanf interceptor.
%n does not increase the input item count. The new code emits writes to %n
arguments even if it has run out of input items.

llvm-svn: 188069
2013-08-09 12:58:35 +00:00
Dmitry Vyukov d4060fd281 tsan: extend suppressions format with ^ and $ symbols
not it's possible to write more precise suppressions,
e.g. "^foo$" won't match "blafoobar"

llvm-svn: 186424
2013-07-16 16:44:15 +00:00
Sergey Matveev 2b19ee3da8 [lsan] Add suppression support.
llvm-svn: 185152
2013-06-28 14:38:31 +00:00
Sergey Matveev 9450108430 [sanitizer] Support padding with spaces in Printf.
llvm-svn: 185082
2013-06-27 15:30:44 +00:00
Sergey Matveev d109eb052b [tsan] Move some suppressions-related code to common.
Factor out code to be reused in LSan. Also switch from linked list to vector.

llvm-svn: 184957
2013-06-26 15:37:14 +00:00
Sergey Matveev b8cd986b5d [lsan] Fix android build.
llvm-svn: 184704
2013-06-24 09:12:11 +00:00
Sergey Matveev 4e0215a71c Revert to C-style callbacks for iteration over allocator chunks.
Also clean up LSan code, fix some comments and replace void* with uptr
to bring down the number of reinterpret_casts.

llvm-svn: 184700
2013-06-24 08:34:50 +00:00
Evgeniy Stepanov 673cf23d06 Fix unused function warning w/o changing compiler flags.
We have way too many different build systems.

llvm-svn: 184409
2013-06-20 09:45:36 +00:00
Evgeniy Stepanov fbea5b95c6 [sanitizer] Handle EVIOxxxx ioctls.
llvm-svn: 184405
2013-06-20 09:19:28 +00:00
Alexey Samsonov b0d92b3312 [Sanitizer] Rename InternalVector to InternalMmapVector
llvm-svn: 183972
2013-06-14 09:59:40 +00:00
Sergey Matveev 53c24fe0e6 [sanitizer] Fix r182994 - update test.
llvm-svn: 182995
2013-05-31 11:33:21 +00:00
Alexey Samsonov 2a6cc67225 Fix #if guards in sanitizer_common code
llvm-svn: 182918
2013-05-30 09:16:04 +00:00
Kostya Serebryany 831a1d7cec [sanitizer] introduce LargeMmapAllocator::GetBlockBeginFastSingleThreaded, required for LeakSanitizer to work faster. Also fix lint.
llvm-svn: 182917
2013-05-30 08:43:30 +00:00
Sergey Matveev 89bcec8117 [sanitizer] Change the way GetThreadStackAndTls() obtains the thread descriptor address.
Instead of using arch_prctl(ARCH_GET_FS), read the address from the
tread descriptor itself. This lets us avoid sandboxing issues. Also,
GetThreadStackAndTls() can now be implemented on i386.

llvm-svn: 182853
2013-05-29 13:07:42 +00:00
Peter Collingbourne 93aa8dfb78 [nolibc] Now that we have a custom allocator, remove dummy allocator
definitions from test.

llvm-svn: 182841
2013-05-29 10:52:59 +00:00
Alexey Samsonov c30e2d6b3a Make InternalAlloc/InternalFree in sanitizer runtimes libc-free by switching to a custom allocator.
llvm-svn: 182836
2013-05-29 09:15:39 +00:00
Peter Collingbourne a7887bf8be [nolibc] Add a test case for Linux/x86_64.
Differential Revision: http://llvm-reviews.chandlerc.com/D873

llvm-svn: 182770
2013-05-28 12:37:34 +00:00
Alexey Samsonov 9c2bcf8c15 Improve support for compiler-rt tests in CMake build.
Now compiler-rt tests run correctly if compiler-rt is checked out into
arbitrary directory (not necessarily projects/compiler-rt).
Patch by Greg Fitzgerald!

llvm-svn: 182726
2013-05-27 09:35:24 +00:00
Kostya Serebryany 3469375e4f [sanitizer] factor out ByteMap from SizeClassAllocator32 so that it can be later replaced with a more memory-efficient implementation on 64-bit.
llvm-svn: 182234
2013-05-20 07:29:21 +00:00
Peter Collingbourne 6d4a7d3723 [nolibc] Begin moving sanitizer_common's libc-dependent code to a separate library
Introduce a new object library, RTSanitizerCommonLibc, which will contain
the subset of sanitizer_common with libc dependencies. RTSanitizerCommon
contains the remainder of sanitizer_common, and is intended to have no
libc dependencies. Begin moving code to RTSanitizerCommonLibc, starting
with sanitizer_common.cc, whose libc-dependent portion is moved to
sanitizer_common_libcdep.cc, the first member of the new library.

This split affects the CMake build only.  The makefile build continues
to produce the full sanitizer_common library.

llvm-svn: 182118
2013-05-17 16:17:19 +00:00
Dmitry Vyukov 69c544d857 tsan: comment out debug output in test
llvm-svn: 182087
2013-05-17 11:54:37 +00:00
Sergey Matveev efb6172cb3 [sanitizer] Fix the region overflow condition in SanitizerAllocator64::PopulateFreeList().
llvm-svn: 182002
2013-05-16 12:58:34 +00:00
Kostya Serebryany a551aaa944 [sanitizer] fix the GetBlockBegin overflow bug while preserving the performance optimization (use 32-bit division when possible). Improve the benchmarks that checks for performance of GetBlockBegin/GetMetaData
llvm-svn: 181989
2013-05-16 07:11:16 +00:00
Kostya Serebryany ad9971d793 [sanitizer] added a test for a bug in allocator discovered by Sergey Matveev (uint32 overflow in GetBlockBegin)
llvm-svn: 181984
2013-05-16 05:22:50 +00:00
Kostya Serebryany 2b42716213 [asan] fix powerpc build and one test; fix lint
llvm-svn: 181881
2013-05-15 12:36:29 +00:00
Sergey Matveev af05543c86 [sanitizer] LibraryNameIs in sanitizer_linux
llvm-svn: 181787
2013-05-14 13:24:46 +00:00
Sergey Matveev 14b56186ab [sanitizer] Minor fixes in sanitizer_common tests.
llvm-svn: 181786
2013-05-14 13:19:33 +00:00
Kostya Serebryany 9d987e34f7 [tsan] fix gcc build with -Wall
llvm-svn: 181763
2013-05-14 08:26:55 +00:00
Peter Collingbourne 6f4be19b57 [nolibc] Change internal syscall API to remove reliance on libc's errno.
This change moves to a model where the error value of a system call is
potentially contained in the return value itself rather than being
implicit in errno.  The helper function internal_iserror can be used
to extract the error value from a return value.  On platforms other
than Linux/x86_64 this still uses errno, but other platforms are free
to port their error handling to this new model.

Differential Revision: http://llvm-reviews.chandlerc.com/D756

llvm-svn: 181436
2013-05-08 14:43:49 +00:00
Sergey Matveev 954c6ef10f [sanitizer] Move GetThreadStackAndTls from TSan to sanitizer_common.
Move this function to sanitizer_common because LSan uses it too. Also, fix a bug
where the TLS range reported for main thread was off by the size of the thread
descriptor from libc (TSan doesn't care much, but for LSan it's critical).

llvm-svn: 181322
2013-05-07 14:41:43 +00:00
Evgeniy Stepanov 517118e6b4 [sanitizer] Sanitizer __internal_*stat interface.
With this change, __internal_*stat always expect a "struct stat *" argument.
This avoids stat/stat64 caller-side confusion (sanitizer_common tests already
made this mistake), and allows the use of __internal_fstat() as a drop-in
replacement for libc's fstat().

llvm-svn: 181311
2013-05-07 12:47:04 +00:00
Alexey Samsonov f36c5a8431 Revert r180082 and add a test for SetEnv function
llvm-svn: 180098
2013-04-23 12:49:12 +00:00
Kostya Serebryany e6459977b8 [sanitizer] Fix boundary condition in LargeMmapAllocator::GetBlockBegin. Patch by Sergey Matveev
llvm-svn: 179007
2013-04-08 08:43:22 +00:00
Kostya Serebryany c3525ce6ac [sanitizer] while doing fast unwinding make sure that the frame pointer is aligned; fix lint
llvm-svn: 178747
2013-04-04 06:52:40 +00:00
Alexey Samsonov e586170e86 Fix unmatching ASan runtime flag for init-order checking exposed by r178158. Add a test for r178158.
llvm-svn: 178229
2013-03-28 09:11:20 +00:00
Alexey Samsonov 7ef76c1cd8 [Sanitizer] Disable atomic_test on Android, where it crashes Clang.
llvm-svn: 177998
2013-03-26 08:55:38 +00:00
Alexey Samsonov c6fd019c77 [Sanitizer] Add basic test for atomic_compare_exchange implementation
llvm-svn: 177851
2013-03-25 08:48:16 +00:00
Dmitry Vyukov 0f2c7ea5d0 tsan: fix lint warnings
llvm-svn: 177251
2013-03-18 07:58:20 +00:00
Alexey Samsonov e25c72958a [Sanitizer] Rely on template argument deduction in sanitizer_allocator_test
llvm-svn: 177245
2013-03-18 06:07:44 +00:00
Alexander Potapenko 845b575370 [libsanitizer] StopTheWorld in sanitizer_common
StopTheWorld puts the process in a suspended state before running the
user-supplied callback. To be used in TSan and in leak checking code.

Linux implementation provided.

Patch by Sergey Matveev (earthdok@google.com)

llvm-svn: 177156
2013-03-15 14:37:21 +00:00
Alexey Samsonov e4385c4b98 [Sanitizer] Don't link tests with -lpthread on Android.
llvm-svn: 177151
2013-03-15 12:54:01 +00:00
Kostya Serebryany 96a7620f3a [sanitizer] fix gcc build warnings
llvm-svn: 177149
2013-03-15 12:27:52 +00:00
Kostya Serebryany b941a2fca4 [asan] Add ForEachChunk() to sanitizer allocators. Patch by Sergey Matveev
llvm-svn: 177147
2013-03-15 11:39:41 +00:00
Alexey Samsonov cdd46d9ccc [Sanitizer] Generalize compile/link flags for sanitizer_common tests on Android and on other platforms.
llvm-svn: 177146
2013-03-15 10:39:26 +00:00
Alexey Samsonov 337b0fcf9c [Sanitizer] Build sanitizer_common tests w/o RTTI. Move ThreadRegistry class members below methods.
llvm-svn: 177143
2013-03-15 07:08:52 +00:00
Alexey Samsonov d1999a1ccc [Sanitizer] Fix compiler warnings and style issues in sanitizer_common tests. Use -Werror=sign-compare when building them.
llvm-svn: 177077
2013-03-14 15:15:35 +00:00
Alexey Samsonov 1cb684381a [Sanitizer] Add generic ThreadRegistry class for sanitizer runtimes. This class holds basic thread bookkeeping logic and allows specific sanitizer runtimes to create thread contexts and mark threads as created/running/joined etc. The class is based on the way we currently store thread contexts in TSan.
llvm-svn: 177074
2013-03-14 13:54:30 +00:00
Alexander Potapenko 34e1171768 [libsanitizer] fixed a bug in ThreadLister tests where we forgot to terminate one thread
Patch by Sergey Matveev (earthdok@google.com)

llvm-svn: 177068
2013-03-14 13:15:14 +00:00
Alexander Potapenko ac3bbb3ef3 [libsanitizer] Fixed incorrect handling of pre-existing threads in ThreadLister test.
Also, extended the test to check that ThreadLister::Reset() works as intended.

Patch by Sergey Matveev (earthdok@google.com)

llvm-svn: 177060
2013-03-14 12:06:54 +00:00
Evgeniy Stepanov 5697b58ec4 [sanitizer] Move GetTlsSize code from TSan to sanitizer_common.
llvm-svn: 176938
2013-03-13 08:19:53 +00:00
Kostya Serebryany 138b155042 [sanitizer] use fewer size classes in the allocator to reduce the memory footprint. There is no all-size-fits-all constant here, but this change is positive or neutral on several large apps I've tested
llvm-svn: 176855
2013-03-12 08:44:40 +00:00
Alexey Samsonov db7d9656bb [Sanitizer] Implement BlockingMutex::CheckLocked()
llvm-svn: 176805
2013-03-11 15:45:20 +00:00
Kostya Serebryany 0f5c20b417 [sanitizer] make SizeClassAllocator64::GetBlockBegin more bullet proof (by Sergey Matveev)
llvm-svn: 176799
2013-03-11 09:43:12 +00:00
Reid Kleckner c193da57b8 [msan] pthread_join() returns int, not void*
pthread_join() returns an error code, not the result of the
pthread_create() function like I thought.

llvm-svn: 176554
2013-03-06 15:41:35 +00:00
Reid Kleckner 66c26e5e96 [sanitizers] Fix check failure on dealloc from new thread
Summary:
Adds a test for this case, which was reduced from a chromium build of
WebKit's DumpRenderTree.

Reviewers: eugenis

CC: glider

Differential Revision: http://llvm-reviews.chandlerc.com/D495

llvm-svn: 176552
2013-03-06 14:54:08 +00:00
Alexey Samsonov dcb0e72e6f [Sanitizer] fix signed-unsigned mismatch in test and use correct order of EXPECT_EQ() args
llvm-svn: 176479
2013-03-05 12:23:07 +00:00
Alexey Samsonov 434dde9996 [Sanitizer] Add methods back() and pop_back() to InternalVector. Patch by Sergey Matveev
llvm-svn: 176478
2013-03-05 11:58:25 +00:00
Alexey Samsonov 4a3234bec5 [Sanitizer] Relax ThreadLister tests to allow possible pre-existing threads. Do proper mutex destruction. Patch by Sergey Matveev
llvm-svn: 176249
2013-02-28 11:33:51 +00:00
Kostya Serebryany f0b8f989e9 add Linux syscall wrappers and ThreadLister to sanitizer_common
ThreadLister is a Linux-specific class for obtaining the thread IDs of a process from procfs (/proc/<pid>/task/). It will be used by leak checking code.
Also add several syscall wrappers which will be required by the same code that uses ThreadLister, but are not used in ThreadLister itself.
Patch by Sergey Matveev

llvm-svn: 176179
2013-02-27 11:22:40 +00:00
Kostya Serebryany c98cddd024 [asan] guard ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS definition with an #ifndef
llvm-svn: 176175
2013-02-27 08:28:24 +00:00
Kostya Serebryany a8cfb900dd [sanitizer] A low-level vector implementation to be used in leak checking code. Patch by Sergey Matveev
llvm-svn: 176089
2013-02-26 13:30:27 +00:00
Kostya Serebryany c8ac15a66b [asan] use the new attribute syntax (no_address_safety_analysis => no_sanitize_address)
llvm-svn: 176077
2013-02-26 07:01:06 +00:00
Alexey Samsonov 54ff0f6388 [Sanitizer] one more fix for signed/unsigned mismatch in comparison
llvm-svn: 176020
2013-02-25 14:06:38 +00:00
Alexey Samsonov b2ac280f96 [Sanitizer] fix signed/unsigned compare warnings in sanitizer_stacktrace_test. Build sanitizer_common tests with -Werror as we use predictable just-built Clang for building them
llvm-svn: 176014
2013-02-25 09:00:03 +00:00
Reid Kleckner e1596856ec [Sanitizer] Add a test for the fast unwinder
Summary:
The test sets up fake x86-style fp+retaddr frames, since that's all the
unwinder works with.

Reviewers: kcc

CC: eugenis

Differential Revision: http://llvm-reviews.chandlerc.com/D445

llvm-svn: 175893
2013-02-22 15:10:16 +00:00
Evgeniy Stepanov 2e50efd484 [sanitizer] Fix FileOps test on Android.
llvm-svn: 175515
2013-02-19 15:01:05 +00:00
Evgeniy Stepanov 477e88ee9e [sanitizer] Slightly lower allocator test memory consumption.
This way it fits on a random 1G device.

llvm-svn: 175513
2013-02-19 13:38:27 +00:00
Alexey Samsonov 99b81b4bbe [Sanitizer] Allow runtime flags be separated by colon as well as space
llvm-svn: 175511
2013-02-19 13:03:37 +00:00
Kostya Serebryany 9f298da9bd [asan] instrument memory accesses with unusual sizes
This patch makes asan instrument memory accesses with unusual sizes (e.g. 5 bytes or 10 bytes), e.g. long double or
packed structures.
Instrumentation is done with two 1-byte checks
(first and last bytes) and if the error is found
__asan_report_load_n(addr, real_size) or
__asan_report_store_n(addr, real_size)
is called.

asan-rt part

Also fix lint.

llvm-svn: 175508
2013-02-19 11:30:25 +00:00
Alexey Samsonov 9211bd33ec [Sanitizer] Make temporary filename depend on user ID
llvm-svn: 175424
2013-02-18 07:17:12 +00:00
Evgeniy Stepanov 71a4ab7141 [sanitizer] Tests for scanf parser in allowGnuMalloc=false mode.
llvm-svn: 174971
2013-02-12 14:37:55 +00:00
Evgeniy Stepanov 154faa6ded [sanitizer] clang-format pass over scanf code.
llvm-svn: 174888
2013-02-11 15:22:34 +00:00
Evgeniy Stepanov 455c72d25e [sanitizer] scanf: don't report stores that did not happen.
Respect REAL(scanf) return value and don't report memory stores that
could potentially happen, but did not.

llvm-svn: 174887
2013-02-11 15:16:48 +00:00
Evgeniy Stepanov 7e0430fe4f [sanitizer] Scanf parser improvements.
Handle %a in cases when it is unambiguous.
Handle %m.

Patch by Jakub Jelinek.

llvm-svn: 174882
2013-02-11 14:04:24 +00:00
Evgeniy Stepanov e6045b4603 [sanitizer] Add 2 random tests for the scanf implementation.
llvm-svn: 174705
2013-02-08 11:19:23 +00:00
Evgeniy Stepanov 87c43537df [sanitizer] Improve scanf interceptor
This a rewrite of the scanf parser. The new implementation is pretty close to
the spec, with a few shortcuts taken here and there. It is conservative, i.e.
it gives up parsing if it does not understand some part of the format string,
or runs into an ambiguous % spec. It does not handle some rarely used parts of
the spec, like %n$ - for now.

I'm also moving parser call to after the original *scanf function completes,
so that we can find out the store size of %s directive by the use of strlen()
on the target buffer.

llvm-svn: 174704
2013-02-08 11:17:20 +00:00
Alexey Samsonov 2c5cbd2b38 [Sanitizer] extend internal libc with stat/fstat/lstat functions
llvm-svn: 174316
2013-02-04 10:16:50 +00:00
Alexey Samsonov c500132a93 [Sanitizer] Add change missed in r173926
llvm-svn: 173929
2013-01-30 13:19:15 +00:00
Alexey Samsonov 49a32c1d08 [Sanitizer] update style checker script and fix namespace style warnings
llvm-svn: 173910
2013-01-30 07:45:58 +00:00
Alexey Samsonov 5311754b62 [CMake] Fix compiler-rt tests after r173617
llvm-svn: 173668
2013-01-28 07:16:22 +00:00
Alexey Samsonov 622a7b2408 [Sanitizer] More fixes to scanf interceptor: stub support for %s, support for %[...] directive
llvm-svn: 173451
2013-01-25 15:26:19 +00:00
Alexey Samsonov 4899fb5cfb [Sanitizer] fix errors in scanf interceptors: add support for %c and fix cases like %5d
llvm-svn: 173440
2013-01-25 11:43:32 +00:00
Dmitry Vyukov 6e406cda4b tsan: implement malloc stats querying
llvm-svn: 173332
2013-01-24 09:08:03 +00:00
Alexey Samsonov 163ab9d0a5 CMake: create AddCompilerRT module and implement convenience add_compiler_rt_object_library function
llvm-svn: 172826
2013-01-18 16:05:21 +00:00
Evgeniy Stepanov 01671c33ff [sanitizer] lint
llvm-svn: 172817
2013-01-18 13:12:56 +00:00
Evgeniy Stepanov a6c4a387ee [sanitizer] Rename 2 files *.h->*.inc as appropriate.
Also add a missing include.

llvm-svn: 172814
2013-01-18 13:01:18 +00:00
Alexey Samsonov 193b45f4fe CMake variables renaming: X86_64->x86_64 I386->i386
llvm-svn: 172812
2013-01-18 12:45:44 +00:00
Evgeniy Stepanov 518a135ffe [sanitizer] Remove an unused variable.
llvm-svn: 172811
2013-01-18 12:32:02 +00:00
Evgeniy Stepanov 222076e972 [sanitizer] Common *scanf interceptors.
llvm-svn: 172805
2013-01-18 11:17:23 +00:00
Dmitry Vyukov 9ab63f68fc asan: fix standalone malloc implementation
llvm-svn: 172529
2013-01-15 12:57:02 +00:00