Commit Graph

988 Commits

Author SHA1 Message Date
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
Alexey Samsonov 2e62a9a765 [Sanitizer] fix windows build
llvm-svn: 161170
2012-08-02 11:38:58 +00:00
Alexey Samsonov 9d74295078 Follow-up for r161168 for Windows
llvm-svn: 161169
2012-08-02 11:29:14 +00:00
Alexey Samsonov 0f840bd240 [Sanitizer] Workaround for a compiler warning - ISO C++ forbids casting pointer-to-function to pointer-to-object, so we use cast via integral type
llvm-svn: 161168
2012-08-02 11:19:13 +00:00
Alexander Potapenko 33824c54f6 Make strcat() and strncat() more standard-compliant (check for invalid parameters even if zero bytes is copied, more accurate overlap check)
Fix the tests that were relying on the incorrect behavior.

llvm-svn: 161167
2012-08-02 10:25:46 +00:00
Alexey Samsonov ce8d497aaf [Sanitizer] Fix warnings to please cmake build
llvm-svn: 161166
2012-08-02 10:09:31 +00:00
Alexander Potapenko 40b48ccae2 Add support for "movsbl %sil,%ecx" (x86_64) and "movsbl $imm(%ebp), %edx" (i386) to our fork of mach_override.
This is an extended version of a patch by Rafael Avila de Espindola (rafael.espindola@gmail.com)

llvm-svn: 161116
2012-08-01 16:35:48 +00:00
Alexey Samsonov 139a7c0575 [Sanitizer] Make ASan/TSan sources depend on headers from interception library
llvm-svn: 161113
2012-08-01 14:55:49 +00:00
Alexey Samsonov cc7ea4269a [ASan] cleanup interceptors code - prefer ASAN_INTERCEPT_FUNCTION_NAME macro to _WIN32, __APPLE__ etc.
llvm-svn: 161109
2012-08-01 11:17:00 +00:00
Alexey Samsonov 7b2f36e96a First tiny move towards integrating AddressSanitizer regressions test into LLVM lit-based testing infrastructure.
The goal is to be able to run ASan tests by simply running "make check-asan" command from CMake build tree:
* tests should use fresh clang binary from current build tree.
* tests should use the same RUN-lines syntax as llvm/clang reg tests.

Next steps:
- restricting tests to machines where target is equal to host, i.e. where we can produce working binaries.
- moving AddressSanitizer unit tests to lit as well.

llvm-svn: 161050
2012-07-31 15:43:11 +00:00
Alexander Potapenko 8aae9557d6 Factor out the main() function.
llvm-svn: 161046
2012-07-31 13:51:26 +00:00
Alexey Samsonov 500e99639d [Sanitizer] Wrapper around llvm::DIContext from LLVM DebugInfo library. If a macro SANITIZER_USES_LLVM_LIBS is defined (by default it is not), then sanitizer runtime includes llvm headers and tries to use LLVM libs for in-process symbolization. To make it functional, we have to link with these LLVM libs - either pass them to linker from Clang driver, or link them into static ASan runtime when we build it.
llvm-svn: 161045
2012-07-31 11:51:26 +00:00
Alexey Samsonov 36d2dff143 [ASan] fix cmake build warning
llvm-svn: 160957
2012-07-30 10:18:31 +00:00
Alexey Samsonov a2e0cf4802 [TSan] delete trailing spaces
llvm-svn: 160955
2012-07-30 07:46:09 +00:00
Dmitry Vyukov 904d3f9c06 tsan: add ReleaseStore() function that merely copies vector clock rather than combines two clocks
fix clock setup for finalizer goroutine (Go runtime)

