Commit Graph

876 Commits

Author SHA1 Message Date
Alexey Samsonov e4a889866d [Sanitizer] move atomic ops, min/max and sort to commnon runtime
llvm-svn: 158496
2012-06-15 07:00:31 +00:00
Alexey Samsonov 70afb91636 [Sanitizer] move more portability wrappers to common runtime: sleep, _exit, abort, atexit, pthread_self
llvm-svn: 158493
2012-06-15 06:37:34 +00:00
Alexey Samsonov ae1e171b72 [Sanitizer] move DumpProcessMap and DisableCoreDumper to common runtime
llvm-svn: 158490
2012-06-15 06:08:19 +00:00
Dmitry Vyukov ea03fc2d78 tsan: fix COMPAT mapping to not produce false reports
llvm-svn: 158473
2012-06-14 21:40:35 +00:00
Nico Weber 34fd6e9cc2 Don't build compiler-rt arm code on darwin. Fixes PR12918.
I'm not sure if this is the right fix, but this has been broken
for two weeks and pleas for review were ignored. It seems to do
the right thing.

llvm-svn: 158466
2012-06-14 20:00:25 +00:00
Nico Weber 4555d5b471 80 columns
llvm-svn: 158465
2012-06-14 19:58:46 +00:00
Alexey Samsonov c70d1086f6 [Sanitizer] move rest of mmap routines to common sanitizer runtime
llvm-svn: 158452
2012-06-14 14:42:58 +00:00
Alexey Samsonov 0c53a38abb [Sanitizer] move portable GetEnv to common sanitizer runtime
llvm-svn: 158451
2012-06-14 14:07:21 +00:00
Alexey Samsonov 96ef49a71e [Sanitizer] Move internal_memcmp to common sanitizer libc
llvm-svn: 158450
2012-06-14 14:04:54 +00:00
Alexey Samsonov aac5d0c831 [Sanitizer] Workaround for -Wunused-private-field warning - add an attribute in TSan unit test, and silence this warning as gtest has unused fields.
llvm-svn: 158449
2012-06-14 14:02:32 +00:00
Alexey Samsonov 52f946611f [ASan] don't include deleted header
llvm-svn: 158448
2012-06-14 13:15:45 +00:00
Alexey Samsonov 53daa28e77 [ASan] remove obsolete header asan_procmaps.h
llvm-svn: 158447
2012-06-14 12:51:20 +00:00
Alexander Potapenko 919b4bde28 Add test rdx, rdx to fix ASan tests on Mac OS 10.7 x64
llvm-svn: 158312
2012-06-11 15:38:07 +00:00
Alexey Samsonov bb62f555f3 [Sanitizer] Use __libc_malloc/__libc_free instead of malloc/free inside internal allocator on Linux (important for TSan)
llvm-svn: 158261
2012-06-09 09:21:44 +00:00
Alexey Samsonov f516d39c1f [TSan] use efficient real_memcpy inside runtime
llvm-svn: 158260
2012-06-09 09:14:24 +00:00
Alexey Samsonov 59036d2c06 [Sanitizer] add internal_memset and internal_strrchr to sanitizer_common/
llvm-svn: 158202
2012-06-08 14:11:12 +00:00
Alexey Samsonov 99d58521c5 [ASan] allow calls to memmove during rtl initialization
llvm-svn: 158201
2012-06-08 14:04:04 +00:00
Alexey Samsonov 6cfc34ea7f [TSan] s/internal_memset/real_memset
llvm-svn: 158200
2012-06-08 13:59:39 +00:00
Alexey Samsonov f26b842ca8 [ASan] add interceptor for strncat
llvm-svn: 158198
2012-06-08 13:27:46 +00:00
Alexey Samsonov 91e1a7eb17 [Sanitizer] move internal_strdup and internal_memcpy to common runtime. Make internal allocations from TSan runtime call InternalAlloc from common runtime
llvm-svn: 158148
2012-06-07 11:54:08 +00:00
Alexey Samsonov 8b9aea522f [Sanitizer] use unsigned int as a parameter for placement new on 32 bits
llvm-svn: 158147
2012-06-07 10:09:41 +00:00
Alexey Samsonov 8bd9098b32 [Sanitizer] move placement_new definiton from TSan to common runtime
llvm-svn: 158145
2012-06-07 09:50:16 +00:00
Alexey Samsonov 94e2b7d040 [Sanitizer] include stdlib.h header to get malloc/free
llvm-svn: 158144
2012-06-07 09:26:13 +00:00
Kostya Serebryany 0b14fd855b [asan] slow 16-byte redzones (still experimental)
llvm-svn: 158143
2012-06-07 09:15:48 +00:00
Alexey Samsonov 3a6ddb86e8 [Sanitizer] Allocator for internal runtime purposes. Currently it calls libcmalloc, but we might have to make it more low-level in future
llvm-svn: 158142
2012-06-07 08:52:56 +00:00
Alexey Samsonov cf4d3a027d [Sanitizer] Fix mac build.
llvm-svn: 158141
2012-06-07 07:32:00 +00:00
Alexey Samsonov 4b1f1031e6 [Sanitizer] factor out GetThreadStackTopAndBottom from ASan runtime to common.
llvm-svn: 158140
2012-06-07 07:13:46 +00:00
Alexey Samsonov 28a9895ee0 [Sanitizer] __asan::AsanProcMaps -> __sanitizer::ProcessMaps.
llvm-svn: 158139
2012-06-07 06:15:12 +00:00
Alexey Samsonov fe44fbd750 [Sanitizer] Move ReadFileToBuffer to sanitizer_common.
llvm-svn: 158138
2012-06-07 05:38:26 +00:00
Kostya Serebryany 112ac68d52 [asan] more compaction: don't use the next field while the chunk is in allocated state
llvm-svn: 158083
2012-06-06 16:58:21 +00:00
Kostya Serebryany c0bbfbfba2 [asan] more allocator compaction
llvm-svn: 158082
2012-06-06 16:33:46 +00:00
Alexey Samsonov 40d5b772e5 [Sanitizer] Switch to common mmap/munmap routines in ASan run-time.
llvm-svn: 158078
2012-06-06 16:15:07 +00:00
Alexey Samsonov e95e29c2ac [Sanitizer] Make UNIMPLEMENTED macro common.
llvm-svn: 158077
2012-06-06 15:47:40 +00:00
Kostya Serebryany 00e22d2b2c [asan] more compaction for allocator
llvm-svn: 158076
2012-06-06 15:30:55 +00:00
Alexey Samsonov e428779dbf [Sanitizer] Use common CHECK machinery. Currently each tool has to define its own CheckFailed function.
llvm-svn: 158075
2012-06-06 15:22:20 +00:00
Kostya Serebryany 79437fe376 [asan] make tid u32 instead of int
llvm-svn: 158074
2012-06-06 15:06:58 +00:00
Kostya Serebryany 53b74ac256 [asan] start compacting the allocator header, the goal is to make it 16 bytes w/o losing any information
llvm-svn: 158072
2012-06-06 14:46:38 +00:00
Kostya Serebryany 64166ca86b [tsan,asan] comment out O_CLOEXEC as it causes build failures on old linux kernels
llvm-svn: 158071
2012-06-06 14:11:31 +00:00
Alexey Samsonov d323f4e78e [Sanitizer] Remove __attribute__((format))
llvm-svn: 158070
2012-06-06 13:58:39 +00:00
Alexey Samsonov d44cb4cb8a [ASan] match type of arguments to format string on Mac.
llvm-svn: 158068
2012-06-06 13:44:19 +00:00
Alexey Samsonov 8bafdd020e [Sanitizer] fix Win build - ignore __attribute__((format)).
llvm-svn: 158067
2012-06-06 13:37:02 +00:00
Alexey Samsonov 51ae983718 [Sanitizer]: Introduce a common internal printf function. For now, also use tool-specific wrappers TsanPrintf (its output is controlled by TSan flags) and AsanPrintf (which copies its results to the ASan-private buffer). Supported formats: %[z]{d,u,x}, %s, %p. Re-write all format strings in TSan according to this format (this should have no effect on 64-bit platforms).
llvm-svn: 158065
2012-06-06 13:11:29 +00:00
Alexey Samsonov cd96c44dce [ASan] more format fixes
llvm-svn: 158060
2012-06-06 10:54:25 +00:00
Alexey Samsonov 461820ad67 [ASan] Make printf arguments match format strings better.
llvm-svn: 158059
2012-06-06 10:46:00 +00:00
Alexey Samsonov ac4c290d02 [TSan] run some renaming as a preparation for factoring out Printf implementation.
llvm-svn: 158058
2012-06-06 10:13:27 +00:00
Alexey Samsonov 201aa367fc [ASan] fix win build - add missing header
llvm-svn: 158057
2012-06-06 09:43:32 +00:00
Alexey Samsonov ee07290628 [Sanitizer] Move more functions/constants to sanitizer_common.
llvm-svn: 158056
2012-06-06 09:26:25 +00:00
Alexey Samsonov ca2b5d7abb [Sanitizer] move internal_filesize and internal_dup2 from TSan to sanitizer_common.
llvm-svn: 158052
2012-06-06 07:30:33 +00:00
Alexey Samsonov c4b201308b [ASan] Use __sanitizer::Die() in ASan runtime.
llvm-svn: 158051
2012-06-06 07:02:44 +00:00
Alexey Samsonov bc3a7e3fe2 [Sanitizer] add sanitizer_common.h for routines shared between TSan and ASan runtimes. Use __sanitizer::Die() in TSan.
llvm-svn: 158050
2012-06-06 06:47:26 +00:00
Alexey Samsonov 7fca5ccdae [ASan] fix GetFreeBytesTest interface test on 32-bit Linux - delete some assumptions about the behavior of allocator in test code
llvm-svn: 158047
2012-06-06 06:02:05 +00:00
Alexey Samsonov 5bbf8290a7 [Sanitizer] rename sanitizer_defs.h to sanitizer_internal_defs.h
llvm-svn: 158001
2012-06-05 14:25:27 +00:00
Alexey Samsonov 3768b58f82 [Sanitizer] fix compilation on Mac OS 10.6 - don't use O_CLOEXEC
llvm-svn: 158000
2012-06-05 14:07:11 +00:00
Alexey Samsonov 8602c65719 [Sanitizer] remove using namespace __sanitizer lines
llvm-svn: 157999
2012-06-05 14:05:09 +00:00
Alexey Samsonov ef2e2cfd33 [Sanitizer] Use common defines for ASan and TSan runtime. Split defines between interface defines (can be visible in user code that includes interface ASan/TSan headers) and internal defines.
llvm-svn: 157998
2012-06-05 13:50:57 +00:00
Kostya Serebryany 03cd639b56 [asan] change the order of tests in the asan_test binary. Makes the test runs 2x faster due to DEATH_TEST overhead (see asan issue 77)
llvm-svn: 157997
2012-06-05 13:48:15 +00:00
Alexey Samsonov cc88531760 [TSan] Use internal_munmap from sanitizer_libc in TSan runtime.
llvm-svn: 157995
2012-06-05 09:55:24 +00:00
Alexey Samsonov 7ac77d6b29 [Sanitizer] add sanitizer_posix.cc. Move more various functions into sanitizer_libc: sscanf, munmap, memchr
llvm-svn: 157994
2012-06-05 09:49:25 +00:00
Alexey Samsonov 9354688dc5 [ASan] s/size_t/uptr in asan_mac.cc
llvm-svn: 157993
2012-06-05 09:13:33 +00:00
Alexey Samsonov b8f35d9512 [TSan] make TSan runtime use internal_{close,read,write} from sanitizer_libc
llvm-svn: 157992
2012-06-05 09:00:36 +00:00
Alexey Samsonov 1b12eda7ec [ASan] use internal_{close,read,write} in ASan runtime.
llvm-svn: 157991
2012-06-05 08:48:10 +00:00
Alexey Samsonov 03c8b846c4 [Sanitizer] add internal_{close,read,write} functions to sanitizer_libc
llvm-svn: 157990
2012-06-05 08:32:53 +00:00
Alexey Samsonov 298dd7c361 [TSan] use __sanitizer::internal_open in TSan run-time
llvm-svn: 157988
2012-06-05 07:46:31 +00:00
Alexey Samsonov f5e2dc3c3d [ASan] use internal_open from sanitizer_libc in ASan runtime
llvm-svn: 157986
2012-06-05 07:25:47 +00:00
Alexey Samsonov dde1f11fe6 [Sanitizer] Add sanitizer_win.cc for windows-specific implementations of libc functions. Add internal_open.
llvm-svn: 157985
2012-06-05 07:05:10 +00:00
Alexey Samsonov 11fff6df33 [TSan] use __sanitizer::internal_mmap in TSan run-time
llvm-svn: 157984
2012-06-05 06:19:00 +00:00
Alexey Samsonov 9ab24cc3f5 [ASan] Fix a typo in Makefile.old
llvm-svn: 157982
2012-06-05 05:20:33 +00:00
Alexey Samsonov b6e4f3690b [Sanitizer] Enable lint for sanitizer_common/
llvm-svn: 157931
2012-06-04 14:35:09 +00:00
Alexey Samsonov 2c5fc3bb11 Created files sanitizer_linux.cc and sanitizer_mac.cc for platform-specific implementations of common functions. Turned asan_mmap into __sanitizer::internal_mmap.
llvm-svn: 157930
2012-06-04 14:27:50 +00:00
Alexey Samsonov 3b2f9f4c98 Remove file-type tags in .cc files in tsan/ and sanitizer_common/
llvm-svn: 157928
2012-06-04 13:55:19 +00:00
Alexey Samsonov 485d3dc363 Remove file-type tags for .cc files in ASan run-time library
llvm-svn: 157927
2012-06-04 13:50:10 +00:00
Alexey Samsonov 90f9630c80 [Sanitizer]: move internal_strcmp to sanitizer_common
llvm-svn: 157926
2012-06-04 13:27:49 +00:00
Alexey Samsonov 4ecc8f43c7 [ASan] Use ASan option symbolize to turn on internal symbolizer (in development)
llvm-svn: 157924
2012-06-04 11:20:17 +00:00
Alexey Samsonov 06f2cd38c1 [Sanitizer] Move internal_strncpy to sanitizer_libc (and make its behavior conforming to manual)
llvm-svn: 157922
2012-06-04 10:30:16 +00:00
Alexey Samsonov c1971ca12f [Sanitizer_common] fix filenames in comments
llvm-svn: 157919
2012-06-04 09:33:06 +00:00
Alexey Samsonov cad2e4e6c2 temporary include stdlib.h in symbolizer to fix Mac/Win build
llvm-svn: 157808
2012-06-01 07:41:47 +00:00
Kostya Serebryany 02845c1dd4 [asan] fix gcc build
llvm-svn: 157807
2012-06-01 07:41:04 +00:00
Alexey Samsonov 6f596767c3 Stub files for common symbolizer for AddressSanitizer and ThreadSanitizer tools.
It is an analogue of addr2line utility and should allow to map instruction address to a location
in source code at run-time. It should use debug information (in DWARF) in a binary, and hopefully
it would be possible to re-use code from llvm/DebugInfo/DIContext.h

