Evgeniy Stepanov
0af672326a
[sanitizer] Replace more platform checks with SANITIZER_ constants.
...
llvm-svn: 177400
2013-03-19 14:33:38 +00:00
Evgeniy Stepanov
d3b56605f1
[sanitizer] Move ASan platform macros to sanitizer_common and rename them appropriately.
...
llvm-svn: 177397
2013-03-19 13:54:41 +00:00
Alexey Samsonov
45d2f96582
Don't use --sysroot to linux SDK when building libprofile - SDK on Linux seems to be incomplete.
...
llvm-svn: 177396
2013-03-19 13:34:23 +00:00
Dmitry Vyukov
082afc8346
tsan: fix build
...
llvm-svn: 177395
2013-03-19 13:34:12 +00:00
Dmitry Vyukov
4ecfa696e0
tsan: flush dead thread info earlier (when another thread is finished rather than new thread is created)
...
llvm-svn: 177394
2013-03-19 12:25:48 +00:00
Dmitry Vyukov
9dd06ad47a
tsan: instruct malloc() to consume less memory
...
llvm-svn: 177393
2013-03-19 12:24:19 +00:00
Dmitry Vyukov
f3fde82667
tsan: symbolizer "flush caches" support
...
llvm-svn: 177389
2013-03-19 10:24:01 +00:00
Dmitry Vyukov
29f335ae80
tsan: symbolizer "flush caches" functinality
...
llvm-svn: 177388
2013-03-19 10:23:17 +00:00
Dmitry Vyukov
509dab30ae
tsan: fix memory leak
...
llvm-svn: 177387
2013-03-19 10:22:33 +00:00
Evgeniy Stepanov
6d02c1c598
[sanitizer] Avoid use of uintptr_t.
...
llvm-svn: 177384
2013-03-19 09:39:15 +00:00
Evgeniy Stepanov
b4a218db34
[sanitizer] Don't adjust the size of the user-allocated stack.
...
Moved this code to sanitizer_common.
llvm-svn: 177383
2013-03-19 09:30:52 +00:00
Alexey Samsonov
4c17c1b157
Support CMake build of profile runtime library on Linux
...
llvm-svn: 177382
2013-03-19 09:17:35 +00:00
Dmitry Vyukov
b59fa875ad
tsan: do not allocate sync vars on relaxed atomic operations
...
helps to reduce memory consumption if an atomic is used only with relaxed ops (stats)
llvm-svn: 177381
2013-03-19 09:15:31 +00:00
Richard Smith
807e4dced5
Update ubsan test for clang change r177362.
...
llvm-svn: 177363
2013-03-19 00:04:20 +00:00
Bill Wendling
2428f167f7
Add some GCOV functions that register all of the __llvm_gcov_flush() functions.
...
The __llvm_gcov_flush() functions only work for the local compile unit. However,
when __gcov_flush() is called, the user expects all of the counters to be
flushed, not just the ones in the current compile unit.
This adds some library functions that register the flush functions. It also
defined __gcov_flush() so that loops through that list and calls the functions.
PR15191 & <rdar://problem/13167507>
llvm-svn: 177337
2013-03-18 22:59:47 +00:00
Dmitry Vyukov
4ddd37ba5b
tsan: smaller memory block headers (32b->16b)
...
llvm-svn: 177312
2013-03-18 19:47:36 +00:00
Dmitry Vyukov
61ce9560d4
tsan: add support for idle threads
...
llvm-svn: 177292
2013-03-18 17:21:15 +00:00
Dmitry Vyukov
ce26a0aa92
tsan: touch less shadow memory during operations on big memory ranges
...
greatly reduces memory consumption
llvm-svn: 177289
2013-03-18 16:56:48 +00:00
Dmitry Vyukov
2e7f29f042
tsan: mark shadow for thread stack as "don't need" when thread exits
...
llvm-svn: 177288
2013-03-18 15:49:07 +00:00
Dmitry Vyukov
f123337275
tsan: better memory profiler
...
llvm-svn: 177286
2013-03-18 13:55:33 +00:00
Dmitry Vyukov
15bee188c4
tsan: madvise(DONTNEED) shadow memory on munmap()
...
llvm-svn: 177278
2013-03-18 11:51:51 +00:00
Kostya Serebryany
9138f75d0a
[asan] make the __asan_get_heap_size more robust
...
llvm-svn: 177270
2013-03-18 10:52:25 +00:00
Dmitry Vyukov
20bf8c7778
tsan: move implementation out of h file
...
llvm-svn: 177269
2013-03-18 10:32:21 +00:00
Dmitry Vyukov
49e462fab2
tsan: fix clang -Wall build
...
Clang does not like classes with virtual functions but w/o virtual dtor.
Go does not like libstdc++ (operator delete).
llvm-svn: 177267
2013-03-18 10:10:15 +00:00
Alexey Samsonov
b5d10f69e4
[TSan] re-apply r177249 lost in edits
...
llvm-svn: 177265
2013-03-18 09:45:22 +00:00
Evgeniy Stepanov
6488b2b257
[asan] Switch to allocator2 on Android.
...
llvm-svn: 177263
2013-03-18 09:22:58 +00:00
Dmitry Vyukov
a1bdd2d942
tsan: fix memory leak
...
llvm-svn: 177262
2013-03-18 09:09:41 +00:00
Dmitry Vyukov
7cd2025c4d
tsan: use StackDepot for thread creation stacks
...
llvm-svn: 177261
2013-03-18 09:02:27 +00:00
Dmitry Vyukov
50160030e1
tsan: fix Go build
...
llvm-svn: 177260
2013-03-18 08:52:46 +00:00
Dmitry Vyukov
a221620b2e
tsan: use StackDepot in sync object to store creation stacks
...
llvm-svn: 177258
2013-03-18 08:27:47 +00:00
Dmitry Vyukov
6f7ca81cce
tsan: fix huge stack frames
...
llvm-svn: 177255
2013-03-18 08:09:42 +00:00
Kostya Serebryany
c4722a65a5
[asan] while generating the description of a global variable, emit the module name in a separate field, thus not duplicating this information if every description. This decreases the binary size (observed up to 3%). https://code.google.com/p/address-sanitizer/issues/detail?id=168 . This changes the asan API version. compiler-rt part, llvm-part will follow
...
llvm-svn: 177253
2013-03-18 08:04:55 +00:00
Dmitry Vyukov
0f2c7ea5d0
tsan: fix lint warnings
...
llvm-svn: 177251
2013-03-18 07:58:20 +00:00
Alexey Samsonov
cbed82ea70
[TSan] fix undefined variable in debug TSan build
...
llvm-svn: 177249
2013-03-18 07:33:00 +00:00
Alexey Samsonov
4f1c8a13d5
[TSan] Use ThreadRegistry::FindThreadContextLocked() to find thread by its stack/tls address.
...
llvm-svn: 177248
2013-03-18 07:02:08 +00:00
Alexey Samsonov
e1955b851d
[TSan] Makefiles: allow configurable paths to clang and FileCheck. Add -fno-rtti flag.
...
llvm-svn: 177247
2013-03-18 07:00:36 +00:00
Alexey Samsonov
f9dbbda5bc
[Sanitizer] Get rid of global mutexes in StopTheWorld implementation
...
llvm-svn: 177246
2013-03-18 06:27:13 +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
3a6b6b9d55
[Sanitizer] Don't intercept frexpf and frexpl on Windows. Add frexp declaration to asan_intercepted_functions.h
...
llvm-svn: 177155
2013-03-15 14:02:21 +00:00
Alexey Samsonov
9aecdfe34d
[TSan] Switch TSan runtime to use ThreadRegistry class from sanitizer_common
...
llvm-svn: 177154
2013-03-15 13:48:44 +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
Eric Christopher
d3c993b396
Fix a virtual destructor warning.
...
Patch by Manuel Klimek!
llvm-svn: 177132
2013-03-15 00:20:17 +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
Alexey Samsonov
a097f7b1e3
[Sanitizer] Add default constructor for BlockingMutex
...
llvm-svn: 177072
2013-03-14 13:30:56 +00:00
Evgeniy Stepanov
8d487b4407
[sanitizer] No dirent64 on Android.
...
llvm-svn: 177071
2013-03-14 13:24:03 +00:00
Alexey Samsonov
3d09fdbf21
[Sanitizer] Build sanitizer_common with -fno-rtti
...
llvm-svn: 177070
2013-03-14 13:16:35 +00:00
Kostya Serebryany
d332d42372
[asan] remove one redundant malloc stress test, unify the usage of ASAN_LOW_MEMORY macro in tests, slightly reduce test memory usage (all to make 32-bit runs consume less RAM)
...
llvm-svn: 177069
2013-03-14 13:16:09 +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
Evgeniy Stepanov
740e6ebe71
[msan] Add changes missing from r177065.
...
llvm-svn: 177067
2013-03-14 13:13:49 +00:00
Evgeniy Stepanov
c6bce93591
[msan] Intercept readdir64.
...
llvm-svn: 177065
2013-03-14 12:49:23 +00:00
Alexey Samsonov
1dc928e1b1
[ASan] remove -fsanitize=init-order from lit tests as now it's implied by -fsanitize=address
...
llvm-svn: 177064
2013-03-14 12:43:03 +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
4062a396c7
[msan] Fix a typo in test.
...
llvm-svn: 177059
2013-03-14 11:58:13 +00:00
Alexey Samsonov
963be1ddd8
[ASan] turn off checking initialization order in ASan runtime by default. Instead, it should be turned on by default in the compiler
...
llvm-svn: 177058
2013-03-14 11:49:40 +00:00
Evgeniy Stepanov
fe0199ea54
[msan] Options for switching between fast and cfi unwinders in run time.
...
Does not change default behavior.
llvm-svn: 177057
2013-03-14 11:47:03 +00:00
Evgeniy Stepanov
231894a902
[sanitizer] Intercept frexp and friends.
...
llvm-svn: 177056
2013-03-14 11:34:39 +00:00
Alexey Samsonov
7d2385419a
[Sanitizer] fix compilation for Windows
...
llvm-svn: 177054
2013-03-14 11:29:06 +00:00
Evgeniy Stepanov
ead6cf7c72
[msan] Intercept __strdup, strndup, __strndup.
...
llvm-svn: 177052
2013-03-14 11:10:36 +00:00
Alexey Samsonov
83e7622df6
[Sanitizer] Write a slightly better implementation of GetEnv() function on Windows
...
llvm-svn: 177051
2013-03-14 11:10:23 +00:00
Alexey Samsonov
140cd84155
[ASan] make ASan assume ASAN_OPTIONS=symbolize=1 if ASAN_EXTERNAL_SYMBOLIZER is defined
...
llvm-svn: 177036
2013-03-14 10:07:40 +00:00
Alexey Samsonov
41a560b8cd
[TSan] Add missing header inclusion
...
llvm-svn: 177013
2013-03-14 07:13:00 +00:00
Alexey Samsonov
109ddd0fe4
[TSan] Use __sanitizer_pthread_attr_t in TSan
...
llvm-svn: 177012
2013-03-14 07:10:52 +00:00
Reid Kleckner
2325273641
[msan] Clean up extensions during msandr shutdown
...
Otherwise debug DynamoRIO complains at us for leaking memory.
llvm-svn: 176947
2013-03-13 13:59:09 +00:00
Evgeniy Stepanov
96f82f8ac3
[sanitizer] Fix lint.
...
llvm-svn: 176943
2013-03-13 10:20:35 +00:00
Alexey Samsonov
d7ab381f53
[Sanitizer] Build ASan, TSan and MSan runtimes with -fno-rtti.
...
llvm-svn: 176940
2013-03-13 09:18:30 +00:00
Evgeniy Stepanov
98f5ea0dba
[msan] Increase stack size as required.
...
Adjust stack size in pthread_attr_t when the app-requested size does not fit MSan TLS.
llvm-svn: 176939
2013-03-13 09:01:40 +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
Evgeniy Stepanov
24aad9c0cb
Break a >80 char line.
...
llvm-svn: 176937
2013-03-13 08:17:39 +00:00
Alexey Samsonov
91f833a413
[Sanitizer] Fixup for r176931 for Mac and Windows
...
llvm-svn: 176935
2013-03-13 07:39:25 +00:00
Alexey Samsonov
d38aceda4e
[Sanitizer] Fix a typo in function name
...
llvm-svn: 176932
2013-03-13 06:55:02 +00:00
Alexey Samsonov
06d3aa4884
[Sanitizer] Change MemoryMappingLayout methods to also report memory protection flags (for future use in leak checker). Patch by Sergey Matveev.
...
llvm-svn: 176931
2013-03-13 06:51:02 +00:00
Kostya Serebryany
67b1478914
[asan] use 4Tb of address space for the asan allocator instead of 1Tb. This increases the memory available for a single size class from 16Gb to 64Gb. The total VM footprint becomes 20Tb
...
llvm-svn: 176857
2013-03-12 09:04:49 +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
Evgeniy Stepanov
26d5bc7fdf
[msan] Use sptr instead of ptrdiff_t.
...
llvm-svn: 176854
2013-03-12 07:21:17 +00:00
Kostya Serebryany
ba56c8d4f9
[sanitizer] simplify the allocator's SizeClassMap: do not require an extra template parameter, instead compute it in flight. No functionality change
...
llvm-svn: 176853
2013-03-12 07:01:27 +00:00
Reid Kleckner
c9d382b5a4
[msan] intercept dlopen and clear shadow for it
...
Summary:
The loader does not call mmap() through the PLT because it has to
bootstrap the process before libc is present. Hooking dlopen() isn't
enough either because the loader runs module initializers before
returning, and they could run arbitrary msan instrumented code.
If msandr is present, then we can intercept the mmaps from dlopen at the
syscall layer and clear the shadow there. If msandr is missing, we
clear the shadow after dlopen() and hope any initializers are trivial.
Reviewers: eugenis
CC: kcc, llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D509
llvm-svn: 176818
2013-03-11 18:07:42 +00:00
Alexey Samsonov
db7d9656bb
[Sanitizer] Implement BlockingMutex::CheckLocked()
...
llvm-svn: 176805
2013-03-11 15:45:20 +00:00
Alexander Potapenko
1f78ad5da4
[ASan] Reduce the local buffer size in Report() not to fail the check enforced when building TSan runtime.
...
llvm-svn: 176804
2013-03-11 13:36:39 +00:00
Alexander Potapenko
18c916c6c5
[ASan] Try to use a small (512 bytes) stack-local buffer in Report() for short messages, fall back to MmapOrDie() in the case of a failure.
...
This shall eliminate most of the cryptic "ERROR: failed to mmap" messages caused by recursively calling MmapOrDie() from MmapOrDie().
llvm-svn: 176802
2013-03-11 11:47:43 +00:00
Alexander Potapenko
92cc1a6d24
[ASan] don't call strerr from functions that map memory, since this results in malloc().
...
llvm-svn: 176800
2013-03-11 10:21:28 +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
Nick Lewycky
593eeb000a
Don't emit the extra checksum into the .gcda file if the user hasn't asked for
...
it. Fortunately, versions of gcov that predate the extra checksum also ignore
any extra data, so this isn't a problem. This matches the API change made in
r176745.
llvm-svn: 176746
2013-03-09 01:33:12 +00:00
Nick Lewycky
8015c6ee2f
Take the GCDA version string as an input to llvm_gcda_start_file.
...
llvm-svn: 176618
2013-03-07 08:28:54 +00:00
Reid Kleckner
063dfe3244
[msan] Block reports from interceptors during _Unwind_Backtrace
...
Summary:
I'm hitting a big recursive report from:
uninit on strlen ->
__msan::PrintWarningWithOrigin() ->
__msan::GetStackTrace() ->
__sanitizer::StackTrace::SlowUnwindStack() ->
_Unwind_Backtrace() ->
... libgcc calls ->
uninit on strlen() ->
... repeats
Reviewers: eugenis
Differential Revision: http://llvm-reviews.chandlerc.com/D497
llvm-svn: 176555
2013-03-06 16:11:58 +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
Evgeniy Stepanov
f5d8c90f57
[asan] Revert r176255, r176264.
...
New allocator has 1.5x memory overhead of the old one.
llvm-svn: 176340
2013-03-01 09:33:05 +00:00
Evgeniy Stepanov
323771b3f1
[sanitizer] Fix check failure in SizeClassMap::Print.
...
llvm-svn: 176338
2013-03-01 08:49:14 +00:00
Evgeniy Stepanov
3305b177e6
[asan] Lower memory usage in LargeMallocTest on Android.
...
llvm-svn: 176264
2013-02-28 15:54:58 +00:00
Alexander Potapenko
f1c48eb509
[ASan] Add the memcmp_strict flag (1 by default) that controls the behavior of accessibility checks in memcmp.
...
1: memcmp(p1, p2, n) always checks n bytes
0: memcmp checks up to n bytes depending on whether the memory contents differ.
llvm-svn: 176256
2013-02-28 14:09:30 +00:00
Evgeniy Stepanov
1cb95a17b8
[asan] Enable allocator2 on Android.
...
llvm-svn: 176255
2013-02-28 14:07:01 +00:00
Kostya Serebryany
abebb57272
[asan] bump kMidMemEnd to 0x4fffffffffULL since in rare cases prelink uses addresses higher than 0x3fffffffff
...
llvm-svn: 176250
2013-02-28 12:28:37 +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
Evgeniy Stepanov
218c582cb5
[msan] Lit tests for __attribute__((no_sanitize_memory)).
...
llvm-svn: 176248
2013-02-28 11:25:54 +00:00
Nick Lewycky
1052c99f46
Holy macaroons, somebody made a copy of llvm/runtime/profile/GCDAProfiling.c,
...
didn't delete the original, and now they've diverged. I have no idea what's
going on. Apply my patch in r176173 to this one too, this one looks newer?
llvm-svn: 176236
2013-02-28 07:00:13 +00:00
Kostya Serebryany
8ee2a5adc7
[asan] if calloc returns a freshly-mmaped memory, don't clear it with memset. Speeds up calloc-intensive code
...
llvm-svn: 176185
2013-02-27 13:38:19 +00:00
Alexey Samsonov
49b86b354a
[Sanitizer] don't include missing header on Android
...
llvm-svn: 176183
2013-02-27 13:03:35 +00:00
Alexey Samsonov
46a36d5019
[UBSan] Use common report decorator to print colorful diagnostics in UBSan, and be more consistent w/ Printf/RawWrite
...
llvm-svn: 176182
2013-02-27 12:58:24 +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
Alexey Samsonov
086b940b1e
[Sanitizer] Don't die if external symbolizer is used on Mac, where it's not implemented yet
...
llvm-svn: 176091
2013-02-26 13:40:51 +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
459df6f167
[asan] a bit stricter lint for CHECK vs CHECK_XX (these CHECK_XX really help debugging!)
...
llvm-svn: 176085
2013-02-26 12:59:06 +00:00
Kostya Serebryany
01a32bdef1
[tsan] enable tsan-vs-gvn test since it is now fixed
...
llvm-svn: 176079
2013-02-26 08:18:27 +00:00
Kostya Serebryany
8caf654731
[asan] fix the output for range accesses (memset, etc); improve the tests; more strict checking in memcmp
...
llvm-svn: 176078
2013-02-26 07:25:18 +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
Alexey Samsonov
85f0a7e644
[TSan] Add interceptor for malloc_usable_size()
...
llvm-svn: 176013
2013-02-25 08:43:10 +00:00
Alexey Samsonov
10bccda948
[TSan] remove temporary build directory in 'make clean' command
...
llvm-svn: 176012
2013-02-25 08:32:02 +00:00
Richard Smith
0404ec8396
ubsan: Runtime handlers for array indexing checks.
...
llvm-svn: 175948
2013-02-23 02:40:07 +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
3065014026
[msan] MSanDR: initial commit.
...
MSanDR is a DynamoRio-based tool that handles uninstrumented libraries and
dynamically generated code for MSan.
llvm-svn: 175883
2013-02-22 09:34:19 +00:00
Kostya Serebryany
1d63d13ce2
[asan] move the .preinit_array hack into a separate file (added used attribute)
...
llvm-svn: 175871
2013-02-22 07:51:26 +00:00
Alexander Potapenko
97781c4dd0
[ASan] temporarily disable alloc_dealloc_mismatch on Mac, since the previous commit caused error reports in gTest.
...
llvm-svn: 175766
2013-02-21 17:12:21 +00:00
Alexander Potapenko
a47c6ee286
[ASan] Make sure operator new/delete and friends are intercepted on OS X.
...
Because the interceptors will reside in a dylib, not the main executable, we can't just declare them,
but must use the interposition machinery.
Fix the test expectations in large_func_test.cc affected by the change.
This CL should make our Mac buildbots green.
llvm-svn: 175763
2013-02-21 16:54:09 +00:00
Alexander Potapenko
1615f193eb
[ASan] Declare CreateThread as extern "C" to fix the Windows build.
...
llvm-svn: 175760
2013-02-21 15:32:50 +00:00
Alexander Potapenko
8dbcb98c52
[ASan] Revert the incorrect macro on Linux.
...
llvm-svn: 175745
2013-02-21 15:15:43 +00:00
Alexander Potapenko
b8135a8a6b
[ASan] Put several function prototypes back under #ifdef _WIN32 to fix the Windows build.
...
llvm-svn: 175743
2013-02-21 15:10:03 +00:00
Alexander Potapenko
e8ba1c851a
[ASan] Refactoring: nuke the redundant function declarations in asan_intercepted_functions.h
...
that had been used on OS X only.
The INTERCEPTOR() macro on OS X is now responsible for declaring the wrapped function, the wrapper and the
pair of pointers to them in __DATA,__interposition section. Thus adding an interceptor requires editing a single file now.
llvm-svn: 175740
2013-02-21 14:41:16 +00:00
Evgeniy Stepanov
57d6f737e6
[sanitizer] Add MSan to Makefile-based build rules.
...
llvm-svn: 175737
2013-02-21 13:55:54 +00:00
Kostya Serebryany
ab5be26af5
[asan] speedup by more than 2x handling of the small memset/memcpy/etc calls
...
llvm-svn: 175728
2013-02-21 07:07:39 +00:00
Reid Kleckner
15f2d1f4be
[Sanitizer] Try to fix infinite loop in frame pointer unwinder
...
Using > instead of >= ensures that each frame deref makes progress and
that we eventually terminate.
Issue: https://code.google.com/p/address-sanitizer/issues/detail?id=162
llvm-svn: 175661
2013-02-20 20:29:48 +00:00
Alexey Samsonov
7dc2b2f07d
[ASan] revert part of r175631 that looks like accidental commit
...
llvm-svn: 175655
2013-02-20 19:55:47 +00:00
Alexander Potapenko
70b01558f1
[ASan] Delete asan/dynamic dir and temporarily move the interposers declarations to asan_intercepted_functions.h
...
Now that we have only one dependency on asan_intercepted_functions.h, we can unite that code with the interceptors declarations in asan_interceptors.cc and get rid of asan_intercepted_functions.h
llvm-svn: 175631
2013-02-20 15:46:02 +00:00
Alexander Potapenko
56821acc79
[ASan] Make isoc99_*scanf intercepted on Linux only. Those are unavailable on Darwin.
...
llvm-svn: 175629
2013-02-20 15:27:58 +00:00
Kostya Serebryany
7b989859a8
[asan] move preinit_test to Linux since on Mac __asan_init is called from ld-preload-ed runtime
...
llvm-svn: 175625
2013-02-20 15:10:22 +00:00
Kostya Serebryany
d8c29210e5
[asan] on linux, run __asan_init from .preinit_array (even earlier than before)
...
llvm-svn: 175623
2013-02-20 14:28:08 +00:00
Alexey Samsonov
aadd1f2ad6
[Sanitizer] use raw syscall instead of _exit() function on Linux
...
llvm-svn: 175622
2013-02-20 13:54:32 +00:00
Kostya Serebryany
ac05bc0556
[asan] add a lit test for invoke-with-no-return instrumentation
...
llvm-svn: 175618
2013-02-20 12:37:22 +00:00
Evgeniy Stepanov
ec1d286111
[sanitizer] Fix lint.
...
llvm-svn: 175615
2013-02-20 11:06:07 +00:00
Kostya Serebryany
8381ef2035
[asan] add test throw_call_test (broken with -static-libstdc++)
...
llvm-svn: 175614
2013-02-20 10:43:05 +00:00
Evgeniy Stepanov
2e50efd484
[sanitizer] Fix FileOps test on Android.
...
llvm-svn: 175515
2013-02-19 15:01:05 +00:00
Kostya Serebryany
96401c9da9
[asan] don't run the long double test if long double is the same as double
...
llvm-svn: 175514
2013-02-19 13:43:44 +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
0b07c63e07
[ASan] Allow ASan default runtime options be overriden at compile time by providing ASAN_DEFAULT_OPTIONS macro
...
llvm-svn: 175512
2013-02-19 13:14:48 +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
Evgeniy Stepanov
76dc3a81ea
[msan] Use slow stack unwinder in UMR reports.
...
llvm-svn: 175510
2013-02-19 12:43:18 +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
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
Kostya Serebryany
3e62fe8c23
[tsan] use our own GetEnv instead of libc's getenv
...
llvm-svn: 175498
2013-02-19 08:19:13 +00:00
Kostya Serebryany
776f3bba96
[asan] enable asan_prelink_test when gold is the default linker (gold and bfd linker have different flag syntax)
...
llvm-svn: 175431
2013-02-18 08:37:49 +00:00
Kostya Serebryany
15e9c852c0
[asan] added flag -d|--demangle to asan_symbolize.py, makes addr2line/llvm-symbolizer demangle the functions names
...
llvm-svn: 175429
2013-02-18 08:02: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
Alexey Samsonov
4544d1fa3d
[ASan] make variables unsigned to silence warnings - attempt 2
...
llvm-svn: 175285
2013-02-15 19:22:49 +00:00
Alexey Samsonov
f6d7379def
[ASan] make variable unsigned to silence the warning
...
llvm-svn: 175284
2013-02-15 19:02:32 +00:00
Alexander Potapenko
3182c3e441
[ASan] Fix https://code.google.com/p/address-sanitizer/issues/detail?id=159
...
MaybeReexec() does now a tricky job to manage DYLD_INSERT_LIBRARIES in a safe way.
Because we're using library interposition, it's critical for an instrumented app
to be executed with the runtime library present in DYLD_INSERT_LIBRARIES list.
Therefore if it's initially missing in that list, we append the runtime library name
to the value of DYLD_INSERT_LIBRARIES and then exec() ourselves.
On the other hand, some of the apps exec()ed by our program may not want to have
ASan runtime library preloaded, so we remove the runtime library from the
DYLD_INSERT_LIBRARIES if it's already there.
Users may want to preload other libraries using DYLD_INSERT_LIBRARIES, so we preserve those.
llvm-svn: 175276
2013-02-15 16:10:49 +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
Alexander Potapenko
594d99588b
[ASan] Fixed the wrong placement of #include
...
llvm-svn: 175157
2013-02-14 12:37:17 +00:00
Alexander Potapenko
6ad3589964
[ASan] Remove the 'alarm' script which isn't present on OS X by default.
...
The test may hang now if a regression occurs.
llvm-svn: 175155
2013-02-14 12:18:07 +00:00
Dmitry Vyukov
965a10e07c
tsan: fix bug in suppression reading (suppressions from file were discarded)
...
llvm-svn: 175153
2013-02-14 11:03:45 +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
Kostya Serebryany
dd0ab08b6e
[asan] use short path for sanitizer_common/tests/sanitizer_test_utils.h, add -I sanitizer_common/tests to asan/tests/CMakeLists.txt
...
llvm-svn: 175142
2013-02-14 08:12:26 +00:00
Kostya Serebryany
039fa75e4d
[asan] fix x32 build (H.J. Lu)
...
llvm-svn: 175140
2013-02-14 08:05:55 +00:00
Kostya Serebryany
aa7f2b5aa6
[tsan] disable a failing test until it gets fixed. fix lint
...
llvm-svn: 175137
2013-02-14 06:54:51 +00:00
Richard Smith
6d9f13127c
ubsan: Add checking for invalid downcasts. Per [expr.static.cast]p2 and p11,
...
base-to-derived casts have undefined behavior if the object is not actually an
instance of the derived type. Runtime library part.
llvm-svn: 175079
2013-02-13 21:18:23 +00:00
Alexander Potapenko
c5ba5ef3c5
[ASan] When re-executing the process on OS X, make sure we update the existing DYLD_INSERT_LIBRARIES correctly.
...
Previously ASan used to hang in an exec loop, because it failed to overwrite the env var value
(see https://code.google.com/p/address-sanitizer/issues/detail?id=159 ).
llvm-svn: 175059
2013-02-13 17:52:55 +00:00
Dmitry Vyukov
3c2489e2c3
tsan: do not imitate memory write on malloc() (Go)
...
better memory range access functions (put only 1 event to trace) (Go)
llvm-svn: 175056
2013-02-13 13:05:36 +00:00
Kostya Serebryany
32214a2587
[asan] fix fixed mapping for mac (ASAN_FLEXIBLE_MAPPING_AND_OFFSET=0)
...
llvm-svn: 175049
2013-02-13 10:15:03 +00:00
Kostya Serebryany
ec87e785a3
[msan] don't check shadow inside interceptors if we are inside symbolizer; add weak function __msan_default_options that overrides default options
...
llvm-svn: 175040
2013-02-13 07:19:47 +00:00
Kostya Serebryany
4681fbf002
[tsan] simplify tsan-vs-gvn test since gvn vs tsan is now fixed; fix lint
...
llvm-svn: 175037
2013-02-13 06:07:50 +00:00
Richard Smith
60261eadbd
Highlight caret in bold green, to match Clang diagnostics.
...
llvm-svn: 175013
2013-02-12 22:12:10 +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
e676f66fe3
[msan] Allow zero buf pointer in getcwd() interceptor.
...
llvm-svn: 174970
2013-02-12 14:36:22 +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
a73704c0f8
[asan] Add new __isoc99_*scanf to ASan intercepted functions list.
...
llvm-svn: 174965
2013-02-12 12:45:29 +00:00
Evgeniy Stepanov
d8cfb99a71
[sanitizer] Missing changes from r174960.
...
llvm-svn: 174962
2013-02-12 12:02:49 +00:00
Evgeniy Stepanov
5fa8fb7d91
[sanitizer] Intercept __isoc99_*scanf.
...
llvm-svn: 174960
2013-02-12 11:34:52 +00:00
Kostya Serebryany
2659e96e4b
[asan] change the default mapping offset on x86_64 to 0x7fff8000. This gives roughly 5% speedup. Since this is an ABI change, bump the asan ABI version by renaming __asan_init to __asan_init_v1. compiler-rt part
...
llvm-svn: 174958
2013-02-12 11:11:58 +00:00
Alexey Samsonov
93686fc6f1
[MSan] symbolize correct PC when printing Summary message
...
llvm-svn: 174956
2013-02-12 10:46:39 +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
257274e754
[msan] Lit tests for MemorySanitizer.
...
Build system setup for MSan lit tests (build with freshly-built clang, run,
check output) - a nearly exact copy from ASan.
First 2 lit tests for MSan.
llvm-svn: 174876
2013-02-11 11:34:26 +00:00
Kostya Serebryany
53e37ef74f
[tsan] added tsan-vs-gvn test
...
llvm-svn: 174875
2013-02-11 11:28:03 +00:00
Evgeniy Stepanov
9f9d79f3ad
[sanitizer] Fix line numbers in a sanitizer lit test.
...
llvm-svn: 174861
2013-02-11 07:19:24 +00:00
Evgeniy Stepanov
0b805cc75c
[asan] Fix off-by-one in AddrIsAtRight.
...
llvm-svn: 174710
2013-02-08 12:59:42 +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
Dmitry Vyukov
e679798315
tsan: fix suppress_java logic
...
llvm-svn: 174635
2013-02-07 17:12:28 +00:00
Alexander Potapenko
c192af29f5
[ASan] Remove the replace_cfallocator flag, which is used no more.
...
See https://code.google.com/p/address-sanitizer/issues/detail?id=10 for the context.
llvm-svn: 174629
2013-02-07 15:59:37 +00:00
Alexander Potapenko
dc91edad59
[ASan] Enable alloc_dealloc_mismatch by default on Darwin.
...
Enable AddressSanitizer.AllocDeallocMismatch tests.
llvm-svn: 174628
2013-02-07 15:55:21 +00:00
Alexander Potapenko
4fb43438d9
[ASan] Enable the new and delete wrappers on Darwin.
...
Also fix large_func_test.cc, which got broken when we switched to allocator2: the OOB access was too far from the original allocation, so ASan decided to describe the next one.
llvm-svn: 174626
2013-02-07 15:33:56 +00:00
Dmitry Vyukov
effd98b0f4
tsan: intercept libc __res_iclose
...
this is required to catch close of file descriptors created in getaddrinfo()
llvm-svn: 174624
2013-02-07 15:27:45 +00:00
Dmitry Vyukov
e94f4c048e
tsan: fix Go build
...
llvm-svn: 174622
2013-02-07 15:26:55 +00:00