Commit Graph

1045 Commits

Author SHA1 Message Date
Evgeniy Stepanov f72f08affc CMake build rules for ASan/Android runtime.
llvm-svn: 162675
2012-08-27 14:28:27 +00:00
Alexey Samsonov 28d8be2d86 [Sanitizer] One more try to fix Windows build
llvm-svn: 162674
2012-08-27 14:08:53 +00:00
Alexey Samsonov e67a5dd8e1 [Sanitizer] Use low-level allocator in flag parsing to avoid calling malloc() before ASan/TSan initialization is done
llvm-svn: 162673
2012-08-27 14:04:54 +00:00
Alexey Samsonov cc62211fbf [Sanitizer] Rename ProcessMaps to MemoryMappingLayout and fix Windows build by providing stub implementation
llvm-svn: 162671
2012-08-27 13:48:48 +00:00
Alexey Samsonov c74289db2b [ASan] add missing build dependency on sanitizer_common headers
llvm-svn: 162670
2012-08-27 13:47:28 +00:00
Evgeniy Stepanov be01398612 A few tweaks for building ASanRT against Android NDK.
llvm-svn: 162666
2012-08-27 11:15:55 +00:00
Alexey Samsonov dc8d1f1039 [Sanitizer] move low-level (mmap-based) allocator to sanitizer_common
llvm-svn: 162663
2012-08-27 09:30:58 +00:00
Dmitry Vyukov 7d3d94454c tsan: improve memory allocator a bit
llvm-svn: 162561
2012-08-24 15:53:14 +00:00
Alexander Potapenko 00492cab3e Revert the erroneous changes made to Makefile.old in r162547
Remove a spare newline from asan_rtl.cc

llvm-svn: 162548
2012-08-24 09:31:53 +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 d79d80b4a0 Add add_clang_runtime_shared_library() CMake function and use it to put the shared ASan runtime in the appropriate place.
llvm-svn: 162546
2012-08-24 07:49:22 +00:00
Dmitry Vyukov 0481ae4722 tsan: allow to override per-thread event trace size
useful if you don't see the second stack trace

llvm-svn: 162456
2012-08-23 18:26:03 +00:00
Dmitry Vyukov 7e6347402d tsan: fix new memory allocator
Deallocate: drain blocks to central cache if cached too much (instead of never drain).
Allocate: batch allocate fixed amount of blocks (instead of all blocks).
This significantly reduces memory consumption of large heavy-multithreaded programs.