llvm-svn: 157806
2012-06-01 06:11:13 +00:00
Dmitry Vyukov 95a5c5ca4c tsan: intercept longjmp() but die in it, greatly simplifies problem diagnostic
llvm-svn: 157760
2012-05-31 18:03:59 +00:00
Kostya Serebryany 8a66b71c8f [asan] partial fix for windows build
llvm-svn: 157750
2012-05-31 16:06:05 +00:00
Kostya Serebryany f8c5a5bcbc [asan] partial fix for windows build
llvm-svn: 157748
2012-05-31 15:44:05 +00:00
Kostya Serebryany 1d35d155fd [asan] more renaming
llvm-svn: 157747
2012-05-31 15:02:07 +00:00
Kostya Serebryany 8d03204204 [asan] more renaming
llvm-svn: 157746
2012-05-31 14:35:53 +00:00
Dmitry Vyukov 6f448700e4 tsan: fix a typo
llvm-svn: 157744
2012-05-31 14:24:10 +00:00
Kostya Serebryany 1b71207f48 [asan,tsan] introduce sanitizer_common/sanitizer_defs.h and perform some renaming in asan rt. More to come.
llvm-svn: 157743
2012-05-31 14:11:07 +00:00
Alexander Potapenko a39c2fec46 Fix the wildcards for two output tests on Darwin.
It turns out that atos does not print the symbol names for static C++ functions correctly (one of the two leading underscores is omitted), so they remain mangled.