llvm-svn: 160918
2012-07-28 15:27:41 +00:00
Dmitry Vyukov 55253100be tsan: add missing include
llvm-svn: 160875
2012-07-27 18:13:03 +00:00
Dmitry Vyukov 4e94662db4 tsan: change event handling from single HandleEvent() to a set of separate functions (Go runtime)
llvm-svn: 160863
2012-07-27 14:00:39 +00:00
Dmitry Vyukov 536551d02d tasn: do not remember stack traces for sync objects for Go (they are not reported anyway)
llvm-svn: 160861
2012-07-27 13:21:33 +00:00
Dmitry Vyukov e91e9ac2a2 tsan: remove unnecessary and wrong include
llvm-svn: 160860
2012-07-27 13:21:01 +00:00
Kostya Serebryany 4c38790f70 [asan] ensure that asan_init is called in str[n]cmp. Bug found by Nick Kralevich (thanks)
llvm-svn: 160853
2012-07-27 07:09:49 +00:00
Dmitry Vyukov 65ec6684c2 tsan: make the runtime library name tsan-neutral for Go upstream
llvm-svn: 160797
2012-07-26 18:42:51 +00:00
Dmitry Vyukov 55b405ef42 tsan: allow environment to override OnReport() and OverrideFlags()
llvm-svn: 160728
2012-07-25 14:30:51 +00:00
Dmitry Vyukov dfc8e52400 tsan: suport for Go finalizers
llvm-svn: 160723
2012-07-25 13:16:35 +00:00
Dmitry Vyukov d654f06644 tsan: expect that Go symbolizer can return NULLs
llvm-svn: 160722
2012-07-25 11:50:37 +00:00
Alexey Samsonov 5062359502 cmake for compiler-rt: add a function to set output dirs for compiler runtimes equal to directory used by Clang driver. Use it for ASan runtime. Also, make sure that ASan unit tests depend on the ASan runtime.
llvm-svn: 160721
2012-07-25 11:15:00 +00:00
Kostya Serebryany bb0ade6daa [asan] don't return from a never-return function. fix a test that had a chain of bugs instead of just one
llvm-svn: 160719
2012-07-25 10:56:09 +00:00
Alexey Samsonov c145b02607 [ASan] fixup for r160712: provide a default definition for weak __asan_default_options()
llvm-svn: 160718
2012-07-25 10:40:57 +00:00
Alexander Potapenko 9bac1cedbc Make __asan_default_options a weak function that returns a const char*.
Users may define it to override the default ASan options.
This function has to be marked with __attribute__((no_address_safety_analysis)), because it is called before ASan is fully initialized.

Add an output test checking the __asan_default_options functionality.

llvm-svn: 160712
2012-07-25 09:18:43 +00:00
Dmitry Vyukov bcf0b7002b tsan: align report style with Go internal format
llvm-svn: 160672
2012-07-24 12:29:43 +00:00
Alexey Samsonov 65d842ae51 Revert r160669 (except for compile flag updates)
llvm-svn: 160671
2012-07-24 12:11:38 +00:00
Dmitry Vyukov 69bee8d8f6 tsan: output goroutine creation stack
llvm-svn: 160670
2012-07-24 12:03:47 +00:00
Alexey Samsonov 3397013606 [ASan] hacking cmake build: after generating asan runtime, copy it to the Clang lib directory where Clang driver expects to find it.
llvm-svn: 160669
2012-07-24 11:49:55 +00:00
Alexey Samsonov 96b9393f2d [ASan] Support for cmake build of ASan unittests in 32-bit LLVM build. Currently, to run ASan unit tests both for 32- and 64 bits one has to maintain two distinct LLVM builds. In a bright future, we'd like to use a single build for this
llvm-svn: 160666
2012-07-24 08:26:19 +00:00
Alexander Potapenko 51e6488b31 Intercept CFAllocator for each thread in the program.
Test that child threads use the ASan allocator, that allocated memory can be passed to another thread and deallocated on it.
This should fix http://code.google.com/p/address-sanitizer/issues/detail?id=81

llvm-svn: 160630
2012-07-23 14:07:58 +00:00
Alexey Samsonov 37d5134f38 [ASan] minor fixes to silence cmake build warnings
llvm-svn: 160624
2012-07-23 09:11:58 +00:00
Alexander Potapenko 7f3e84c9fd For wild addresses in the shadow or shadow gap areas print an error message instead of crashing on a check.
Add AddressSanitizer.MemsetWildAddressTest that makes sure a proper error message is printed.