llvm-svn: 162447
2012-08-23 17:16:07 +00:00
Alexey Samsonov 563fb4113c [Sanitizer] Add external symbolizer binary. Next steps - include it in CMake build (produce 32-bit and 64-bit version of it, make sure we can compile LLVM sources with our own flags) and add tests for it.
llvm-svn: 162442
2012-08-23 12:39:35 +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
Alexey Samsonov 419f610a74 [Sanitizer] Switch the symbolization strategy that would be used by sanitizer tools family: as compiling in-process symbolizer into runtime involves certain difficulties, we may instead launch an external symbolizer program (fork + execl) in a subprocess and communicate with it via pipe.
llvm-svn: 162437
2012-08-23 07:32:06 +00:00
Alexey Samsonov 4d520640ba [ASan] use write instead of puts in malloc hooks test for ASan, as puts calls malloc on Mac
llvm-svn: 162359
2012-08-22 13:32:37 +00:00
Alexey Samsonov a85b6b8154 [ASan] get rid of ASAN_USE_EXTERNAL_SYMBOLIZER compiler def in favor of __asan_set_symbolize_callback interface function. Now the user doesn't have to recompile ASan runtime to provide its own symbolizer
llvm-svn: 162358
2012-08-22 13:31:37 +00:00
Alexey Samsonov de17f86655 [ASan] make ASan malloc/free hooks weak interface functions, overridable by user. Now the user can control malloc/free hooks without recompiling ASan runtime
llvm-svn: 162355
2012-08-22 10:12:47 +00:00
Alexey Samsonov 9b4e440c44 [ASan] fix CMake build: make sure that all ASan runtimes are built at correct directory
llvm-svn: 162353
2012-08-22 09:19:32 +00:00
Alexey Samsonov 75e5fc3e57 [TSan] switch tsan to using InternalScopedBuffer from sanitizer_common
llvm-svn: 162351
2012-08-22 07:25:52 +00:00
Kostya Serebryany 68d9c9da40 [asan] fix mac build
llvm-svn: 162279
2012-08-21 14:43:36 +00:00
Kostya Serebryany 676bcdb838 [asan] run-time part of the initialization order checker. Patch by Reid Watson with some bits from kcc. The sub-pass is off by default for now. On simple tests it works fine.
llvm-svn: 162278
2012-08-21 14:10:25 +00:00
Alexey Samsonov b92488a549 [Sanitizer] implement internal_strcspn
llvm-svn: 162272
2012-08-21 09:26:26 +00:00
Kostya Serebryany 55b4dd314f [asan] update asan-rt to match the interface change in LLVm (r162268)
llvm-svn: 162269
2012-08-21 08:24:35 +00:00
Alexey Samsonov e6704ee109 [Sanitizer] define InternalScopedBuffer to replace large arrays on stack. It is defined analogous to similar class in tsan and should replace it.
llvm-svn: 162262
2012-08-21 08:13:37 +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
Alexander Potapenko 4a156c1b80 Fix a leftover #if defined(DYNAMIC_MAC_WRAPPERS).
llvm-svn: 162197
2012-08-20 08:49:49 +00:00
Dmitry Vyukov e59bed4e8a tsan: proper handling of linker initialized mutexes
llvm-svn: 162169
2012-08-18 11:49:00 +00:00
Dmitry Vyukov e2b5b5c4ac tsan: Non-executable stack for hand-coded assembly
llvm-svn: 162112
2012-08-17 18:05:28 +00:00
Alexander Potapenko dffbb3b330 Intercept siglongjmp and _longjmp under "#if ASAN_INTERCEPT_*"
llvm-svn: 162103
2012-08-17 16:27:38 +00:00
Alexander Potapenko 5f487de8a3 Fix lint warnings.
llvm-svn: 162092
2012-08-17 10:08:51 +00:00
Alexander Potapenko c62210e3ff Commit the source and CMake changes that will allow to build ASan runtime
as a shared library on Mac OS. This will provide an alternative to
mach_override.

llvm-svn: 162091
2012-08-17 09:00:08 +00:00
Dmitry Vyukov 9f143c5c5f tsan: improve Go report format + fix build
llvm-svn: 162042
2012-08-16 19:36:45 +00:00
Dmitry Vyukov 77196efb1e tsan: add flag to disable reporting of destruction of locked mutexes (some programs use that on a regular basis)
llvm-svn: 162024
2012-08-16 15:12:35 +00:00
Dmitry Vyukov 3482ec3bc8 tsan: better diagnostics for destroy of a locked mutex + a test
llvm-svn: 162022
2012-08-16 15:08:49 +00:00
Dmitry Vyukov 19ae9f3b2e tsan: support for linker initializer mutexes with static storage duration
llvm-svn: 162021
2012-08-16 14:21:09 +00:00
Dmitry Vyukov 5c45dab649 tsan: fix COMPAT shadow mapping once again
llvm-svn: 162020
2012-08-16 14:20:45 +00:00
Dmitry Vyukov 4723e6b1e5 tsan: implement RWLOCK annotations
llvm-svn: 162019
2012-08-16 13:29:41 +00:00
Dmitry Vyukov f77c6ea7ea tsan: fix COMPAT shadow mapping for new memory allocator
llvm-svn: 162018
2012-08-16 13:27:25 +00:00
Dmitry Vyukov 912f3bf279 tsan: refactor cur_thread() -> thr
llvm-svn: 162017
2012-08-16 13:26:54 +00:00
Dmitry Vyukov 1c0b3c6b84 tsan: store sync objects in memory block headers + delete them when the block is freed
llvm-svn: 161959
2012-08-15 17:27:20 +00:00
Dmitry Vyukov 9f1509fe44 tsan: provide function that imitates write to a region but does not detect races
llvm-svn: 161957
2012-08-15 16:52:19 +00:00
Alexander Potapenko cfb2a6b074 Remove the extra semicolon reported by the buildbot.
llvm-svn: 161954
2012-08-15 15:59:18 +00:00
Dmitry Vyukov 954fc8c3e4 tsan: switch to new allocator
llvm-svn: 161953
2012-08-15 15:35:15 +00:00
Alexander Potapenko f6344ffe39 Introduce asan_intercepted_functions.h which contains the declarations wrapped functions and their wrappers.
Those declarations are going to be shared between asan_interceptors.cc and the dynamic runtime library on Mac OS.