llvm-svn: 157742
2012-05-31 13:55:40 +00:00
Kostya Serebryany c5bea20e2e [asan,tsan] rename files in sanitizer_common to have a common prefix (sanitizer_).
llvm-svn: 157740
2012-05-31 13:42:53 +00:00
Dmitry Vyukov d6ffccd1da tsan: suppress reports against source file names as well
llvm-svn: 157739
2012-05-31 13:18:11 +00:00
Alexander Potapenko bb50e7f08c Be more verbose when installing the signals.
llvm-svn: 157693
2012-05-30 15:29:11 +00:00
Alexander Potapenko 6e216bea86 Fix a bug in parsing boolean flags: we used to take the first char of the key=value string
instead of the first character of the value.

llvm-svn: 157692
2012-05-30 15:28:45 +00:00
Alexander Potapenko 93b2c7d516 Be less verbose when parsing the default options.
llvm-svn: 157691
2012-05-30 14:12:20 +00:00
Dmitry Vyukov 92d917d91c tsan: prevent recursive signal handlers
llvm-svn: 157625
2012-05-29 15:51:27 +00:00
Kostya Serebryany 458b4006b2 [asan,tsan] Add a new directory compiler-rt/lib/sanitizer_common
which will contain code shared between asan and tsan run-times.

