Commit Graph

121 Commits

Author SHA1 Message Date
Alexey Samsonov 020ac94665 [ASan] Force the compiler to generate frame pointer in certain Mac-specific interceptors.
Patch by Kuba Brecka!

llvm-svn: 212664
2014-07-10 00:06:53 +00:00
Alexey Samsonov 56b6ee9833 [ASan] Optional support for dynamic ASan runtime on Linux.
Based on http://llvm-reviews.chandlerc.com/D3042 by Yuri Gribov!

llvm-svn: 205308
2014-04-01 13:16:30 +00:00
Alexander Potapenko 4672bacaef [ASan] Get rid of asan_mac.h, which contents have been moved to sanitizer_mac.h
llvm-svn: 200757
2014-02-04 11:35:59 +00:00
Alexander Potapenko 768e315a74 [ASan] Move GetMacosVersion() to sanitizer_common.
llvm-svn: 200700
2014-02-03 15:32:19 +00:00
Alexander Potapenko cf4bef3161 [ASan] Move the signal handling-related flags to sanitizer_common.
This change is a part of refactoring intended to have common signal handling behavior in all tools.

llvm-svn: 200295
2014-01-28 09:28:57 +00:00
Alexander Potapenko c87794d055 [ASan] Delete asan_intercepted_functions.h, move the code into asan_interceptors.h
Fixes https://code.google.com/p/address-sanitizer/issues/detail?id=188.

llvm-svn: 198048
2013-12-26 15:34:31 +00:00
Sergey Matveev 9be70fbda9 [sanitizer] Introduce VReport and VPrintf macros and use them in sanitizer code.
Instead of "if (common_flags()->verbosity) Report(...)" we now have macros.

llvm-svn: 196497
2013-12-05 12:04:51 +00:00
Dmitry Vyukov 52ca74ec61 tsan: move verbosity flag to CommonFlags
llvm-svn: 192701
2013-10-15 13:28:51 +00:00
Alexander Potapenko 27155281db [ASan] Cache the OSX version to avoid calling sysctl() on every GetMacosVersion() call.
llvm-svn: 186389
2013-07-16 09:29:48 +00:00
Alexander Potapenko b137ca157b [ASan] Add support for OS X Mavericks to GetMacosVersion.
llvm-svn: 186386
2013-07-16 08:35:42 +00:00
Sergey Matveev af179b8d63 [sanitizer] Move GetStackTrace from ASan to sanitizer_common.
llvm-svn: 181424
2013-05-08 12:45:55 +00:00
Kostya Serebryany 5b4267f7e7 [sanitizer] found a bug by code inspection: CHECK(a=b) instead of CHECK(a==b). Was puzzled why lint did not catch it. Turns out this check was disabled for asan source. fix all cases and enable the check
llvm-svn: 178872
2013-04-05 14:40:25 +00:00
Alexey Samsonov 21cb74318c [ASan] Kill the remainders of platform defines in favor of SANITIZER_ defines
llvm-svn: 178629
2013-04-03 07:29:53 +00:00
Timur Iskhodzhanov 07d06d7cf5 Remove all 'static' before ALWAYS_INLINE
llvm-svn: 178290
2013-03-28 21:16:09 +00:00
Alexey Samsonov 54afba8b62 [ASan] Switch ASan to generic ThreadRegistry from sanitizer_common. Delete ASan-specific AsanThreadRegistry.
llvm-svn: 177634
2013-03-21 11:23:41 +00:00
Alexey Samsonov 920b3b9a0c [ASan] Move malloc stats collection away from AsanThreadRegistry class.
llvm-svn: 177508
2013-03-20 10:11:24 +00:00
Evgeniy Stepanov 95eaa21637 [sanitizer] More renamed macros.
llvm-svn: 177401
2013-03-19 14:54:17 +00:00
Evgeniy Stepanov 0af672326a [sanitizer] Replace more platform checks with SANITIZER_ constants.
llvm-svn: 177400
2013-03-19 14:33:38 +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
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 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 aa7f2b5aa6 [tsan] disable a failing test until it gets fixed. fix lint
llvm-svn: 175137
2013-02-14 06:54:51 +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
Alexander Potapenko 34157fc33f [ASan] Delete the code related to static runtime on OS X.
Nuke lib/interception/mach_override.

llvm-svn: 174383
2013-02-05 15:57:12 +00:00
Alexander Potapenko dc00c44d46 [ASan] Remove the declarations of pthread_workqueue_t and pthread_workitem_handle_t, which are used no more.
Kudos to Jeremy Huddleston Sequoia <jeremyhu@apple.com>

llvm-svn: 173143
2013-01-22 10:32:06 +00:00
Alexander Potapenko cae42d23a6 [ASan] Use dylib interposition to hook memory allocation in the dynamic runtime.
This CL drastically simplifies the way we're hooking the memory allocation routines in ASan on Mac by using dylib interposition to replace the main malloc_zone_* functions. This allows us to avoid replacing the default CFAllocator and drop the CF dependency at all.