llvm-svn: 161952
2012-08-15 15:24:48 +00:00
Alexey Samsonov 5b2c6ea38f [ASan] lit tests: use nm instead of llvm-nm, until llvm-nm becomes usable on Mac. Port output test change in r161948 to lit
llvm-svn: 161951
2012-08-15 14:33:30 +00:00
Dmitry Vyukov 4b5ec3145a tsan: add some more tests for memory allocator
llvm-svn: 161950
2012-08-15 14:25:33 +00:00
Dmitry Vyukov c693689bb1 tsan: fix several integer overflows
llvm-svn: 161949
2012-08-15 14:25:08 +00:00
Alexander Potapenko 6c1de8faa7 Check for filenames and numbers to detect possible problems with asan_symbolize.py on -fPIE binaries.
llvm-svn: 161948
2012-08-15 14:00:09 +00:00
Alexander Potapenko 1800362758 Pass offset of the frame address within the binary to addr2line instead of the absolute address.
Fixes the problem with -PIE binaries.

llvm-svn: 161947
2012-08-15 13:58:24 +00:00
Alexander Potapenko 07ea07c3ca Patch the frame address regardless of the frame number.
llvm-svn: 161946
2012-08-15 13:23:03 +00:00
Alexander Potapenko 20f9fcc285 Move the prototype of __CFInitialize to asan_mac.h so that asan_malloc_mac.cc may use it in the dynamic library mode.
llvm-svn: 161945
2012-08-15 12:23:36 +00:00
Alexander Potapenko 9a168a7405 Use SANITIZER_INTERFACE_ATTRIBUTE instead of __attribute__((visibility("default")))
Export CheckFailed, asan_malloc, asan_free, asan_memalign, AsanStackTrace::CompressStack, AsanStackTrace::UncompressStack from the dynamic runtime library.

