Commit Graph

579 Commits

Author SHA1 Message Date
Evgeniy Stepanov adaca58526 [msan] Fix ReExec on linux.
execle(argv[0], ...) is wrong, because argv[0] may contain a PATH-resolvable
program name. Execute /proc/self/exe instead.

llvm-svn: 175504
2013-02-19 11:09:29 +00:00
Evgeniy Stepanov 3e2e32c618 [sanitizer] Fix Android build.
llvm-svn: 175503
2013-02-19 11:06:41 +00:00
Evgeniy Stepanov ea61d08185 [sanitizer] Add interceptors for localtime and friends.
llvm-svn: 175499
2013-02-19 09:19:16 +00:00
Alexey Samsonov 9211bd33ec [Sanitizer] Make temporary filename depend on user ID
llvm-svn: 175424
2013-02-18 07:17:12 +00:00
Kostya Serebryany fd61b6f0c8 [asan] make asan work with 7fff8000 offset and prelink
When prelink is installed in the system, prelink-ed
libraries map between 0x003000000000 and 0x004000000000 thus occupying the shadow Gap,
so we need so split the address space even further, like this:
|| [0x10007fff8000, 0x7fffffffffff] || HighMem    ||
|| [0x02008fff7000, 0x10007fff7fff] || HighShadow ||
|| [0x004000000000, 0x02008fff6fff] || ShadowGap3 ||
|| [0x003000000000, 0x003fffffffff] || MidMem     ||
|| [0x00087fff8000, 0x002fffffffff] || ShadowGap2 ||
|| [0x00067fff8000, 0x00087fff7fff] || MidShadow  ||
|| [0x00008fff7000, 0x00067fff7fff] || ShadowGap  ||
|| [0x00007fff8000, 0x00008fff6fff] || LowShadow  ||
|| [0x000000000000, 0x00007fff7fff] || LowMem     ||

Do it only if necessary.

Also added a bit of profiling code to make sure that the
mapping code is efficient.

Added a lit test to simulate prelink-ed libraries.
Unfortunately, this test does not work with binutils-gold linker.
If gold is the default linker the test silently passes.

Also replaced
__has_feature(address_sanitizer)
with
__has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
in two places.

Patch partially by Jakub Jelinek.

llvm-svn: 175263
2013-02-15 12:00:24 +00:00
Evgeniy Stepanov 2a25bfe06a [sanitizer] Get full argv and envp on glibc.
/proc/$PID/cmdline is clipped to 4Kb.
Locate argv and envp on the main thread stack.