llvm-svn: 160620
2012-07-23 08:22:27 +00:00
Alexey Samsonov 3735faa108 [ASan] subtract one from PCs in ASan error reports (as they originally contain return addresses). Make output tests stricter.
llvm-svn: 160508
2012-07-19 15:07:26 +00:00
Kostya Serebryany 7a32f8dcb8 [tsan] fix lint
llvm-svn: 160504
2012-07-19 12:22:04 +00:00
Kostya Serebryany a415df6539 [tsan] minor fixes in tsan allocator and its testlib. Now runs fine with chrome
llvm-svn: 160503
2012-07-19 12:15:33 +00:00
Alexander Potapenko 628b349b17 Suppress the stderr output from atos.
llvm-svn: 160502
2012-07-19 12:01:07 +00:00
Alexey Samsonov 7acdc1738f [Sanitizer] When obtaining the data for loaded modules, add address ranges of loadable segments only. Looks like address range of PT_TLS segment may intersect with loadable segments of other modules.
llvm-svn: 160498
2012-07-19 07:51:20 +00:00
Kostya Serebryany ab34919413 [tsan] minor enhancements in the new tsan allocator and a test malloc replacement library that can be linked to any program to replace malloc (tested on spec2006)
llvm-svn: 160436
2012-07-18 16:04:55 +00:00
Alexey Samsonov c6d97c0ad1 [TSan] fix confusing error message in CheckFailed
llvm-svn: 160435
2012-07-18 14:37:22 +00:00
Alexey Samsonov 4dbfad627e [Sanitizer] add missing unit test for flag parsing (forgot to run svn add before)
llvm-svn: 160428
2012-07-18 06:29:18 +00:00
Alexey Samsonov 93ca829c2d [TSan] cleanup header comments
llvm-svn: 160359
2012-07-17 09:39:59 +00:00
Kostya Serebryany 78713bc574 [asan] get rid of the last operator new call in asan rtl
llvm-svn: 160347
2012-07-17 07:20:13 +00:00
Dmitry Vyukov f2bc464f37 tsan: add platform suffix to Go runtime library
llvm-svn: 160304
2012-07-16 18:25:43 +00:00
Dmitry Vyukov 3abd096370 tsan: treat malloc() as memory access in Go
llvm-svn: 160289
2012-07-16 16:55:01 +00:00
Dmitry Vyukov 5bfac97ff9 tsan: use dynamic shadow stack for Go
llvm-svn: 160288
2012-07-16 16:44:47 +00:00
Dmitry Vyukov dc36d69b6a tsan: increase number of dead threads for Go
llvm-svn: 160283
2012-07-16 16:03:16 +00:00
Dmitry Vyukov 9270eaf1f2 tsan: Go runtime: support goroutine end event
llvm-svn: 160282
2012-07-16 16:01:08 +00:00
Dmitry Vyukov 5e5e36712b tsan: fix build
llvm-svn: 160267
2012-07-16 13:25:47 +00:00
Dmitry Vyukov c40c00767c tsan: port Go runtime to Darwin
llvm-svn: 160266
2012-07-16 13:02:40 +00:00
Alexey Samsonov d77fbba74a [Sanitizer] implement straightforward nlogn sorting, as qsort() may call malloc, which leads to deadlock in ASan allocator
llvm-svn: 160262
2012-07-16 11:27:17 +00:00
Dmitry Vyukov 263efd8f05 tsan: allow to pass CFLAGS to Go runtime build script
llvm-svn: 160259
2012-07-16 10:36:39 +00:00
Dmitry Vyukov 2dac24a42b tsan: add missing test for Go runtime
llvm-svn: 160258
2012-07-16 10:34:57 +00:00
Kostya Serebryany 38f318bf20 [tsan] use internal_strnlen in strncpy interceptor (the bug found while booting chromium)
llvm-svn: 160171
2012-07-13 13:04:43 +00:00
Nick Kledzik 35293305b7 <rdar://problem/11668446> Add .subsections_via_symbols to Darwin assembly files
llvm-svn: 160062
2012-07-11 19:21:39 +00:00