llvm-svn: 161943
2012-08-15 11:57:52 +00:00
Alexander Potapenko 55df945db2 Make __asan::asan_{malloc,free,memalign} globally visible, so that the dynamic version of the runtime will export them.
llvm-svn: 161942
2012-08-15 11:32:15 +00:00
Alexey Samsonov 9fe914b099 [ASan] Port (the last one) tricky interface_test to lit, and a *huge* chunks of boilerplate to run tests for 32/64 bits and all optimization levels. Alas, lit doesn't support for loops in RUN-lines...
llvm-svn: 161941
2012-08-15 11:26:57 +00:00
Alexander Potapenko 81a1ec8ea6 Do not attempt to intercept mlock and friends on Windows.
llvm-svn: 161939
2012-08-15 09:46:45 +00:00
Alexander Potapenko 785f8bc4ec Use the common interception machinery for mlock/munlock/mlockall/munlockall.
llvm-svn: 161938
2012-08-15 09:22:57 +00:00
Alexey Samsonov 0e056762ef [ASan] use clangxx_asan instead of clang_asan for C++ lit tests
llvm-svn: 161936
2012-08-15 08:54:14 +00:00
Alexey Samsonov 6016486a16 [ASan] port remaining output and feature tests to lit. TODO: we should in fact run most of the tests for 32/64 bits and for all optimization levels
llvm-svn: 161935
2012-08-15 08:29:17 +00:00
Alexey Samsonov 5717f4c1eb [ASan] port interception and shared library tests to lit
llvm-svn: 161933
2012-08-15 07:13:51 +00:00
Alexey Samsonov 682a07cbe1 [ASan] move declaration of __asan_default_options to interface header
llvm-svn: 161932
2012-08-15 07:11:14 +00:00
Kostya Serebryany ad855e9438 [asan] better diagnostics for mmap failure
llvm-svn: 161874
2012-08-14 15:18:40 +00:00
Alexey Samsonov 517842b2fc [ASan] make sure __asan_default_options symbol is exported
llvm-svn: 161873
2012-08-14 15:03:24 +00:00
Alexey Samsonov eb39adc9fa [ASan] make sure __asan_default_options gets default visibility, port corresponding test to lit
llvm-svn: 161869
2012-08-14 13:54:28 +00:00
Alexey Samsonov bf2bfa5aa4 [ASan] support for running OS-specific tests using lit, port clone_test as an example
llvm-svn: 161864
2012-08-14 13:22:58 +00:00
Alexey Samsonov ef7758f561 [Sanitizer] move OS-dependent pieces of symbolizer to separate source files
llvm-svn: 161862
2012-08-14 13:00:32 +00:00
Dmitry Vyukov 81a78ad59c tsan: handle larger number of goroutines + fix a memory leak of goroutine descriptors
llvm-svn: 161770
2012-08-13 18:44:44 +00:00
Alexey Samsonov b39b0fa9a0 [ASan] add __asan_set_on_error_callback into force_interface_symbols (thanks to cool test by glider@)
llvm-svn: 161756
2012-08-13 14:05:00 +00:00
Alexey Samsonov f87ff74075 [ASan] Add __asan_set_on_error_callback() interface function that allows user to set a callback to be called right when ASan detects an error
llvm-svn: 161754
2012-08-13 11:23:40 +00:00
Alexey Samsonov a72c7cf227 [ASan] If ASan finds second error report, wait for some time and die (instead of running in a busy loop) to make sure ASan won't hang if it finds error while reporting an error in the same thread
llvm-svn: 161749
2012-08-13 09:57:19 +00:00
Alexey Samsonov d33973edb4 [Sanitizer] Return cmake support for setting compile definitions for sanitizer_common library
llvm-svn: 161747
2012-08-13 07:41:43 +00:00
Dmitry Vyukov 2bee426ed6 tsan: fix parameter type for pwrite64() interceptor
llvm-svn: 161741
2012-08-12 11:08:30 +00:00
Alexey Samsonov b93df94238 [ASan] share code executed at the beginning/end of printing error reports
llvm-svn: 161666
2012-08-10 15:13:05 +00:00
Alexey Samsonov fb844c7eff [ASan] CMake support for building ASan runtime as a universal binary on Mac
llvm-svn: 161665
2012-08-10 14:45:52 +00:00
Alexander Potapenko 33c028fa05 Remove the setjmp.h dependency, fix the comment.
llvm-svn: 161662
2012-08-10 12:46:39 +00:00
Alexander Potapenko 2cdd4f165e Temporary fix for http://code.google.com/p/address-sanitizer/issues/detail?id=99:
when trying to free memory that actually belongs to the system purgeable zone, use malloc_zone_free(malloc_default_purgeable_zone(), ptr) instead of asan_free().

llvm-svn: 161661
2012-08-10 11:33:01 +00:00
Alexander Potapenko 8aba007fe1 Add a test checking that all the "__asan_" interface functions are present in a binary built with -dead_strip.
Fix force_interface_symbols() so that none of the interface symbols is stripped.

llvm-svn: 161582
2012-08-09 16:05:17 +00:00
Alexander Potapenko 03ee064845 Make the non-interface mach_override functions static to avoid name clashes with user code that may contain its own mach_override.
llvm-svn: 161577
2012-08-09 13:33:02 +00:00
Alexey Samsonov f343eb7df4 [ASan] Move mac-specific error reports to asan_report.cc as well
llvm-svn: 161576
2012-08-09 12:15:40 +00:00
Alexey Samsonov b53a670817 [ASan] Small fix to please tests on Windows, where stack unwinding using provided pc/bp works too bad
llvm-svn: 161575
2012-08-09 11:29:13 +00:00
Alexey Samsonov f688412b8c [ASan] Move __asan_report_error implementation to asan_report.cc
llvm-svn: 161574
2012-08-09 10:56:57 +00:00
Alexander Potapenko ba6174889c Use a switch instead of a simple condition in force_interface_symbols().
Otherwise Clang eliminates everything after the first interface symbol that is marked noreturn.