Naming is hard. If you can suggest a better name for the directory -- speak up.

llvm-svn: 157611
2012-05-29 12:18:18 +00:00
Alexey Samsonov 1cbe656d66 Fixing ASan build on Win: don't use __asan_default_options
llvm-svn: 157608
2012-05-29 09:39:01 +00:00
Alexander Potapenko d07b7b529a Do not define ___asan_default_options on Windows.
llvm-svn: 157603
2012-05-29 08:26:18 +00:00
Alexey Samsonov 80bc3b0d2b Fix atoi stub for linux introduced in r157573. This fixes compiler-rt build on linux.
llvm-svn: 157600
2012-05-29 06:55:01 +00:00
Dmitry Vyukov 9bf897e696 tsan: fix compiler warnings
llvm-svn: 157585
2012-05-28 17:33:08 +00:00
Dmitry Vyukov 880bb6697f tsan: fix race during pthread_join/detach
llvm-svn: 157584
2012-05-28 17:32:50 +00:00
Alexander Potapenko 0efd915d92 Rework the flags machinery a bit.
Clients may define the __asan_default_options char string containing the default options for the tool now.

llvm-svn: 157582
2012-05-28 16:21:19 +00:00
Alexander Potapenko db892de581 More verbose check in AppendString.
llvm-svn: 157580
2012-05-28 15:00:45 +00:00
Dmitry Vyukov e1bbb2f34a tsan: pass CFLAGS to tests
llvm-svn: 157579
2012-05-28 14:15:39 +00:00
Dmitry Vyukov ed5bc02740 tsan: be more conservative wrt symbolizer output
llvm-svn: 157578
2012-05-28 14:14:53 +00:00
Bill Wendling aa888a29eb Add support for the GCOV_PREFIX_STRIP env variable which tries to strip off the first 'n' directories from the filename.
llvm-svn: 157574
2012-05-28 10:09:01 +00:00
Bill Wendling 1e039681c5 Add stub for 'atoi'.
llvm-svn: 157573
2012-05-28 09:58:27 +00:00
Bill Wendling 65adec933d Simplify the logic that tries to open the GCDA file at all costs. Basically, if
we can't open the file even after creating all of the directories to it, then
just give up.

llvm-svn: 157572
2012-05-28 09:46:43 +00:00
Bill Wendling bba2a7d46d * A bit of cleanup of the 'recursive_mkdir'. No functionality change.
* Check for absolute paths before using the GCOV_PREFIX.
* Don't add an ending path separator if there's already one.

