Commit Graph

876 Commits

Author SHA1 Message Date
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
David Chisnall 675de5d16c Initial commit of support functions for atomic operations.
llvm-svn: 153735
2012-03-30 08:35:32 +00:00
Alexander Potapenko c6eb6a8287 Add internal_memset and replace the uses of REAL(memset) with it where the performance allows.
llvm-svn: 153641
2012-03-29 12:20:47 +00:00
Alexey Samsonov b33c87bbb9 [ASan] interceptors for atoi/atol/atoll
llvm-svn: 153637
2012-03-29 08:04:35 +00:00
Kostya Serebryany b0414e0eff [asan] fix lint
llvm-svn: 153601
2012-03-28 21:03:34 +00:00
Kostya Serebryany 48c157c25a [asan] add racy double-free test
llvm-svn: 153586
2012-03-28 18:30:10 +00:00
Alexander Potapenko 8418de1689 Log the allocator messages at a higher verbosity level.
llvm-svn: 153514
2012-03-27 16:37:16 +00:00
Alexey Samsonov 0a4f8dc0cb [ASan] add interceptor for strtol
llvm-svn: 153444
2012-03-26 16:42:22 +00:00
Evgeniy Stepanov 4cc2631c7d Avoid including link.h.
It's not available on Android. We only use this header to find out if _DYNAMIC
is present; declaring it "extern void*" does the trick.

llvm-svn: 153431
2012-03-26 09:48:41 +00:00
Alexey Samsonov 1fd5dbc140 [ASan] use macro to define if we should intercept signal/sigaction
llvm-svn: 153430
2012-03-26 09:07:29 +00:00
Alexey Samsonov f71cb8d307 [ASan] revert r153378
llvm-svn: 153379
2012-03-24 10:12:58 +00:00
Alexey Samsonov 01da1055d3 [ASan] simplify ASAN_INTERCEPT_* definitions
llvm-svn: 153378
2012-03-24 09:47:56 +00:00
Alexey Samsonov 78481835ae [ASan] use ASAN_INTERCEPT_STRNLEN instead of defined(__APPLE__)
llvm-svn: 153377
2012-03-24 09:10:50 +00:00
Alexey Samsonov c8efe828a9 [ASan] add interceptor for strtoll
llvm-svn: 153376
2012-03-24 08:39:14 +00:00
Timur Iskhodzhanov 99cc6235bc [ASan/tests] Make 'noinline' and a bunch of other stuff portable
llvm-svn: 153333
2012-03-23 13:10:59 +00:00
Timur Iskhodzhanov f392910965 [ASan] replace '#if ... or ...' with '#if ... || ...'
llvm-svn: 153332
2012-03-23 12:21:47 +00:00
Timur Iskhodzhanov 72859836ab [ASan] Add a few more malloc-related interceptors for Windows
llvm-svn: 153327
2012-03-23 11:33:02 +00:00
Alexander Potapenko 83a689887e Handle two-byte short jumps in the relocated code.
After the instructions are moved to the branch island, fixupInstructions() expands every 2-byte ja/je instruction with a 1-byte offset into a 6-byte ja/je with 32-bit offset. The offset is fixed to point to the original function.

llvm-svn: 153249
2012-03-22 11:29:53 +00:00
Kostya Serebryany 3f56851f5c [asan] extend the test for long double bug
llvm-svn: 153190
2012-03-21 15:29:28 +00:00
Alexey Samsonov b8a047261c [asan] one more try to remove pthread.h from asan_interceptors.cc
llvm-svn: 153188
2012-03-21 15:02:39 +00:00
Alexey Samsonov 9113f3e000 [asan] add missing declarations from string.h and remove this header
llvm-svn: 153187
2012-03-21 14:33:15 +00:00
Alexey Samsonov abbcccc187 [asan] use extern declaraions of libc functions on Win and on Mac
llvm-svn: 153186
2012-03-21 14:22:28 +00:00
Alexey Samsonov ef50dfd6aa [asan]: remove signal.h system header from interceptors
llvm-svn: 153183
2012-03-21 13:44:39 +00:00
Alexey Samsonov 8ada45553d [asan]: substitute extern decls with system header in asan_mac.cc
llvm-svn: 153182
2012-03-21 13:00:04 +00:00
Alexey Samsonov 9ce04b0c36 [asan] merge mac-specific interceptors into one function
llvm-svn: 153180
2012-03-21 12:42:00 +00:00
Alexey Samsonov 5f7048b396 [asan]: remove asan_mac.h
llvm-svn: 153179
2012-03-21 12:29:54 +00:00
Alexey Samsonov 1d4145380e [asan]: start removing os-specific asan_mac.h - move inclusion of mac system header to asan_mac.cc
llvm-svn: 153178
2012-03-21 12:03:44 +00:00
Evgeniy Stepanov 823085a8f4 [asan] Support for %z to Printf()
At the moment, asan internal Printf() uses %l modifier for printing
values of size_t and related types. This works, because we control
both the implementation of Printf and all its uses, but can be a
little misleading.