llvm-svn: 161573
2012-08-09 09:46:12 +00:00
Alexey Samsonov 65b9acf0af [ASan] move code that describes globals to asan_report.cc
llvm-svn: 161572
2012-08-09 09:27:24 +00:00
Alexey Samsonov 4ce12349d6 [ASan] move some functions that describe addresses to asan_report.cc
llvm-svn: 161571
2012-08-09 09:06:52 +00:00
Alexey Samsonov c0ff933d8b [ASan] Move error reporting code away from file with interceptors
llvm-svn: 161570
2012-08-09 08:32:33 +00:00
Alexey Samsonov b4b316fc5b [ASan] Move error reports away from ASan allocator. Add new source file to CMakeLists as well
llvm-svn: 161569
2012-08-09 08:15:46 +00:00
Alexey Samsonov aa05110a17 [ASan] Create new files asan_report.{h,cc} as a preparation for refactoring of ASan error reporting code.
Currently ASan reports many kinds of errors, and the code that actually prints error messages can
be found inside allocator, OS-specific files, interceptors code etc.

An example of maintenance troubles this situation causes:
There is currently an ASan interface function that registers
callback which should take the char buffer with error report printed by ASan.
This function is now broken, as one has to insert callback calls to all the places in
ASan code where the error reports are printed, surprisingly it is not only
"__asan_report_error" function...

llvm-svn: 161568
2012-08-09 07:40:58 +00:00
Alexey Samsonov 4750230ac6 [Sanitizer] cleanup CMake files for interception and sanitizer_common helper libraries
llvm-svn: 161485
2012-08-08 09:46:51 +00:00
Alexey Samsonov 36796b4899 [compiler-rt] CMake build: if LLVM_BUILD_32_BITS is on, then -m32 is added to llvm definitions. Let us override this by explicitly adding -m64 compiler flag when building compiler-rt libraries for x86_64 target
llvm-svn: 161415
2012-08-07 12:14:29 +00:00
Alexey Samsonov 0317b8bbc0 [ASan] simplify cmake rules for adding lit testsuites
llvm-svn: 161412
2012-08-07 11:09:41 +00:00
Alexey Samsonov 1e6c947a4c [ASan] add llvm_tools_dir to lit.site.cfg for ASan and add it to PATH
llvm-svn: 161411
2012-08-07 11:00:19 +00:00
Alexey Samsonov 59c33c0c9a [ASan] Add support for running unit tests by lit (as a part of 'make check-asan' command)
llvm-svn: 161406
2012-08-07 08:59:15 +00:00
Alexey Samsonov 941a6ec9bb [ASan] fix names of malloc/free replacements on Android
llvm-svn: 161322
2012-08-06 15:13:22 +00:00
Alexey Samsonov 0295edbfd5 [ASan] add new ASan option 'strip_path_prefix' to remove useless prefices from filenames in stack traces
llvm-svn: 161321
2012-08-06 13:00:21 +00:00
Alexander Potapenko 8f6dd3537c AllocationSize(ptr) should check that |ptr| actually points to the beginning of the chunk it belongs to.
Fixes http://code.google.com/p/address-sanitizer/issues/detail?id=86

llvm-svn: 161320
2012-08-06 12:24:39 +00:00
Alexander Potapenko 879b1ffca7 Implement LinuxSymbolizer instead of symbolize_addr2line.
llvm-svn: 161181
2012-08-02 14:58:04 +00:00
Alexander Potapenko be84ac8ff3 Some refactoring for asan_symbolize.py: introduced the Symbolizer class and implemented DarwinSymbolizer for atos-based symbolization, BreakpadSymbolizer for breakpad-based symbolization (files produced by the dump_syms tool, http://code.google.com/p/google-breakpad/source/browse/#svn%2Ftrunk%2Fsrc%2Ftools%2Fmac%2Fdump_syms) and ChainSymbolizer to allow falling back if a symbolizer hadn't succeeded.
Fixed pylint warnings.

llvm-svn: 161176
2012-08-02 13:59:23 +00:00