llvm-svn: 157571
2012-05-28 09:41:48 +00:00
Dmitry Vyukov d558530754 tsan: increase /proc/self/maps max size (1M is far not enough)
llvm-svn: 157570
2012-05-28 09:24:01 +00:00
Dmitry Vyukov bd310f02a5 asan/tsan: rename interceptors from __xsan_xxx to __interceptor_xxx
llvm-svn: 157569
2012-05-28 07:47:35 +00:00
Dmitry Vyukov ebdf670ae7 tsan: more robust detection of stack of main thread
llvm-svn: 157568
2012-05-28 07:46:42 +00:00
Dmitry Vyukov 3de9ca068f tsan: use DCHECK_GT/LT instead of plain DCHECK (better diagnostics)
llvm-svn: 157567
2012-05-28 07:45:35 +00:00
Dmitry Vyukov 2d4e3c140f tsan: do not clean stack/tls for main thread
llvm-svn: 157566
2012-05-28 07:44:34 +00:00
Dmitry Vyukov 9b13e9f3b5 asan: remove static libraries on make clean
llvm-svn: 157565
2012-05-28 07:43:36 +00:00
Bill Wendling f16084723c Don't use 'strrchr', which isn't implemented here yet.
llvm-svn: 157560
2012-05-28 02:50:53 +00:00
Bill Wendling 74f987f3b6 Sync with old GCOV runtime library's file.
llvm-svn: 157559
2012-05-28 02:34:34 +00:00
Alexander Potapenko 4e424b85e3 Typo fix.
llvm-svn: 157477
2012-05-25 15:56:40 +00:00
Alexander Potapenko 85e93ef612 Factor ParseAsanOptions outside __asan_init
llvm-svn: 157473
2012-05-25 15:37:16 +00:00
Alexander Potapenko 442002568c Introduce the check_malloc_usable_size flag (on by default).
When the flag is set to zero, we do not check for errors in malloc_usable_size.
This may be useful to work around a bug in Nvidia drivers prior to 295.*

llvm-svn: 157472
2012-05-25 15:20:13 +00:00
Dmitry Vyukov 7339eb197b tsan: do not call into libc in symbolizer and in other code (this causes recursion and crashes)
llvm-svn: 157466
2012-05-25 11:15:04 +00:00
Dmitry Vyukov e86497ee1c tsan: output message about failure to intercept only if verbosity flag is passed
llvm-svn: 157465
2012-05-25 09:47:18 +00:00
Dmitry Vyukov ff25cf5887 asan: fix tests
depending on -m32/-m64 addr2line says either e.g. __xsan_strnlen or just strnlen

llvm-svn: 157464
2012-05-25 09:46:33 +00:00
Meador Inge 6fef6e6466 Adding back a right parenthesis that was dropped in r157388.
llvm-svn: 157406
2012-05-24 18:16:39 +00:00
Dmitry Vyukov d1b9521e48 tsan: compilation of tests with newest clang
llvm-svn: 157392
2012-05-24 14:55:12 +00:00
Dmitry Vyukov 30c32a8819 tsan: fix compilation with newest clang
llvm-svn: 157391
2012-05-24 14:50:33 +00:00
Dmitry Vyukov 7fb7330469 asan/tsan: weak interceptors
The idea isthat asan/tsan can survive if user intercepts the same functions. At the same time user has an ability to call back into asan/tsan runtime. See the following tests for examples:
asan/output_tests/interception_failure_test-linux.cc
asan/output_tests/interception_test-linux.cc
asan/output_tests/interception_malloc_test-linux.cc

llvm-svn: 157388
2012-05-24 13:54:31 +00:00
Dmitry Vyukov 65c21a5e6d tsan: add a flag to control RunningOnValgrind() return value
llvm-svn: 157383
2012-05-24 09:24:45 +00:00
Evgeniy Stepanov 8152e22073 Move AsanShadowRangeIsAvailable() from mac to posix.
llvm-svn: 157326
2012-05-23 15:21:50 +00:00
Evgeniy Stepanov 8f247016bd Use zero-based shadow by default on Android.
llvm-svn: 157318
2012-05-23 11:52:37 +00:00
Dmitry Vyukov 4a17675888 asan: fix typo in comment
llvm-svn: 157314
2012-05-23 06:14:21 +00:00
Dmitry Vyukov 302cebb8f1 tsan: add shadow memory flush + fix few bugs
llvm-svn: 157270
2012-05-22 18:07:45 +00:00
Dmitry Vyukov 011a363c85 tsan: fix sizeof sigset_t
llvm-svn: 157268
2012-05-22 18:01:33 +00:00
Dmitry Vyukov 4d30e9b5eb tsan: fix makefile
allow to build custom configurations