This change adds support for %z to Printf(). All callers that print
sizes and pointers as integers are switched to %zu / %zx.

llvm-svn: 153177
2012-03-21 11:32:46 +00:00
Alexander Potapenko 1159250518 s/Printf/Report for libc interceptors (need this to debug the potential double interception)
llvm-svn: 153175
2012-03-21 09:33:05 +00:00
Alexey Samsonov 1479418407 [ASan] get rid of setjmp.h header in interceptors
llvm-svn: 153085
2012-03-20 11:40:09 +00:00
Alexey Samsonov c298b3674f [ASan]: remove GetMacosVersion from asan_mac.h header
llvm-svn: 153084
2012-03-20 10:54:40 +00:00
Alexey Samsonov cae79fbab9 [ASan]: re-enable noreturn attribute on posix
llvm-svn: 153082
2012-03-20 10:14:55 +00:00
Kostya Serebryany 74a908bb85 [asan] disable GetOwnershipStressTest on non-linux
llvm-svn: 152953
2012-03-16 22:15:22 +00:00
Kostya Serebryany af32a84b24 [asan] added an assert in InitializeAsanInterceptors (it should be run just once)
llvm-svn: 152945
2012-03-16 21:02:13 +00:00
Alexander Potapenko fa391a7df2 [ASan] Print the parsed ASAN_OPTIONS for verbosity>0.
Move the flags around slightly.