Committing this patch will result in the static runtime being broken. A follow-up CL will switch ASan to use the dynamic runtime library.

llvm-svn: 173134
2013-01-22 09:14:54 +00:00
Alexander Potapenko 51794a390f Remove references to pthread_workqueue_additem_np(), which isn't in the official libdispatch API.
llvm-svn: 172802
2013-01-18 10:27:31 +00:00
Alexey Samsonov 4f1885a109 [ASan] minor changes to swapcontext handling: don't clear shadow memory if context stack is too large
llvm-svn: 172727
2013-01-17 15:45:28 +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
Kostya Serebryany 3674c6b13b [asan] add a flag alloc_dealloc_mismatch (off by default for now) which finds malloc/delete, new/free, new/delete[], etc mismatches
llvm-svn: 170869
2012-12-21 08:53:59 +00:00
Kostya Serebryany 060bfab568 [asan] fix win build
llvm-svn: 170119
2012-12-13 10:03:50 +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
Alexander Potapenko 0dcd6d9468 [ASan] Do not build the interceptors that use ObjC blocks if the compiler does not support blocks.
Need to define MISSING_BLOCKS_SUPPORT in this case at buildtime.

Patch by Jack Howarth <howarth@bromo.med.uc.edu>
 

llvm-svn: 169206
2012-12-04 02:41:47 +00:00
Kostya Serebryany df198db1aa [asan/tsan] get rid of kPageSize completely in favor of GetPageSizeCached(). This makes the code friendly to more platforms
llvm-svn: 168537
2012-11-24 05:03:11 +00:00
Alexey Samsonov aac36b345a [ASan] intercept swapcontext on Linux only
llvm-svn: 168509
2012-11-23 10:14:44 +00:00
Kostya Serebryany 734f1eb5f4 [asan/tsan] do not use __WORDSIZE macro, as it is glibc-private thing. Instead, define our own SANITIZER_WORDSIZE
llvm-svn: 168424
2012-11-21 12:38:58 +00:00
Alexander Potapenko 1eef2b813c [ASan] Rename ReplaceCFAllocator to MaybeReplaceCFAllocator.
Replace the allocator only if the replace_cfallocator flag is set (in some cases it wasn't checked)

llvm-svn: 166550
2012-10-24 09:35:23 +00:00
Alexander Potapenko e3e80d607f Do not call ReplaceCFAllocator() before __CFInitialize(), otherwise crashes are possible on 10.8.
Fixes http://code.google.com/p/address-sanitizer/issues/detail?id=122

llvm-svn: 166029
2012-10-16 16:58:10 +00:00
Alexander Potapenko 4a78e1002d Add MACOS_VERSION_MOUNTAIN_LION.
llvm-svn: 166026
2012-10-16 16:24:49 +00:00
Alexey Samsonov 4787d0fbef [ASan] more macro/casting magic to suppress warnings
llvm-svn: 163706
2012-09-12 14:10:14 +00:00
Alexander Potapenko 3ecf916c33 Use the return value of dladdr() to avoid Clang warning.
llvm-svn: 163311
2012-09-06 12:18:45 +00:00
Kostya Serebryany ee92877f17 [asan] more refactoring to move StackTrace to sanitizer_common
llvm-svn: 162752
2012-08-28 13:25:55 +00:00
Kostya Serebryany 6b0d775229 [asan] some renaming before we move StackTrace into sanitizer_common
llvm-svn: 162747
2012-08-28 11:54:30 +00:00
Alexander Potapenko fefc1e989c If the program is linked to a dynamic ASan runtime which is not present in DYLD_INSERT_LIBRARIES
(which, in turn, is required for our interceptors to take effect), re-exec the program with
DYLD_INSERT_LIBRARIES set.

llvm-svn: 162547
2012-08-24 09:22:05 +00:00
Alexander Potapenko 2ebe619340 Re-implement the wrappers for libdispatch functions using blocks where appropriate
(kudos to Anna Zaks for a good example).
This simplifies the code much and lets us not implement internal parts of libdispatch.

All ASan tests from t32 and t64 should pass with the dylib runtime now.

llvm-svn: 162439
2012-08-23 09:34:40 +00:00
Kostya Serebryany 6b745b5281 [asan] fix lint
llvm-svn: 162258
2012-08-21 06:43:44 +00:00
Alexander Potapenko 02e6f03236 Dynamic interceptors for dispatch_async and dispatch_after.
llvm-svn: 162202
2012-08-20 11:59:26 +00:00
Alexander Potapenko 1233d558dc Minor refactoring: reduce code duplication by introducing a macro for dispatch_sync_f, dispatch_async_f, dispatch_barrier_async_f bodies.
llvm-svn: 162199
2012-08-20 09:25:10 +00:00