llvm-svn: 157259
2012-05-22 16:46:05 +00:00
Dmitry Vyukov f6985e3ab9 tsan: reduce per-thread memory usage
llvm-svn: 157252
2012-05-22 14:34:43 +00:00
Kostya Serebryany 5d03d45643 [asan] nuke some old unused code
llvm-svn: 157250
2012-05-22 13:31:35 +00:00
Kostya Serebryany 02d5ec5ecf [asan] increase the stack size limit to 256M (yes, that happens); also CHECK that the stack size is less than that on a non-main thread
llvm-svn: 157249
2012-05-22 11:54:44 +00:00
Dmitry Vyukov 15710c9220 tsan: simple memory profiler
llvm-svn: 157248
2012-05-22 11:33:03 +00:00
Kostya Serebryany a20890b6bc [asan] use -fno-builtin to build asan-rt on Mac
llvm-svn: 157239
2012-05-22 07:59:37 +00:00
Kostya Serebryany c84461dbfe [asan] use -fPIE -fno-builtin for building asan-rt
llvm-svn: 157238
2012-05-22 07:56:09 +00:00
Kostya Serebryany 4fa4ac1290 [asan] fix one test on 32-bit Mac 10.7; enable another test on Mac
llvm-svn: 157237
2012-05-22 07:44:30 +00:00
Dmitry Vyukov 46c1a4c25e tsan: implement malloc/free hooks
llvm-svn: 157196
2012-05-21 17:39:40 +00:00
Timur Iskhodzhanov ea365131a2 [ASan] Make for-Windows RTL compileable using Clang++
llvm-svn: 157188
2012-05-21 14:25:36 +00:00
Dmitry Vyukov 99ed663a42 tsan: do not assume non-recursive signal handlers
llvm-svn: 157187
2012-05-21 14:24:20 +00:00
Dmitry Vyukov 163a8338be tsan: replace CHECK with CHECK_EQ for better diagnostics
llvm-svn: 157181
2012-05-21 10:20:53 +00:00
Dmitry Vyukov 98953b7a6d tsan: better, more realistic handling of signals
llvm-svn: 157178
2012-05-21 08:26:51 +00:00
Dmitry Vyukov 9d2229f3ca tsan: add more checks for OOM conditions
tests like to try to malloc((size_t)-1)

llvm-svn: 157176
2012-05-21 06:46:27 +00:00
Dmitry Vyukov f64046cb3d tsan: check for overflow in malloc()
llvm-svn: 157048
2012-05-18 09:41:52 +00:00
Dmitry Vyukov bea47a5029 tsan: fix potential NULL deref
llvm-svn: 157047
2012-05-18 08:53:16 +00:00
Dmitry Vyukov 19b855fe3e tsan: remove shutdown code
tsan runtime shutdown is problematic for 2 reasons:
1. others crash during shutdown
2. we have to override user exit status (don't know it and can't return from atexit handler)

llvm-svn: 156991
2012-05-17 15:00:27 +00:00
Dmitry Vyukov fee5b7d2e0 tsan: detect accesses to freed memory
http://codereview.appspot.com/6214052

llvm-svn: 156990
2012-05-17 14:17:51 +00:00
Kostya Serebryany 82bcc58384 [tsan] fix dependency rules in Makefile.old
llvm-svn: 156983
2012-05-17 08:33:14 +00:00
Dmitry Vyukov 352358b715 tsan: ValgrindSlowdown() should be weak for some time
llvm-svn: 156982
2012-05-17 08:31:47 +00:00
Dmitry Vyukov 166b8e5f33 tsan: add ValgrindSlowdown() "dynamic annotation"
llvm-svn: 156981
2012-05-17 08:04:41 +00:00
Dmitry Vyukov f015a94f09 tsan: improve addr2line symbolizer
-provide support for non-continous modules
-ignore not loaded sections
-more debug output

llvm-svn: 156924
2012-05-16 16:40:47 +00:00
Kostya Serebryany e263221069 [tsan] add tiny_test.c
llvm-svn: 156908
2012-05-16 07:48:16 +00:00
Kostya Serebryany 480922f6a1 [tsan] fix old-style makefile -- we still need them to run our tests
llvm-svn: 156907
2012-05-16 07:46:55 +00:00
Kostya Serebryany c9fd917b36 [tsan] makefile machinery to build tsan-rt (linux-x86_64 only)
llvm-svn: 156822
2012-05-15 15:17:35 +00:00
Kostya Serebryany 8423f5654f [asan] fix the old-style Makefile, which we still need to run asan tests
llvm-svn: 156818
2012-05-15 12:41:14 +00:00
David Chisnall ca9c93c38d Update atomic.c to work with the new clang builtins.
llvm-svn: 156817
2012-05-15 12:36:14 +00:00
Kostya Serebryany 1dd4c606ed [asan] move lib/asan/interception to lib/interception so that other tools (e.g. tsan) can use it
llvm-svn: 156816
2012-05-15 12:21:33 +00:00
Dmitry Vyukov 572c5b2a44 tsan: add more atomics to public interface (fetch_or/and/xor + 1-,2-byte versions)
llvm-svn: 156766
2012-05-14 15:33:00 +00:00
Dmitry Vyukov 665ce2a2f4 tsan: enabled report suppression for signal-unsafe reports
llvm-svn: 156765
2012-05-14 15:28:03 +00:00
Dmitry Vyukov d004b99cc6 tsan: fix output_tests script to actually verify tests results
llvm-svn: 156764
2012-05-14 15:25:35 +00:00
Dmitry Vyukov f5cbda29cd tsan: make addr2line symbolizer understand dynamic libraries
Collect info about all dynamic libraries in the process (name, base, size).
Determine to what dyn lib the address relates, route request to addr2line instance for the lib.