llvm-svn: 175163
2013-02-14 14:40:03 +00:00
Evgeniy Stepanov 763b2981b4 [sanitizer] Raise argv limit for ReExec.
We are still limited by /proc/*/cmdline size (4Kb max on Linux!).

llvm-svn: 175145
2013-02-14 08:22:06 +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 b5ec3a2d55 [sanitizer] More accurate scanf parsing without GNU extensions.
In __isoc99_*scanf we don't have to worry about GNUisms, and can parse
%a accurately.

Patch by Jakub Jelinek.

llvm-svn: 174969
2013-02-12 14:29:34 +00:00
Evgeniy Stepanov 5fa8fb7d91 [sanitizer] Intercept __isoc99_*scanf.
llvm-svn: 174960
2013-02-12 11:34:52 +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 5eb25e8d39 [sanitizer] Remove an extra va_copy.
llvm-svn: 174883
2013-02-11 14:08:12 +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 60a8e5b9b7 [sanitizer] Fix lint.
llvm-svn: 174708
2013-02-08 12:13:43 +00:00
Timur Iskhodzhanov 167f9e4395 [ASan] Switch Windows to allocator v2, also fixing some build errors
llvm-svn: 174707
2013-02-08 12:02:00 +00:00
Timur Iskhodzhanov 659bca56a7 [ASan] Move functions using BitScan/clzl to sanitizer_common
llvm-svn: 174706
2013-02-08 11:45:04 +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
Kostya Serebryany 39675fe9c8 [sanitizer] always allocate 16-byte aligned chunks of memory
llvm-svn: 174617
2013-02-07 15:04:06 +00:00
Alexander Potapenko 109aa04ea9 [sanitizer_common] Fix lint warnings.
llvm-svn: 174616
2013-02-07 14:58:04 +00:00
Alexander Potapenko 07c740e213 [ASan] Fix a compilation warning.
llvm-svn: 174604
2013-02-07 12:00:40 +00:00
Alexander Potapenko f444a49310 [ASan] Implement asan_mz_size(), asan_mz_force_lock() and asan_mz_force_unlock() for allocator2.
Switch to allocator2 on Darwin.

llvm-svn: 174603
2013-02-07 11:40:03 +00:00
Kostya Serebryany 7b0b9b3b65 [msan] add strip_path_prefix flag; print error summary; don't crash while printing summary if debug info is missing. The tests will follow later once we establish the lit-like tests for msan.
llvm-svn: 174595
2013-02-07 08:04:56 +00:00
Alexander Potapenko d895ae94f9 Use 64-bit inodes in file operations. ASan is now built with -mmacosx-version-min=10.5, thus the default inode
size is 32 bits. However the supported client code is going to target 10.6 and higher, where 64-bit inodes will be used.

llvm-svn: 174507
2013-02-06 14:41:15 +00:00
Kostya Serebryany 4fb340d972 [tsan] print error summary line
llvm-svn: 174505
2013-02-06 14:24:00 +00:00
Kostya Serebryany b4c2c5c8a6 [asan] print a short one-line report summary after the full report. Currently, works only if symbolization happens in-process.
llvm-svn: 174501
2013-02-06 12:36:49 +00:00
Dmitry Vyukov fa67ed47e1 asan/tsan: fix failing CHECK on windows
llvm-svn: 174319
2013-02-04 10:42:38 +00:00
Alexey Samsonov 576e270287 [Sanitizer] use proper casting in *stat functions on Mac
llvm-svn: 174318
2013-02-04 10:31:39 +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
Dmitry Vyukov 7981ea8baa asan/tsan: fix compilation errors/bugs on Windows where long is 32-bit even in 64-bit mode
llvm-svn: 174312
2013-02-04 08:07:45 +00:00
Alexey Samsonov 4985b8766e [Sanitizer] use u32 instead of mode_t, which is defined in Darwin headers
llvm-svn: 174189
2013-02-01 16:32:18 +00:00
Alexey Samsonov 39313b780d [Sanitizer] make internal_open have the same interface as libc version
llvm-svn: 174187
2013-02-01 15:58:46 +00:00
Kostya Serebryany bda64b4d40 [sanitizer] make the error messages from sanitizer_common contain the actual tool name
llvm-svn: 174059
2013-01-31 14:11:21 +00:00
Dmitry Vyukov 00e0236665 asan/tsan: manually define FUTEX constants, because <linux/futes.h> header is broken on some linux distributions
llvm-svn: 173933
2013-01-30 14:39:27 +00:00
Alexey Samsonov c500132a93 [Sanitizer] Add change missed in r173926
llvm-svn: 173929
2013-01-30 13:19:15 +00:00
Evgeniy Stepanov 358698279d [sanitizer] Further split private and public sanitizer headers.
And make msan_interface.h C-compatible.

llvm-svn: 173928
2013-01-30 13:12:08 +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
Dmitry Vyukov 0632dd410c tsan: fix the message (tsan is not asan)
llvm-svn: 173784
2013-01-29 09:39:58 +00:00
Dmitry Vyukov 7943b69002 tsan: add IsSymbolizerAvailable() function for querying for presence of internal/external symbolizer
llvm-svn: 173783
2013-01-29 09:35:14 +00:00
Timur Iskhodzhanov 6cff9deb16 Use the correct order of NOINLINE vs ret type to fix Windows build
llvm-svn: 173694
2013-01-28 17:29:50 +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
Kostya Serebryany c1056f90ae [sanitizer] improve the calloc overflow check (spotted by samsonov@)
llvm-svn: 173443
2013-01-25 12:22:21 +00:00
Kostya Serebryany fa79cd65e2 [sanitizer] fix calloc overflow in asan/tsan/msan
llvm-svn: 173441
2013-01-25 11:46:22 +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
Alexey Samsonov 971b0cd26f [Sanitizer] use stub InternalSymbolizer on platforms where we don't have weak hooks
llvm-svn: 173347
2013-01-24 14:01:59 +00:00
Alexey Samsonov 8db4077583 [Sanitizer] Add skeleton for InternalSymbolizer that can be used by providing callbacks __sanitizer_symbolize_{code,data}
llvm-svn: 173344
2013-01-24 13:42:45 +00:00
Dmitry Vyukov 6e406cda4b tsan: implement malloc stats querying
llvm-svn: 173332
2013-01-24 09:08:03 +00:00
Dmitry Vyukov 0ced85a8c7 asan/tsan: fix pwrite interceptors
llvm-svn: 173328
2013-01-24 07:44:21 +00:00
Kostya Serebryany 7206a145dd [sanitizer] increase the minimal mmap size in allocator to 2^16; fix the asan Mac build
llvm-svn: 173261
2013-01-23 14:07:17 +00:00
Dmitry Vyukov 5787924e85 tsan: add missing interceptors
llvm-svn: 173253
2013-01-23 11:52:19 +00:00
Evgeniy Stepanov 5f37c82154 [sanitizer] Disable scanf interceptor on windows.
llvm-svn: 173037
2013-01-21 13:30:08 +00:00
Evgeniy Stepanov 5e7936f646 [sanitizer] Define va_copy on win32.
llvm-svn: 173025
2013-01-21 11:32:50 +00:00
Alexey Samsonov 4e50333684 CMake: Add add_compiler_rt_osx_object_library to create universal libraries on Mac
llvm-svn: 172979
2013-01-20 14:36:12 +00:00
Alexey Samsonov 2d04812a45 Fixup for r172828: use InternalScopedBuffer in favor of large stack buffers
llvm-svn: 172975
2013-01-20 13:22:06 +00:00
Alexey Samsonov b068483d4d CMake: Generalize build rules for different arches for sanitizer_common, asan, ubsan
llvm-svn: 172829
2013-01-18 16:51:07 +00:00
Alexander Potapenko b4ba995366 [ASan] Fix the log_path option to use different log files for parent and child processes after fork().
llvm-svn: 172828
2013-01-18 16:44:27 +00:00
Evgeniy Stepanov 8a3666f63c [sanitizer] Workaround broken mktemp on certain platforms.
llvm-svn: 172827
2013-01-18 16:24:50 +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 c8cde8d736 [sanitizer] Enable cpplint for .inc files.
llvm-svn: 172825
2013-01-18 15:53:43 +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
Kostya Serebryany 69fe0ba415 [sanitizer] reapply r172719, r172721-172723, r172725, and also fix the warning on Mac.
llvm-svn: 172791
2013-01-18 06:43:13 +00:00
Jakob Stoklund Olesen 7956e0094d Revert r172719, r172721-172723, and r172725.
The r172719 patch broke the build on Mac, the others depended on it.

compiler-rt/lib/asan/asan_interceptors.cc:78:13: error: unused function
      'SetThreadName' [-Werror,-Wunused-function]
      static void SetThreadName(const char *name) {

Orignal headlines:

  [asan] attempting to fix the Mac build
  [asan] restructure read/pread/pread64 tests
  [sanitizer] move write/pwrite/pwrite64 interceptors to common
  [msan] start using common interceptors in msan
  [tsan] move prctl interceptor from asan to common_interceptors thus enabling it for tsan too

llvm-svn: 172763
2013-01-17 22:51:56 +00:00
Peter Collingbourne 6600516a58 Have ReExec read environment from /proc/self/environ
It is possible for ReExec to be called before the C standard library
has initialised itself sufficiently for execv to work properly.
Fix this by parsing the environment ourselves and using execve.

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

llvm-svn: 172748
2013-01-17 19:50:42 +00:00
Kostya Serebryany 87eb229241 [asan] attempting to fix the Mac build
llvm-svn: 172725
2013-01-17 15:14:20 +00:00
Kostya Serebryany 5cdd91fc43 [sanitizer] move write/pwrite/pwrite64 interceptors to common
llvm-svn: 172722
2013-01-17 14:48:03 +00:00
Kostya Serebryany f7f5566055 [tsan] move prctl interceptor from asan to common_interceptors thus enabling it for tsan too
llvm-svn: 172719
2013-01-17 13:38:16 +00:00
Kostya Serebryany 93ebdb5d64 [sanitizer] a bit more unification for interceptors (merge read/pread/pread64 in asan and tsan)
llvm-svn: 172713
2013-01-17 13:09:00 +00:00
Dmitry Vyukov 59e5d358db tsan: fix a bug
llvm-svn: 172712
2013-01-17 12:59:10 +00:00
Dmitry Vyukov e528f67c14 tsan: fix a bug
llvm-svn: 172710
2013-01-17 12:13:03 +00:00
Dmitry Vyukov 7f4603200f asan: fix ARM build
llvm-svn: 172613
2013-01-16 14:35:13 +00:00
Dmitry Vyukov 9ab63f68fc asan: fix standalone malloc implementation
llvm-svn: 172529
2013-01-15 12:57:02 +00:00
Kostya Serebryany c4bb752e3b [sanitizer] hide PR_SET_NAME under an ifdef (for older kernels)
llvm-svn: 172523
2013-01-15 09:03:23 +00:00
Dmitry Vyukov 2854326db6 asan: correct non-temporal prefetch for memory allocator
llvm-svn: 172522
2013-01-15 09:03:20 +00:00
Dmitry Vyukov 45a698eb58 asan: faster thead-local cache for memory allocator
llvm-svn: 172521
2013-01-15 09:02:20 +00:00
Dmitry Vyukov 1f48c1a9a1 asan: fix lint warnings
llvm-svn: 172520
2013-01-15 08:51:10 +00:00
Dmitry Vyukov 74764617d7 asan: fix bugs in the testlib
llvm-svn: 172519
2013-01-15 08:33:41 +00:00
Dmitry Vyukov 1e4b54d196 asan: rename the file (it's not 64-bit specific anymore)
llvm-svn: 172518
2013-01-15 08:04:27 +00:00
Evgeniy Stepanov 99d91289b6 Move large part of asan_test_utils.h to sanitizer_common.
Move my_rand() to the common header.

This lets us avoid the use of rand_r in sanitizer_common tests.
There is no rand_r on Android.

llvm-svn: 172421
2013-01-14 15:12:26 +00:00
Alexey Samsonov 4e958e5ddb Fix-up copypasto from r172410
llvm-svn: 172419
2013-01-14 14:52:35 +00:00
Dmitry Vyukov ff19809a3d asan: fix windows build
llvm-svn: 172415
2013-01-14 14:28:06 +00:00
Evgeniy Stepanov cfe3b3b956 Build rules for sanitizer_common tests on Android.
llvm-svn: 172410
2013-01-14 14:08:25 +00:00
Evgeniy Stepanov e375a1f036 Remove thread-locals from sanitizer_common tests.
Not supported on Android.

llvm-svn: 172408
2013-01-14 14:06:58 +00:00
Dmitry Vyukov 4ebb4e5565 asan/tsan: mmap shadow memory before allocating memory (otherwise other threads can access non yet allocated shadow)
llvm-svn: 172395
2013-01-14 10:49:11 +00:00
Dmitry Vyukov 38092f628b asan/tsan: fix memory allocator statistics
llvm-svn: 172390
2013-01-14 08:51:08 +00:00
Dmitry Vyukov 064c739cea asan: fix Android build
llvm-svn: 172389
2013-01-14 08:48:26 +00:00
Dmitry Vyukov 795eb90db5 asan/tsan: faster memory allocator
1. Increase size classes from 32k to 128k
2. Use lock-free stack in central cache
3. Use blocking mutex when allocate new memory with mmap

llvm-svn: 172388
2013-01-14 08:23:34 +00:00
Dmitry Vyukov 8d15db4a1e tsan: fix cmake warning (unused private field)
llvm-svn: 172387
2013-01-14 08:21:34 +00:00
Dmitry Vyukov 316faf78ee tsan: add the FIXME
llvm-svn: 172386
2013-01-14 08:12:47 +00:00
Dmitry Vyukov af4b0b084a asan: fix compilation errors in mutex
llvm-svn: 172385
2013-01-14 08:01:58 +00:00
Kostya Serebryany f55e719a13 [asan] add more frames to standalone_malloc_test
llvm-svn: 172383
2013-01-14 07:59:09 +00:00
Dmitry Vyukov 3d462f89de asan: add missing file
llvm-svn: 172381
2013-01-14 07:52:01 +00:00
Dmitry Vyukov f22982bf0a asan/tsan: move blocking mutex from asan to sanitizer_common
llvm-svn: 172380
2013-01-14 07:51:39 +00:00
Dmitry Vyukov ecd73d36d4 asan/tsan: faster memory allocator
replace lists with arrays

llvm-svn: 172217
2013-01-11 16:41:19 +00:00
Dmitry Vyukov 86585ad319 asan: add memory prefetch to quarantine recycle
llvm-svn: 172216
2013-01-11 16:40:24 +00:00
Dmitry Vyukov 7c6c943782 asan: add memory prefetch to quarantine recycle
llvm-svn: 172215
2013-01-11 16:40:01 +00:00
Dmitry Vyukov f3a7087194 asan: improve allocator benchmark
llvm-svn: 172213
2013-01-11 16:22:53 +00:00
Dmitry Vyukov 83c4a77265 asan: improve the benchmark
llvm-svn: 172209
2013-01-11 15:57:19 +00:00
Dmitry Vyukov af96edbad2 asan: fix format string in CHECK
llvm-svn: 172203
2013-01-11 15:07:49 +00:00
Dmitry Vyukov edac64ad3f asan: prevent inlining of cold function
llvm-svn: 172197
2013-01-11 11:39:59 +00:00
Dmitry Vyukov 008dba6aa0 asan: always pass allocator cache to Allocate()
llvm-svn: 172193
2013-01-11 11:15:48 +00:00
Dmitry Vyukov b1c0dbe2c6 asan: faster quarantine
llvm-svn: 172192
2013-01-11 11:03:35 +00:00
Dmitry Vyukov c14bb685a1 asan/tsan: fix bug in list implementation
llvm-svn: 172187
2013-01-11 10:15:13 +00:00
Dmitry Vyukov db0cf871d4 asan: Refactor asan memory quarantine.
llvm-svn: 172183
2013-01-11 08:07:43 +00:00
Dmitry Vyukov 5cb6c62641 tsan: symbolize global variables
llvm-svn: 172181
2013-01-11 07:23:51 +00:00
Kostya Serebryany fdcfbda750 [sanitizer] better statistics for the large allocator
llvm-svn: 172069
2013-01-10 13:38:38 +00:00
Kostya Serebryany e1be48fe64 [sanitizer] fix the non-cmake build (2-nd attempt)
llvm-svn: 172068
2013-01-10 13:33:15 +00:00
Dmitry Vyukov 22c53df947 asan/tsan: fix comment
llvm-svn: 172064
2013-01-10 13:06:35 +00:00
Kostya Serebryany 1199dc0327 [sanitizer] fix the non-cmake build
llvm-svn: 172063
2013-01-10 13:05:16 +00:00
Kostya Serebryany 4f6e4ae44a [sanitizer] add standalone_malloc_test
llvm-svn: 172061
2013-01-10 12:34:12 +00:00
Kostya Serebryany 864ef315c0 [asan] make the slow unwinder a bit more robust. The unittests pass with fast_unwind_on_fatal=0, but I still observe some differences between the two unwinders
llvm-svn: 171973
2013-01-09 13:55:00 +00:00
Timur Iskhodzhanov 1d1f74cbf5 [ASan/Win] Satisfy lint
llvm-svn: 171970
2013-01-09 12:43:16 +00:00
Timur Iskhodzhanov 73e484aa8a [ASan/Win] Unbreak the 32-bit RTL build
llvm-svn: 171968
2013-01-09 12:03:27 +00:00
Kostya Serebryany cb510e50e2 [asan] implement more strict checking for memset/etc parameters. Instead of checking the first and the last byte, we check the entire shadow region. This costs ~10 slowdown for the instrumented functions. Motivated by a nasty memset-buffer-overflow-by-140-bytes in chrome which was reported as a use-after-free or not at all
llvm-svn: 171198
2012-12-28 15:24:16 +00:00
Alexey Samsonov 8474843e3b [TSan] Blacklist test: Rename blacklisted function. Make this test work for custom TSan testing script.
llvm-svn: 171186
2012-12-28 10:06:26 +00:00
Kostya Serebryany 4a42cf69a6 [sanitizer] add statistics to the allocator; fix lint
llvm-svn: 171161
2012-12-27 14:09:19 +00:00
Alexey Samsonov c20f5d2246 Define COMPILER_RT_CAN_EXECUTE_TESTS variable on platforms where we can produce working binaries and use it in build rules for sanitizers tests
llvm-svn: 171160
2012-12-27 13:19:23 +00:00
Kostya Serebryany 6f604b5007 [asan/tsan] when unmapping a chunk of user memory, apply madvise(MADV_DONTNEED) to the corresponding chunk of shadow memory. Also update sanitizer_allocator64_testlib.cc
llvm-svn: 171144
2012-12-27 07:37:24 +00:00
Alexey Samsonov c914281341 [Sanitizer] attempt to fix InterlockedCompareExchangePointer intrinsic on MSVC
llvm-svn: 171104
2012-12-26 09:25:09 +00:00
Kostya Serebryany a11cd57a78 [asan] asan_allocator2: by default use the StackDepot to store the stack traces instead of storing them in the redzones
llvm-svn: 171099
2012-12-26 06:30:02 +00:00
Kostya Serebryany 27ad15e165 [asan] asan_allocator2: store the user requested size in just 32 bits (larger sizes use metadata). This allows to put one more 32-bit field into the chunk header
llvm-svn: 171089
2012-12-26 04:52:07 +00:00
Kostya Serebryany eff9b4b9b1 [asan] add a test for right OOB with special large sizes. Fix this test in asan_allocator2. More test tweaking for allocator2
llvm-svn: 171058
2012-12-25 09:40:20 +00:00
Dmitry Vyukov 116518af74 tsan: fix tests to consistently use internal functions (otherwise it leads to false positives)
llvm-svn: 171057
2012-12-25 09:20:58 +00:00
Kostya Serebryany ad24c58e16 [sanitizer] increase the maximum size class of the fast allocator. This should save quite a bit of memory in tsan/msan (and later in asan). This also puts more stress on the large allocator. Add a couple of checks
llvm-svn: 171055
2012-12-25 07:50:35 +00:00
Kostya Serebryany db3250b8b3 [sanitizer] fix gcc warnings, enable one tests under asan_allocator2
llvm-svn: 171036
2012-12-24 14:53:13 +00:00
Kostya Serebryany fc7de2910c [sanitizer] make LargeMmapAllocator::GetBlockBegin faster by not using a linked list
llvm-svn: 171035
2012-12-24 14:35:14 +00:00
Kostya Serebryany ebb23c8cfa [sanitizer] rework the size class map in the sanitizer allocator: make the differences between size classes more uniform.
llvm-svn: 171031
2012-12-24 13:41:07 +00:00
Kostya Serebryany fe80f080ee [asan] asan_allocator2 fix two asserts that happen on full chrome: a) memalign called with 0 size and large alignment and b) malloc called after TSD has been destructed
llvm-svn: 170900
2012-12-21 14:54:46 +00:00
Alexey Samsonov e30a84f08f [Sanitizer] CMake build rules for unittests: depend on headers when compiling a file with custom clang.
llvm-svn: 170897
2012-12-21 14:04:52 +00:00
Kostya Serebryany a1e29adab5 [sanitizer] mmap less on every size class to make the allocator more friendly to small programs
llvm-svn: 170895
2012-12-21 13:38:05 +00:00
Alexey Samsonov 53a965e125 [Sanitizer] Don't implicitly add object files to the list of dependencies when building compiler_rt unittests. Fix sanitizer_common and asan build rules accordingly. This also fixes check-sanitizer command on Ninja.
llvm-svn: 170870
2012-12-21 08:56:14 +00:00
Alexey Samsonov aef6b78bcb [Sanitizer] Fix CMake build rules for sanitizer_common tests to respect universal static libraries on Mac
llvm-svn: 170698
2012-12-20 14:38:02 +00:00
Alexey Samsonov 01674dfc8f [Sanitizer] Modify CMake build rules for sanitizer_common unit tests: build them with fresh Clang for both 32- and 64-bits (if possible)
llvm-svn: 170691
2012-12-20 13:24:21 +00:00
Richard Smith 64e25ce53d Move C++ name demangling support from ubsan into sanitizer_common.
llvm-svn: 170666
2012-12-20 05:00:13 +00:00
Alexey Samsonov 35ed02ebf1 [Sanitizer] add missing header on Windows
llvm-svn: 170514
2012-12-19 08:51:39 +00:00
Kostya Serebryany 479f05b276 [asan] asan_allocator2: improve FindHeapChunkByAddress to find memory chunks to the left of a given address. Almost all tests pass with the new allocator now, only 6 are left to fix.
llvm-svn: 170511
2012-12-19 08:32:50 +00:00
Alexey Samsonov b6219c060b [Sanitizer] implement internal_isatty on Windows
llvm-svn: 170507
2012-12-19 07:57:42 +00:00
Kostya Serebryany 2abbce6701 [sanitizer] one more stability fix in 64-bit allocator
llvm-svn: 170498
2012-12-19 06:51:45 +00:00
Kostya Serebryany 12676268fa [sanitizer] fix LargeMmapAllocator::GetBlockBegin
llvm-svn: 170434
2012-12-18 14:56:38 +00:00
Alexey Samsonov f37c45c20d [Sanitizer] Expose StackTrace::GetPreviousInstructionPc() to get PC of call instruction from return address
llvm-svn: 170424
2012-12-18 09:57:34 +00:00
Kostya Serebryany bad01549b6 [asan] add some colors to asan output if printing to tty (following ubsan)
llvm-svn: 170418
2012-12-18 07:32:16 +00:00
Richard Smith 54fc2370f9 Don't escape %s in printf usage message; it's not written by printf.
llvm-svn: 170413
2012-12-18 05:49:49 +00:00
Kostya Serebryany c8208c5258 [sanitizer] fix a bug that has crept into the sanitizer allocator and caused SEGV on allocations between 1Mb and 2Mb, improve the test
llvm-svn: 170274
2012-12-15 18:36:23 +00:00
Alexey Samsonov 6a68a9117b [Sanitizer] remove extra typename
llvm-svn: 170208
2012-12-14 15:37:35 +00:00
Kostya Serebryany 673c052631 [sanitizer] add AllocatorLeakTest
llvm-svn: 170206
2012-12-14 14:20:29 +00:00
Evgeniy Stepanov fb37510e96 Add MemorySanitizer.cpp to the lint script.
llvm-svn: 170204
2012-12-14 13:48:55 +00:00
Dmitry Vyukov 51b6e07deb tsan: fix lint warning
llvm-svn: 170202
2012-12-14 13:46:03 +00:00
Dmitry Vyukov 5b375d84c0 tsan: fix build
llvm-svn: 170191
2012-12-14 12:24:11 +00:00
Kostya Serebryany 7dfb168eb8 [asan] more asan_allocator2 code: actually un/poison shadow on malloc/free
llvm-svn: 170190
2012-12-14 12:15:09 +00:00
Alexey Samsonov cd1e68ebb1 [Sanitizer] use INTERCEPT_FUNCTION(foo) instead of CHECK(INTERCEPT_FUNCTION(foo)) - this check may fail on Linux if user program defines its own version of library function foo
llvm-svn: 170189
2012-12-14 11:52:02 +00:00
Dmitry Vyukov 34aef74a4d tsan: disable allocator tests in debug build
llvm-svn: 170187
2012-12-14 10:17:22 +00:00
Dmitry Vyukov ed6d54368c tsan: comment out debug output in test
llvm-svn: 170186
2012-12-14 10:12:14 +00:00
Kostya Serebryany bb69879d09 [asan] pop the internal stack frames in SlowUnwindStack, extend the test to check this
llvm-svn: 170124
2012-12-13 12:31:55 +00:00
Alexey Samsonov 506b97d61e [Sanitizer] disable lint check for line length in ASan output tests
llvm-svn: 170123
2012-12-13 12:09:47 +00:00
Kostya Serebryany baf583c443 [asan] add two asan flags: fast_unwind_on_fatal and fast_unwind_on_malloc to allow using the slow CFI-based unwinder
llvm-svn: 170117
2012-12-13 09:34:23 +00:00
Alexey Samsonov 5a26e1fbf2 [Sanitizer] Add new header - sanitizer_platform_interceptors.h, which should define whether or not given function should be intercepted on a given platform.
llvm-svn: 170115
2012-12-13 08:50:16 +00:00
Alexey Samsonov 447e2f2f19 [ASan] one more macro for 'read' interception
llvm-svn: 170114
2012-12-13 08:36:13 +00:00
Alexey Samsonov 65c14f5314 [ASan] more macro for conditional interception of pread functions
llvm-svn: 170112
2012-12-13 08:10:23 +00:00
Kostya Serebryany 07bb3925b0 [sanitizer] replace size_t with SIZE_T in interceptors (same for ssize_t, off_t and off64_t). This is done to avoid confusion and to make the code work with compilers that define size_t w/o any includes (MSVC)
llvm-svn: 170103
2012-12-13 06:31:40 +00:00
Kostya Serebryany a167087571 [asan] fix windows build
llvm-svn: 170101
2012-12-13 05:51:02 +00:00
Kostya Serebryany 9806628792 [sanitizer] introduce MmapFixedOrDie and use it in SizeClassAllocator64
llvm-svn: 170099
2012-12-13 05:36:00 +00:00
Kostya Serebryany eec22a628b [asan] fix the Android build (pread64 interceptor again)
llvm-svn: 170098
2012-12-13 05:27:08 +00:00
Kostya Serebryany 2ce42e0aef [sanitizer] change the way SizeClassAllocator64 allocated memory from the system: instead of one huge mmap(NORESERVE) it does one huge mprotect and then does small on-demand mmaps. This allows us to call OnMap callbacks which are required to poison newly allocated memory in asan
llvm-svn: 170097
2012-12-13 05:05:11 +00:00
Kostya Serebryany e29883c10a [sanitizer] add OnMap/OnUmap callbacks to the allocator interface
llvm-svn: 169985
2012-12-12 14:32:18 +00:00
Alexander Potapenko ada2fbd2d4 [ASan] fix compilation on Mac.
llvm-svn: 169969
2012-12-12 11:52:26 +00:00
Kostya Serebryany 28a32c89e9 [asan] fix android build and lint
llvm-svn: 169968
2012-12-12 11:37:23 +00:00
Kostya Serebryany 9a58d399c7 [asan] add sanitizer_common/sanitizer_common_interceptors.h with pread/pread64/read interceptors. Use it in asan. Add asan tests for pread/etc. Add FIXME to tsan/msan interceptors
llvm-svn: 169966
2012-12-12 09:54:35 +00:00
Kostya Serebryany 90a59fafc0 [asan] more code for asan_allocator2: basic Allocate/Deallocate code
llvm-svn: 169864
2012-12-11 14:41:31 +00:00
Evgeniy Stepanov 83f05bf960 Add MemorySanitizer runtime to check_lint.sh.
llvm-svn: 169861
2012-12-11 12:52:38 +00:00
Kostya Serebryany 5e2a7acdbe [asan] more sceleton code for asan_allocator2
llvm-svn: 169836
2012-12-11 09:02:36 +00:00
Alexander Potapenko 1746f555ee Add a libsanitizer API __sanitizer_sandbox_on_notify(void* reserved), which should be used by
the client programs to notify the tools that sandboxing is about to be turned on.

llvm-svn: 169732
2012-12-10 13:10:40 +00:00
Kostya Serebryany 40bac5b01f [asan] fix lint, remove debug prints
llvm-svn: 169620
2012-12-07 18:07:52 +00:00
Dmitry Vyukov 3a2046b3a6 tsan: fix lint warnings
llvm-svn: 169606
2012-12-07 16:20:06 +00:00
Kostya Serebryany 35f9e5e87b [sanitizer] implement SanitizerSetThreadName/SanitizerGetThreadName. Just for linux so far (using prctl(PR_GET_NAME))
llvm-svn: 169598
2012-12-07 11:27:24 +00:00
Evgeniy Stepanov 5d2d761ad6 Switch to r83 of cpplint.
Ubuntu Precise compatibility.

llvm-svn: 169597
2012-12-07 11:00:14 +00:00
Kostya Serebryany 52a3b92abd [sanitizer] try not to use libc mem* functions in sanitizer_common tests (conflicts with our own interceptors)
llvm-svn: 169595
2012-12-07 10:13:10 +00:00
Kostya Serebryany 378f93e804 [sanitizer] fix the build on ancient gcc which has stricter rules about what can be put on TLS. Long term, we absolutely must build the run-times with the fresh target clang
llvm-svn: 169593
2012-12-07 09:40:17 +00:00
Kostya Serebryany 6986550c7d [sanitizer] POD-ify the allocator cache
llvm-svn: 169514
2012-12-06 16:22:04 +00:00
Dmitry Vyukov e3e0557f19 tsan: fix lint warning and make output tests more robust
llvm-svn: 169511
2012-12-06 15:42:54 +00:00
Kostya Serebryany 6d2d30f61d [asan/msan] one more test for 32-bit allocator + minor code simplification
llvm-svn: 169507
2012-12-06 14:39:41 +00:00
Kostya Serebryany c14ae88b08 [asan/msan] add BulkAllocate to the 32-bit allocator (and a test)
llvm-svn: 169506
2012-12-06 14:27:32 +00:00
Kostya Serebryany 0f67d01031 [asan/msan] refactor allocator's BulkAllocate (move to AllocatorFreeList)
llvm-svn: 169503
2012-12-06 13:34:11 +00:00
Kostya Serebryany 9f84eecc9e [asan/msan] add GetBlockBegin to the 32-bit allocator (+test)
llvm-svn: 169499
2012-12-06 13:13:58 +00:00
Kostya Serebryany 2731cb23b1 [asan/msan] one more test for 32-bit allocator
llvm-svn: 169497
2012-12-06 13:00:11 +00:00
Kostya Serebryany 2044135dca [asan/msan] new 32-bit allocator, basic functionality so far
llvm-svn: 169496
2012-12-06 12:49:28 +00:00
Bill Wendling f9528843d2 Remove unused variable.
llvm-svn: 169485
2012-12-06 07:43:17 +00:00
Kostya Serebryany 1e3d387459 [tsan] add MmapAlignedOrDie
llvm-svn: 169474
2012-12-06 06:10:31 +00:00
Dmitry Vyukov dd95cd148b tsan: fix lint warnings
llvm-svn: 169369
2012-12-05 10:16:02 +00:00
Kostya Serebryany 571232b8cf [tsan] get rid of *allocator64* files, moving everything to *allocator* files. This will help with the 32-bit allocator implementation and testing
llvm-svn: 169368
2012-12-05 10:09:15 +00:00
Kostya Serebryany 0afbb325b6 [tsan] make the 64-bit allocator build (but not work) in 32-bit mode to simplify the code and test structure and allow further refactoring
llvm-svn: 169361
2012-12-05 07:11:47 +00:00
Alexander Potapenko 0a4e0f6d35 Fix a use-after-unmap bug in /proc/self/maps caching. The cached buffer was occasionally deleted in the MemoryMappingLayout destructor.
llvm-svn: 169335
2012-12-04 23:30:00 +00:00
Kostya Serebryany 7436d95c9c [tsan] test the allocator with CompactSizeClassMap
llvm-svn: 169270
2012-12-04 14:39:51 +00:00
Kostya Serebryany f299288f55 [tsan] minor interface refactoring
llvm-svn: 169267
2012-12-04 14:15:17 +00:00
Kostya Serebryany 5e6f833bdd [tsan] refactor the allocator tests to allow testing other flavours of the allocator (add templates)
llvm-svn: 169264
2012-12-04 13:59:22 +00:00
Kostya Serebryany 077f88045e [tsan] refactoring and comment changes in sanitizer_common/sanitizer_allocator{,64}.h. No functionality change
llvm-svn: 169234
2012-12-04 07:54:41 +00:00