llvm-svn: 152929
2012-03-16 16:38:31 +00:00
Kostya Serebryany e059c124a8 [asan] one more -Wnull-conversion fix
llvm-svn: 152773
2012-03-15 04:26:00 +00:00
Kostya Serebryany 54a3cac5c5 [asan] fix unwinding inside libc intercepors (asan issue #46)
llvm-svn: 152768
2012-03-15 01:36:00 +00:00
Kostya Serebryany fd2037162e [asan] performance optimization: make sure the check for poisoned shadow inside inteceptors is inlined
llvm-svn: 152767
2012-03-15 01:18:06 +00:00
Kostya Serebryany baf68ffcf8 [asan] fix -Wnull-conversion warnings
llvm-svn: 152747
2012-03-14 22:48:09 +00:00
Timur Iskhodzhanov d8d9fd66c6 [ASan] Undo NORETURN on POSIX as it's not clear how to do this cleanly yet
llvm-svn: 152631
2012-03-13 16:48:46 +00:00
Timur Iskhodzhanov f0b7595e08 [ASan] Fix build error on Linux; screen-reviewed by glider@google.com
llvm-svn: 152629
2012-03-13 16:29:25 +00:00
Timur Iskhodzhanov 70df757918 [ASan/Win] Eliminate a couple of FIXMEs, add NORETURN to CheckFailed/UNIMPLEMENTED
llvm-svn: 152628
2012-03-13 16:12:03 +00:00
Timur Iskhodzhanov cf526ff278 [ASan/Win] Fix wrong memmove,memcpy,memset interceptor definitons
llvm-svn: 152622
2012-03-13 10:42:34 +00:00
Alexey Samsonov 8b5f7c5aa2 AddressSanitizer: fix a couple of typos
llvm-svn: 152617
2012-03-13 06:46:32 +00:00
Kostya Serebryany b0712f8e68 [asan] output test for memcmp
llvm-svn: 152594
2012-03-13 01:04:06 +00:00
Timur Iskhodzhanov 2f48b870f3 [ASan] Add back the support for /MT; intercept statically-linked functions
llvm-svn: 152557
2012-03-12 11:45:09 +00:00
Timur Iskhodzhanov fead7f5aa5 [ASan] Use WriteFile instead of fwrite in AsanWrite
llvm-svn: 152540
2012-03-11 12:45:12 +00:00
Kostya Serebryany b0f9354168 [asan] use O(log(N)) algorithm instead of O(N) in __asan_get_ownership
llvm-svn: 152467
2012-03-10 01:30:01 +00:00
Kostya Serebryany 8aff411add [asan] add a (disabled) stress test for __asan_get_ownership
llvm-svn: 152362
2012-03-09 01:48:18 +00:00
Kostya Serebryany f7fc1d4859 [asan]: fix off-by-one error in stack unwinder (asan issue #44; reproduced thanks to 'csmith' fuzzer)
llvm-svn: 152347
2012-03-08 22:25:08 +00:00
Kostya Serebryany c7835f301e [asan] don't use dl_iterate_phdr on linux, go back to using /proc/self/maps. Hopefully fixes the problem reported by our mozilla friends.
llvm-svn: 152341
2012-03-08 21:19:07 +00:00
Timur Iskhodzhanov bc08fed082 [ASan] Fix lint warning
llvm-svn: 152226
2012-03-07 11:33:15 +00:00
Timur Iskhodzhanov d8dd07f2ff [ASan/Win] Intercept _msize, required for running SQLite
llvm-svn: 152224
2012-03-07 11:19:26 +00:00
Alexander Potapenko b780ad9117 Force __asan_handle_no_return into the binary built with ASan.
llvm-svn: 152117
2012-03-06 11:45:59 +00:00
Eli Friedman e781266905 Make sure to properly ifdef out an unused function on OSX < 10.6. PR12136. Patch from Jeremy Huddleston.
llvm-svn: 152085
2012-03-06 01:21:14 +00:00
Daniel Dunbar 030e0a866c platform/clang_darwin: Fix a comment.
llvm-svn: 152058
2012-03-05 20:46:09 +00:00
Daniel Dunbar cdf9bf7048 make/clang_darwin: Tweak CheckArches function to force the integrated-as and use
the stub SDK to try and ensure we always pick up the right archs when they
should be able to be used.
 - Also, warn when we drop an architecture.

This is a reapplication of r150232 that should stick now that we have the
integrated assembler on for ARM.

llvm-svn: 152057
2012-03-05 20:46:06 +00:00
Evgeniy Stepanov f485c3ccbd [asan] Add a negative test for memcpy of long double.
llvm-svn: 151888
2012-03-02 10:42:10 +00:00
Alexander Potapenko 8e9d772c5a Force __asan_set_death_callback into the resulting binary.
llvm-svn: 151808
2012-03-01 14:39:21 +00:00
Timur Iskhodzhanov 972720e564 [ASan] Replace CRT .dll malloc with our implementation at asan_init() time
llvm-svn: 151715
2012-02-29 11:43:03 +00:00
Alexander Potapenko 7e07f56811 Introduce __asan_set_error_report_callback() to allow the client program post-process the error reports.
If the callback is set, Report() and Printf() print the reports into a buffer (together with stderr), which is then passed to the client.

llvm-svn: 151528
2012-02-27 14:06:48 +00:00
Evgeniy Stepanov d84e16e6a3 Replace some #ifdef(s) with plain if(s).
llvm-svn: 151526
2012-02-27 13:07:29 +00:00
Alexey Samsonov a1a3a2ffc3 AddressSanitizer: add some checks to AsanChunkFifoList::PushList
llvm-svn: 151521
2012-02-27 09:06:10 +00:00
Kostya Serebryany 6ad2115575 [asan] don't compile gtest with asan when building asan tests
llvm-svn: 151391
2012-02-24 20:49:36 +00:00
Timur Iskhodzhanov 0f9c9a5332 [ASan] Intercept CreateThread on Windows
llvm-svn: 151366
2012-02-24 15:28:43 +00:00
Alexey Samsonov 53e191e77e AddressSanitizer: quick fix - undef INT32_MIN etc to avoid macro redefinition
llvm-svn: 151165
2012-02-22 16:12:46 +00:00
Alexey Samsonov d6651509d0 AddressSanitizer: get rid of stdlib.h and add (smaller) stddef.h instead
llvm-svn: 151162
2012-02-22 14:07:06 +00:00
Timur Iskhodzhanov 36d297d27f [ASan] Intercept functions on Windows - first version
llvm-svn: 151161
2012-02-22 13:59:49 +00:00
Alexey Samsonov a5b3130e86 AddressSanitizer: get rid of limits.h, use constants for fixed size integral types instead.
llvm-svn: 151159
2012-02-22 12:54:04 +00:00
Evgeniy Stepanov abaf196be3 [asan] Remove mentions of pthread*_t from interceptors.
Some platforms do not define pthread_t in stdlib.h.

llvm-svn: 151158
2012-02-22 12:31:25 +00:00
Alexey Samsonov 2df8afa075 AddressSanitizer: fix Makefile.old - gtest should depend on libasan
llvm-svn: 151157
2012-02-22 11:59:44 +00:00
Timur Iskhodzhanov 94602b48ee [ASan] Fix style + suppress 'long' lint warnings
llvm-svn: 151149
2012-02-22 09:28:14 +00:00
Evgeniy Stepanov d179ec614e Update source code links in LICENSE.TXT.
mach_override has been moved to a different path.
sysinfo is gone.

llvm-svn: 151148
2012-02-22 09:21:02 +00:00
Alexander Potapenko 2c0ed61c7a Move the contents of AsanProcMaps::Dump() into AsanDumpProcessMaps() for Posix systems.
Define AsanDumpProcessMaps as unimplemented on Windows.

This should fix the Windows build.

llvm-svn: 151147
2012-02-22 09:11:55 +00:00
Timur Iskhodzhanov 3a32ed913b [ASan] Fix a wrong filename mentioned in a comment
llvm-svn: 151145
2012-02-22 08:56:25 +00:00
Alexander Potapenko c259ab3cac Dump the process memory map if any of the mappings interleaves with the shadow.
llvm-svn: 151141
2012-02-22 08:27:32 +00:00
Alexander Potapenko fce2ca9f66 Add AsanProcMaps::Dump()
llvm-svn: 151139
2012-02-22 08:13:47 +00:00
Timur Iskhodzhanov a1c987ff38 [ASan] Add __asan_init to the list of C dynamic initializers to support /MD on Windows
llvm-svn: 151059
2012-02-21 16:24:23 +00:00
Alexander Potapenko 47038cae29 Fix the lib32 and lib64 targets.
llvm-svn: 151057
2012-02-21 14:11:52 +00:00
Timur Iskhodzhanov f2061453bd [ASan] Remove one FIXME - re-enable "free-not-malloced" reports on Windows
llvm-svn: 151051
2012-02-21 09:58:39 +00:00
Alexander Potapenko 0be25d562c Check that the FakeStack size is non-zero before looking into it.
Sometimes DescribeStackAddress is called before another thread's FakeStack is initialized, which could previously cause a check to fire.

llvm-svn: 151046
2012-02-21 08:45:41 +00:00
Alexey Samsonov 789456bf68 AddressSanitizer: Don't include GrandCentralDispatch headers in asan headers on Mac
llvm-svn: 151044
2012-02-21 08:30:57 +00:00
Alexey Samsonov 2d2f1711b7 AddressSanitizer: don't use /tmp for temporary file in output tests.
llvm-svn: 151042
2012-02-21 07:08:38 +00:00
Alexey Samsonov 0d0b406aba AddressSanitizer: use custom strtol/atoll functions
llvm-svn: 150812
2012-02-17 16:15:09 +00:00
Alexey Samsonov 8e7bfceb98 AddressSanitizer: fix lint
llvm-svn: 150802
2012-02-17 08:31:10 +00:00
Alexey Samsonov fbb50f19ad AddressSanitizer: revert r150683 - we can't get rid of headers that easily
llvm-svn: 150699
2012-02-16 17:00:45 +00:00
Evgeniy Stepanov 5d47e9164c [asan] Allocator tweaks for low memory systems.
llvm-svn: 150689
2012-02-16 13:35:11 +00:00
Alexey Samsonov ca37969c24 AddressSanitizer: don't include pthread.h and signal.h in interceptors on Mac
llvm-svn: 150683
2012-02-16 11:26:52 +00:00
Kostya Serebryany 10dbd68bd2 [asan] don't do AsanDie twice
llvm-svn: 150641
2012-02-16 00:40:18 +00:00
Alexey Samsonov 1e7e2370aa AddressSanitizer: don't include pthread.h in asan_interceptors.cc on Linux
llvm-svn: 150573
2012-02-15 09:14:26 +00:00
Alexey Samsonov 278c25f241 AddressSanitizer: simplify IntervalsAreSeparate function
llvm-svn: 150569
2012-02-15 08:27:34 +00:00
Timur Iskhodzhanov d2a9075de0 [ASan] Define an internal implementation of strchr to make stack OOB tests pass on Windows
llvm-svn: 150499
2012-02-14 19:33:04 +00:00
Evgeniy Stepanov 2ee5950dd0 [asan] Add lots of missing visibility attributes.
llvm-svn: 150479
2012-02-14 13:46:06 +00:00
Kostya Serebryany fcd535ba6c [asan] implement __asan_set_death_callback
llvm-svn: 150414
2012-02-13 21:24:29 +00:00
Alexander Potapenko 438447a7f3 Fix compilation on Mac.
llvm-svn: 150400
2012-02-13 17:14:31 +00:00
Alexander Potapenko 234d8c2168 Lint fix
llvm-svn: 150399
2012-02-13 17:11:19 +00:00
Alexander Potapenko 720aaefb8d Move the non-trivial implementation of AsanShadowRangeIsAvailable to asan_mac.cc
to avoid crashes on Linux and Win.

llvm-svn: 150398
2012-02-13 17:09:40 +00:00
Alexander Potapenko ef4521e239 Check whether the shadow memory range intersects with an existing mapping.
This should help to detect problems with ASLR or linker tricks early.

llvm-svn: 150391
2012-02-13 15:11:23 +00:00
Alexey Samsonov ea308d876b AddressSanitizer: re-enable lint for output tests
llvm-svn: 150386
2012-02-13 14:18:36 +00:00
Alexey Samsonov 54671b63be AddressSanitizer: fix llvm headers in output tests
llvm-svn: 150385
2012-02-13 14:05:07 +00:00
Alexey Samsonov 633c8be0ae AddressSanitizer: remove match_output.py, split expected output into OS-specific and OS-independent parts
llvm-svn: 150384
2012-02-13 13:59:24 +00:00
Evgeniy Stepanov c5d845dc09 [asan] Add a missing include.
llvm-svn: 150382
2012-02-13 12:37:56 +00:00
Evgeniy Stepanov 450c123218 [asan] Add a missing return.
It is technically reachable on Android, where pthread_exit is not
marked noreturn.

llvm-svn: 150381
2012-02-13 12:36:44 +00:00
Alexey Samsonov 92a0b806a6 AddressSanitizer: Convert templates for output tests to FileCheck format and move them inside sources
llvm-svn: 150375
2012-02-13 12:21:58 +00:00
Evgeniy Stepanov b25d0d2318 [asan] Return type of index() is char*.
This is important for Android, where we can't keep system headers
from leaking into asan_interceptors.cc.

llvm-svn: 150374
2012-02-13 12:12:32 +00:00
Evgeniy Stepanov da7522b551 [asan] Disable signal&sigaction interceptors on Android.
llvm-svn: 150373
2012-02-13 12:04:36 +00:00
Evgeniy Stepanov 45fd36110b [asan] Default visibility for __asan_handle_no_return.
llvm-svn: 150372
2012-02-13 11:55:24 +00:00
Evgeniy Stepanov 56ae29f92d [asan] Fix a crash in GetCurrent() of an undead thread.
llvm-svn: 150371
2012-02-13 11:53:24 +00:00
Alexey Samsonov 6e6083f4b1 AddressSanitizer: fix path to FileCheck in makefiles
llvm-svn: 150368
2012-02-13 09:14:31 +00:00
Alexey Samsonov b30df37ebf AddressSanitizer: move output tests to a separate directory
llvm-svn: 150367
2012-02-13 08:50:21 +00:00
Alexey Samsonov f9affd3a0c AddressSanitizer: Use FileCheck instead of grep for pure C output tests
llvm-svn: 150366
2012-02-13 08:27:10 +00:00
Bob Wilson e67004e2f1 Back out some changes that accidentally committed.
llvm-svn: 150254
2012-02-10 16:41:46 +00:00
Bob Wilson ddd971564e Revert r150232 since it breaks the build when there's no ARM assembler.
llvm-svn: 150253
2012-02-10 16:36:49 +00:00
Daniel Dunbar d205200d41 make/clang_darwin: Tweak CheckArches function to force the integrated-as and use
the stub SDK to try and ensure we always pick up the right archs when they
should be able to be used.
 - Also, warn when we drop an architecture.

llvm-svn: 150232
2012-02-10 06:00:35 +00:00
Timur Iskhodzhanov 7ce3e5bb8e [asan] The first version of the RTL for Windows, reviewed at http://codereview.appspot.com/5647052
llvm-svn: 150185
2012-02-09 17:20:14 +00:00
Timur Iskhodzhanov bc9bb3f581 Test commit + fix an obvious typo
llvm-svn: 150184
2012-02-09 16:29:41 +00:00
Alexey Samsonov 9654367cbc AddressSanitizer: move mach_override inside interception library
llvm-svn: 150171
2012-02-09 11:36:12 +00:00
Kostya Serebryany 0394da7bea [asan] unpoison the stack before every noreturn call. Fixes asan issue 37. rt part
llvm-svn: 150101
2012-02-08 21:33:27 +00:00
Alexey Samsonov 8489f2a564 AddressSanitizer: start factoring out interception machinery
llvm-svn: 150083
2012-02-08 19:52:01 +00:00
Alexander Potapenko 1da11ec357 Move the _ReturnAddress definition out of the __asan:: namespace
Patch by Timur Iskhodzhanov (timurrrr@google.com)

llvm-svn: 150075
2012-02-08 14:14:18 +00:00
Alexey Samsonov e725478e2f AddressSanitizer: replace all "real_X" calls with "REAL(X)"
llvm-svn: 150073
2012-02-08 13:45:31 +00:00
Alexander Potapenko 42cdb7e640 Typo fix: s/SNPrint/SNPrintf
llvm-svn: 150069
2012-02-08 11:45:09 +00:00
Kostya Serebryany 9716914b2d [asan] better warning messages for double-free bugs (provide allocation/deallocation stack traces)
llvm-svn: 150027
2012-02-08 00:42:29 +00:00
Kostya Serebryany f98fc08bc7 [asan] GET_CALLER_PC macro for Win. Patch by timurrrr@google.com
llvm-svn: 149994
2012-02-07 18:23:54 +00:00
Kostya Serebryany d61255638f [asan] print 'ALL TESTS PASSED' in makefile when running tests (convenience)
llvm-svn: 149990
2012-02-07 17:36:07 +00:00
Kostya Serebryany 614b53de1b [asan] don't crash if /proc/self/maps has enormous size (linux)
llvm-svn: 149944
2012-02-07 00:47:35 +00:00
Kostya Serebryany b5eb5a7a05 [asan] make sure the AsanThread object is destroyed if pthread_exit is called
llvm-svn: 149940
2012-02-07 00:27:15 +00:00
Kostya Serebryany 546ba363ea [asan] use raw syscalls for open/close on linux to avoid being intercepted
llvm-svn: 149892
2012-02-06 19:23:38 +00:00
Kostya Serebryany 9ff28d661d [asan] The first version of Windows malloc interceptors, patch by timurrrr@google.com
llvm-svn: 149875
2012-02-06 17:56:38 +00:00
Nick Kledzik 686f0d17a6 On Apple platforms, wire up compilerrt_abort() to log file and function info
llvm-svn: 149723
2012-02-03 23:53:40 +00:00
Nick Kledzik a2b846c000 Remove __attribute__((weak)) on function prototype. It has a different meaning on prototypes then it does on definitions. It is not needed on the prototype and causes build failures for static codegen
llvm-svn: 149720
2012-02-03 23:10:55 +00:00
Alexey Samsonov f9fef3d275 AddressSanitizer: simplify RoundUpToPowerOfTwo/clz; add a couple of CHECKs for real_X calls. Patch by timurrrr@google.com
llvm-svn: 149687
2012-02-03 08:50:16 +00:00
Alexey Samsonov 23e3b90319 AddressSanitizer: Replace __attribute__ with macro (for Win compatibility). Patch by timurrrr@google.com
llvm-svn: 149686
2012-02-03 08:37:19 +00:00
Alexey Samsonov 15965f9c3d AddressSanitizer: Add macro for definition/declaration of interceptors
llvm-svn: 149602
2012-02-02 10:39:40 +00:00
Alexander Potapenko c97434ecaf Disable wrapping memcpy() on Mac OS Lion, where it
actually falls back to memmove.
In this case we still need to initialize real_memcpy, so we set it to
real_memmove
We check for MACOS_VERSION_SNOW_LEOPARD, because currently only Snow
Leopard and Lion are supported.

llvm-svn: 149492
2012-02-01 10:07:52 +00:00
Alexander Potapenko f504602a0f Disables testing memcpy() on Mac OS 10.7,
where memcpy() in fact aliases memmove() and thus calling it with
overlapping parameters is not an error.

llvm-svn: 149491
2012-02-01 09:47:40 +00:00
Kostya Serebryany 9160b5059b [asan] fix the wrong __WORDSIZE definition on Win x64, add ASAN_INTERFACE_FUNCTION_ATTRIBUTE. Patch by timurrrr@google.com
llvm-svn: 149395
2012-01-31 18:13:50 +00:00
Kostya Serebryany 7e7d0ca1a2 [asan] remove dead code
llvm-svn: 149392
2012-01-31 17:29:02 +00:00
Alexander Potapenko 81203bdb33 Implement GetMacosVersion() to obtain the OS X version at runtime.
llvm-svn: 149382
2012-01-31 13:19:18 +00:00
Kostya Serebryany ad1fccdb1c [asan] tests should not require the asan-rt to be built with debug info
llvm-svn: 149330
2012-01-31 01:56:58 +00:00
Kostya Serebryany bca91defcb [asan] new run-time flag: sleep_before_dying (asan Issue #31)
llvm-svn: 149306
2012-01-31 00:52:18 +00:00
Kostya Serebryany 9aca3b0d2f [asan] re-enable the test for ObjC initialization bug
llvm-svn: 149302
2012-01-30 23:55:46 +00:00
Kostya Serebryany 39ba3f724f [asan] fix issue 35: don't let the optimizer to optimize the test code away.
llvm-svn: 149296
2012-01-30 23:23:26 +00:00
Kostya Serebryany fed83c5755 [asan] ifdef/include cleanup
llvm-svn: 149281
2012-01-30 22:11:04 +00:00
Kostya Serebryany cf2c65aa8e [asan] add a test for __attribute__ no_address_safety_analysis
llvm-svn: 149278
2012-01-30 21:34:59 +00:00
Kostya Serebryany 510850c345 [asan] minor ifdef cleanup
llvm-svn: 149274
2012-01-30 20:55:02 +00:00
Alexey Samsonov 2dcef2d2a8 AddressSanitizer: Enforce default visibility for all libc interceptors
llvm-svn: 149247
2012-01-30 13:42:44 +00:00
Alexander Potapenko 81ebb0aafb Add a mask for "cmpb $imm, (%rdi)" on x86_64
llvm-svn: 149245
2012-01-30 12:49:00 +00:00
Anton Korobeynikov 28037ceacf Proper divmod implementation
llvm-svn: 149242
2012-01-30 10:21:51 +00:00
Anton Korobeynikov b047b04c4c Provide aeabi_mem* functions.
llvm-svn: 149241
2012-01-30 10:21:23 +00:00
Alexander Potapenko f519564d7c Make compiler-rt/trunk/lib/asan compileable with Visual Studio 2008 on Windows.
Patch by Timur Iskhodzhanov (timurrrr@google.com)

To test:
$ cl /c *.c*
in the asan directory.

The code fails to link if you omit the "/c" part but that's one of the
next steps,
as well as a few TODO's I've put into the Windows-specific code.

llvm-svn: 149130
2012-01-27 15:15:04 +00:00
Alexander Potapenko 13d95d5e5a Make compiler-rt/trunk/lib/asan compileable with g++.
Patch by Timur Iskhodzhanov (timurrrr@google.com)

The double-extern thing is
http://llvm.org/bugs/show_bug.cgi?id=11869

And the #include <string[s].h> are only needed on Mac (see comments in
the original code)
and also including them might make strchr/index conflict with the g++
system headers (which don't follow the man pages, ouch!)

llvm-svn: 149129
2012-01-27 10:52:37 +00:00
Alexander Potapenko fabfcd8bea Darwin-specific templates for the output tests.
These should fix the output tests on Mac.

llvm-svn: 149068
2012-01-26 17:40:18 +00:00
Alexander Potapenko 02a71626e3 More accurate atos execution which depends on the file type (EXECUTE, DYLIB) of the binary.
More Linux-like output on Mac (to match more output tests).

llvm-svn: 149064
2012-01-26 17:06:50 +00:00
Alexander Potapenko 98f0c713d9 Fix a bug in AsanProcMaps on Mac: on 64 bits the program was trying to read twice as many segment load commands as the binary actually contained.
llvm-svn: 149063
2012-01-26 17:01:20 +00:00
Alexander Potapenko 1f397fb87f Tune asan_symbolize.py to symbolize 64-bit binaries correctly.
Add the DEBUG flag to test_output.sh

llvm-svn: 148798
2012-01-24 10:44:44 +00:00
Kostya Serebryany 586ade114b [asan] use internal_strcmp before asan_init is done. *may* fix asan issue #30
llvm-svn: 148726
2012-01-23 21:20:05 +00:00
Kostya Serebryany f9418f9679 [asan] test that -fno-optimize-sibling-calls helps to get sane stack traces
llvm-svn: 148714
2012-01-23 18:44:34 +00:00
Alexander Potapenko 046ecc06be Wrap CFStringCreateCopy to prevent copying constant CF strings.
This should fix http://code.google.com/p/address-sanitizer/issues/detail?id=10

llvm-svn: 148696
2012-01-23 10:09:54 +00:00
Alexander Potapenko f9392011c8 Add a test for CFStringCreateCopy.
Normally this function should not create copies of constant strings, but it does when the default CFAllocator
is replaced (e.g. under AddressSanitizer)

This test is related to http://code.google.com/p/address-sanitizer/issues/detail?id=10

llvm-svn: 148695
2012-01-23 10:06:14 +00:00
Evgeniy Stepanov 3f6840745c Make the Android TSD workaround more reliable.
By scanning the thread list backwards.

llvm-svn: 148476
2012-01-19 13:57:45 +00:00
Evgeniy Stepanov d296ad4e16 Workaround the self-cleaning TSD on Android.
llvm-svn: 148475
2012-01-19 13:37:31 +00:00
Alexander Potapenko 62b0d70e56 Remove a debugging Report() call.
llvm-svn: 148474
2012-01-19 13:34:15 +00:00
Alexander Potapenko 3825e9770b Minor fixes of the AsanProcMaps code on Mac:
-- make the load command scan linear (instead of quadratic)
 -- do not create a nested AsanProcMaps instance for each address lookup
 -- more comments

llvm-svn: 148472
2012-01-19 12:44:06 +00:00
Evgeniy Stepanov 84c44a8b8b EHABI-based stack trace on ARM.
The change removes the unused FLAG_fast_unwind, and forces EHABI-based unwind
on ARM, and fast (FP-based) unwind everywhere else.

llvm-svn: 148468
2012-01-19 11:34:18 +00:00
Alexey Samsonov 0ac73fc9f8 AddressSanitizer: return false instead of true for __asan_get_ownership(NULL)
llvm-svn: 148394
2012-01-18 15:26:55 +00:00
Alexander Potapenko 38da9a04f5 Delete sysinfo/* and all references to it.
llvm-svn: 148386
2012-01-18 11:42:30 +00:00
Alexander Potapenko 4257386879 Implement AsanProcMaps for Mac OS. The code from sysinfo/ is not needed anymore and should be cleaned up.
llvm-svn: 148385
2012-01-18 11:16:05 +00:00
Kostya Serebryany 5767f0f113 [asan] workaround for bug http://llvm.org/bugs/show_bug.cgi?id=11763. Do not bark on memcpy(a, a, size).
llvm-svn: 148318
2012-01-17 18:43:52 +00:00
Kostya Serebryany 86d4492627 [asan] fix ReadFileToBuffer to correctly handle files from /proc/ (asan issue 27)
llvm-svn: 148311
2012-01-17 18:00:07 +00:00
Alexey Samsonov 67d508d083 Revert commit 148304
llvm-svn: 148305
2012-01-17 14:01:15 +00:00
Alexey Samsonov 1e310295d0 AddressSanitizer: from this patch, ASan allocator returns false for __asan_get_ownership(NULL) and produce error reports for malloc_usable_size(NULL) and __asan_get_allocated_size(NULL)
llvm-svn: 148304
2012-01-17 13:31:54 +00:00
Alexander Potapenko 2b2e0721d7 Define the bounds of the branch allocator memory space for 32-bit apps.
llvm-svn: 148303
2012-01-17 09:38:54 +00:00
Alexey Samsonov 209c514a1d AddressSanitizer: add support for malloc_usable_size() function
llvm-svn: 148287
2012-01-17 06:39:10 +00:00
Alexey Samsonov 2d3a67b73b AddressSanitizer: create AsanThreadSummary together with AsanThread (in parent thread)
llvm-svn: 148286
2012-01-17 06:35:31 +00:00
Evgeniy Stepanov 1b65b17bf5 [asan] Implement GetObjectNameAndOffset on ARM.
llvm-svn: 148236
2012-01-16 12:45:07 +00:00
Alexey Samsonov 50bf956f29 AddressSanitizer: fix recently introduced lint errors and broken test on Mac.
llvm-svn: 148235
2012-01-16 12:38:09 +00:00
Evgeniy Stepanov 2227207c83 Disable posix_memalign test on Android.
llvm-svn: 148234
2012-01-16 12:19:51 +00:00
Alexander Potapenko bd53f597de This patch adds two methods, __asan_allocate_island and __asan_deallocate_island
and switches our interceptors to using them instead of the default
vm_allocate-based approach used by mach_override_ptr.

To simplify the code, a fixed memory mapping is used for the allocation pool --
note that we can't mmap an arbitrary chunk of memory, because the shadow memory hasn't been mapped yet
(for the reasons discussed in http://code.google.com/p/address-sanitizer/issues/detail?id=24, we cannot map the shadow earlier)

The patch drops the program startup time from several second to half a second,
which speeds up the execution of ASan tests noticeably.
Because of the virtual memory size occupied by the programs it's hard
to speed up the shutdown time, which would've also helped the tests.

llvm-svn: 148116
2012-01-13 16:13:58 +00:00
Alexander Potapenko 9301db4baa Add __asan_mach_override_ptr_custom, which allows to inject a custom memory allocator into mach_override_ptr().
llvm-svn: 148115
2012-01-13 15:31:37 +00:00
Alexander Potapenko 553c208d22 This patch moves the code reading /proc/self/environ into AsanGetEnv
in asan_linux.cc, because /proc is unavailable on Mac.
Instead the Mac version of AsanGetEnv iterates over the array of
environment variables obtained from _NSGetEnviron()

llvm-svn: 148114
2012-01-13 12:59:48 +00:00
Anton Korobeynikov 48cfd55c5d Add some basic mingw support.
Patch by Ruben Van Boxem! 

llvm-svn: 148048
2012-01-12 21:13:48 +00:00
Evgeniy Stepanov 837fe5bcc9 Call asan_init from .preinit_array.
Protected by an #ifdef, disabled by default.

llvm-svn: 147932
2012-01-11 08:17:19 +00:00
Alexey Samsonov 5d5fa5115a Test commit. Minor cleanup in AsanThread
llvm-svn: 147930
2012-01-11 08:07:51 +00:00
Kostya Serebryany 41cdb8614c [asan] remove OS-dependent headers from asan_internal.h
llvm-svn: 147919
2012-01-11 02:39:16 +00:00
Kostya Serebryany 0c8fa7b8ed [asan] remove OS-dependent includes from asan_interceptors.h
llvm-svn: 147916
2012-01-11 02:32:40 +00:00
Kostya Serebryany 1dd51b53b2 [asan] move TSD code into asan_posix.cc
llvm-svn: 147913
2012-01-11 02:21:06 +00:00
Kostya Serebryany 332923be32 [asan] get rid of the scary TSD destructor code. Now, we store the leaky AsanThreadSummary in TSD and never remove it from there.
llvm-svn: 147910
2012-01-11 02:03:16 +00:00
Kostya Serebryany 258d7b4182 [asan] hopefully fix the build on MacOS 10.6 (the code did work on 10.7, where I tested it)
llvm-svn: 147896
2012-01-10 23:36:59 +00:00
Kostya Serebryany a82f0d4950 [asan] move OS-dependent code away from asan_lock.h
llvm-svn: 147878
2012-01-10 21:24:40 +00:00
Kostya Serebryany edb4a8a128 [asan] don't include unistd.h in the headers
llvm-svn: 147811
2012-01-09 23:11:26 +00:00
Kostya Serebryany 3a55cfacf1 [asan] temporary reinstate string.h/strings.h. Removal of those caused a Mac build failulre which I failed to observe before the commit
llvm-svn: 147810
2012-01-09 22:45:05 +00:00
Kostya Serebryany d9cb2f13b3 [asan] don't include string.h and strings.h
llvm-svn: 147809
2012-01-09 22:36:51 +00:00
Kostya Serebryany 65518014e2 [asan] don't use strstr/strncat from libc, use our own versions instead
llvm-svn: 147807
2012-01-09 22:20:49 +00:00
Kostya Serebryany 3ab81d1f26 [asan] fix mac build once more
llvm-svn: 147796
2012-01-09 19:50:06 +00:00
Kostya Serebryany 3e559e87a4 [asan]: fix typo from previous commit
llvm-svn: 147793
2012-01-09 19:41:15 +00:00
Kostya Serebryany ba41e8d2c5 [asan]: fix mac build
llvm-svn: 147792
2012-01-09 19:35:11 +00:00
Kostya Serebryany 5be458ccfd [asan] refactoring: move some common linux/mac code to asan_posix.cc
llvm-svn: 147788
2012-01-09 19:18:27 +00:00
Kostya Serebryany 9fd01e5ea5 [asan] refactoring: move all interceptors to a single file
llvm-svn: 147784
2012-01-09 18:53:15 +00:00
Kostya Serebryany 3f4b9bb4a0 [asan] do not use new/delete for the internal thread structure
llvm-svn: 147674
2012-01-06 19:44:11 +00:00
Kostya Serebryany 25d6c1b3c3 [asan] move more code into OS-specific files
llvm-svn: 147671
2012-01-06 19:11:09 +00:00