llvm-svn: 156759
2012-05-14 14:38:29 +00:00
Dmitry Vyukov fa44dc5623 tsan: update output tests to race on heap memory
Races on stack of main thread are problematic for COMPAT mapping, because it's not 1-to-1 and race addr is not properly mapped from shadow back to application memory. 
Update output tests to race heap memory.

llvm-svn: 156758
2012-05-14 14:00:07 +00:00
Dmitry Vyukov b078a33151 tsan: fix mmap fd
This is mostly to test my commit access.
Fixes fd passed to mmap(), -1 is the proper invalid fd.

llvm-svn: 156741
2012-05-13 14:24:46 +00:00
Alexander Potapenko a1c3c6582c Increase error_message_buffer_size to 64K (16K is insufficient for large programs)
llvm-svn: 156711
2012-05-12 12:33:41 +00:00
Evgeniy Stepanov d989be1386 Fix GetFrameNameByAddr hitting stale stack guards.
In the current implementation AsanThread::GetFrameNameByAddr scans the
stack for a magic guard value to locate base address of the stack
frame. This is not reliable, especially on ARM, where the code that
stores this magic value has to construct it in a register from two
small intermediates; this register can then end up stored in a random
stack location in the prologue of another function.

With this change, GetFrameNameByAddr scans the shadow memory for the
signature of a left stack redzone instead. It is now possible to
remove the magic from the instrumentation pass for additional
performance gain. We keep it there for now just to make sure the new
algorithm does not fail in some corner case.

llvm-svn: 156710
2012-05-12 12:33:10 +00:00
Kostya Serebryany 0e6705ec67 [tsan] run output tests in parallel
llvm-svn: 156617
2012-05-11 14:58:20 +00:00
Kostya Serebryany 07c4805175 [tsan] run more kinds of builds as presubmit test (and fix gcc debug build)
llvm-svn: 156616
2012-05-11 14:42:24 +00:00
Kostya Serebryany 1136764ab0 [tsan] a bit more lint
llvm-svn: 156614
2012-05-11 13:49:53 +00:00
Kostya Serebryany 5b7cb1db61 [tsan] old-dstyle Makefile for tests; two helper scripts that analyze the assembly code of the hot functions
llvm-svn: 156547
2012-05-10 15:10:03 +00:00
Kostya Serebryany ff15ef0c50 [tsan] ThreadSanitizer tests and micro benchmarks. No makefiles yet.
llvm-svn: 156545
2012-05-10 14:18:22 +00:00
Kostya Serebryany df68b67f06 [tsan] add the old Makefile (which is the only way to build the tsan-rtl for now)
llvm-svn: 156544
2012-05-10 14:04:19 +00:00
Kostya Serebryany 4ad375f0a9 [tsan] First commit of ThreadSanitizer (TSan) run-time library.
Algorithm description: http://code.google.com/p/thread-sanitizer/wiki/ThreadSanitizerAlgorithm

Status:
The tool is known to work on large real-life applications, but still has quite a few rough edges.
Nothing is guaranteed yet.

The tool works on x86_64 Linux.
Support for 64-bit MacOS 10.7+ is planned for late 2012.
Support for 32-bit OSes is doable, but problematic and not yet planed.

Further commits coming:
  - tests
  - makefiles
  - documentation
  - clang driver patch

The code was previously developed at http://code.google.com/p/data-race-test/source/browse/trunk/v2/
by Dmitry Vyukov and Kostya Serebryany with contributions from
Timur Iskhodzhanov, Alexander Potapenko, Alexey Samsonov and Evgeniy Stepanov.

llvm-svn: 156542
2012-05-10 13:48:04 +00:00
Alexander Potapenko 66e6de10cf Fix ReadFileToBuffer to return 0 on failure (-1 is too large if returned as size_t).
llvm-svn: 156538
2012-05-10 12:03:09 +00:00
Alexey Samsonov fbadfddcf1 [ASan] use CLANG_VERSION in Makefile (currently 3.2)
llvm-svn: 155350
2012-04-23 13:27:47 +00:00
Kostya Serebryany c5bf3ad922 [asan] fix asan issue #66 (correctly report type of the bug)
llvm-svn: 155344
2012-04-23 10:08:16 +00:00
Alexander Potapenko 0825d35b57 Bump the LLVM minor version. This should fix our 32-bit Linux build.
llvm-svn: 155338
2012-04-23 07:36:24 +00:00
Kostya Serebryany d45a71c2bc [asan] test for issue #66
llvm-svn: 155127
2012-04-19 14:53:51 +00:00
Alexander Potapenko ec316e5940 Partially revert r154390 (http://llvm.org/viewvc/llvm-project?view=rev&revision=154390)
Until we work out the solution for http://code.google.com/p/address-sanitizer/issues/detail?id=65 we'd better not allow
the clients to override AddressSanitizer's signal handler.

The second part of r154390 (removing the sighandler-related tests) is not reverted, because those tests were broken
and didn't test anything.

llvm-svn: 154803
2012-04-16 08:33:01 +00:00
Alexey Samsonov cc0b3e6607 [asan] minor fix: pass flag -g to output tests as a part of CXXFLAGS
llvm-svn: 154589
2012-04-12 13:31:13 +00:00
Alexey Samsonov f2a8ea3afd Don't build atomic.c when building compiler-rt using make
llvm-svn: 154583
2012-04-12 09:43:57 +00:00
Alexey Samsonov a5f6fd9884 [ASan] fix output tests - r154570 changed debug info for static functions and now they are symbolized a bit differently
llvm-svn: 154581
2012-04-12 07:32:08 +00:00
Alexander Potapenko bc42d44112 Change the way ASan interacts with custom signal handlers.
From now on we allow the clients to override signal handlers set by ASan, but print a warning in such a case.

Remove the tests for signal() and sigaction(), because they made little sense even without this change.

llvm-svn: 154390
2012-04-10 11:00:26 +00:00
Alexey Samsonov 7ec936a4f4 [ASan] remove dispatch.h header once again - it's not present on Leopard, and we don't want to break the build of compiler-rt there. See https://trac.macports.org/ticket/33362
llvm-svn: 154326
2012-04-09 16:45:18 +00:00
Timur Iskhodzhanov 36a7cc6292 Use 'typename' instead of 'class' in template<> definitions supporting POD types
llvm-svn: 154314
2012-04-09 11:50:27 +00:00
Kostya Serebryany d2863dab85 [asan] last bit for gcc compatibility
llvm-svn: 154203
2012-04-06 20:36:18 +00:00
Kostya Serebryany b7f68dee45 [asan] minor change to please gcc
llvm-svn: 154201
2012-04-06 20:19:59 +00:00
Alexey Samsonov 6a19d5d209 [ASan] move replacements for new/delete to separate file
llvm-svn: 154167
2012-04-06 08:21:08 +00:00
Kostya Serebryany 1490c7996f [asan] add flags: disable_core, abort_on_error and unmap_shadow_on_exit
llvm-svn: 154159
2012-04-06 01:27:11 +00:00
Timur Iskhodzhanov 889a3009a4 [ASan/Win] Revert the local Makefile change slipped into the prev commit
llvm-svn: 154112
2012-04-05 18:33:17 +00:00
Timur Iskhodzhanov 7d2776960b [ASan/Win] Fix lint warning
llvm-svn: 154111
2012-04-05 18:31:50 +00:00
Timur Iskhodzhanov 0881092306 [ASan/Win] Fix build by using inline assembly instead of an unavailable intrinsic function
llvm-svn: 154106
2012-04-05 17:16:32 +00:00
Kostya Serebryany 7a8f5e4d1e [asan] make __asan::Deallocate immune to racy double-free (issue #57)
llvm-svn: 154097
2012-04-05 15:55:09 +00:00
Alexander Potapenko 08342aa1a1 Introduce the use_sigaltstack flag (off by default), which enables using alternate
per-thread stacks for signal handling. This allows to print more verbose error reports
for stack overflows.

llvm-svn: 154092
2012-04-05 10:54:52 +00:00
Alexander Potapenko 44016da83f Allow calling GetCurrentTidOrMinusOne() before AsanThreadRegistry was initialized.
llvm-svn: 154091
2012-04-05 10:10:57 +00:00
Chandler Carruth 1f5d5c0e13 Initial, very rough cut at a new CMake build system for compiler-rt.
Some high-level notes:

1) An explicit goal is to support building compiler-rt as a subproject
   build, checked out into the projects/compiler-rt directory. There are
   many other possible ways of building the code here, but this is
   optimized for development on LLVM/Clang/compiler-rt, and incremental
   trial and testing of the toolchain.
2) The current support is targeted at Linux. I would love to see this
   generalized to other platforms, but for the sake of simplicity in
   testing, I'm focusing here first.

Much of this patch was paired with Manuel, and I credit him with the
majority of the work here.

Some important caveats that I'll be working on in subsequent patches:

1) This uses the host compiler rather than using the just-built-clang.
2) Currently only x86 is supported.
3) Currently, none of the tests are built or run.
4) Uses CMake's builtin globbing which doesn't update correctly.
5) This is still turned off from LLVM's CMake build until these issues
   are addressed

llvm-svn: 154060
2012-04-04 22:12:04 +00:00
Chandler Carruth 6acfaaf3aa Remove the old, and non-functional CMake build system from CompilerRT.
I cannot build any part of this successfully on either Linux or Darwin,
and the replacement is worlds simpler by requiring that this be built as
a subproject of LLVM. If this breaks you for any reason, please let me
know, and let me know what your use case is.

llvm-svn: 154059
2012-04-04 22:12:01 +00:00
Alexey Samsonov 61a331d594 [ASan] use correct C-version of strchr on Windows
llvm-svn: 154006
2012-04-04 11:36:47 +00:00
Benjamin Kramer 185f2edd70 Fix the build on 32 bit hosts.
- Add memcpy and memcmp to the stub headers.
- __uint128_t is not available on 32 bit platforms. It's also unused so just
  comment it out for now.

llvm-svn: 153779
2012-03-30 21:37:08 +00:00
Alexander Potapenko 4f1d3e8eaa Make sure NSObjects are allocated in a way that is visible to ASan.
llvm-svn: 153762
2012-03-30 17:31:15 +00:00