Commit Graph

2880 Commits

Author SHA1 Message Date
Dmitry Vyukov b7c6f49364 tsan: remove non-existent functions from syms file
llvm-svn: 185077
2013-06-27 13:52:50 +00:00
Evgeniy Stepanov f5cae53057 [msan] Optionally disable 2 tests (dlopen & gethostbyname).
llvm-svn: 185076
2013-06-27 13:21:00 +00:00
Evgeniy Stepanov 815d3232a7 [sanitizer] Fix dirent interceptors.
The new version reads d_reclen for (struct dirent) size.

llvm-svn: 185067
2013-06-27 09:37:27 +00:00
Alexey Samsonov 895784a5b0 [LSan] Add the way to disable LSan at link time
llvm-svn: 185066
2013-06-27 09:35:50 +00:00
Alexey Samsonov ecdcf11bd6 [TSan] try to fix Go build
llvm-svn: 185063
2013-06-27 07:57:53 +00:00
Alexey Samsonov ed4594b76a [MSan] Rename __msan_unpoision_param to __msan::UnpoisonParam - it shouldn't be in interface
llvm-svn: 185062
2013-06-27 07:50:56 +00:00
Sergey Matveev 0b2ffe30e4 [tsan] Fix build.
llvm-svn: 184963
2013-06-26 16:49:34 +00:00
Bob Wilson c4b26ad006 Revert "Temporarily disable building the armv7 variants of profile_ios on"
This reverts commit r184816.  With Chandler's change in r184929, this should
no longer be necessary.

llvm-svn: 184961
2013-06-26 16:35:16 +00:00
Sergey Matveev d109eb052b [tsan] Move some suppressions-related code to common.
Factor out code to be reused in LSan. Also switch from linked list to vector.

llvm-svn: 184957
2013-06-26 15:37:14 +00:00
Evgeniy Stepanov 06d6c25141 [sanitizer] readdir and readdir_r interceptors.
llvm-svn: 184950
2013-06-26 15:00:53 +00:00
Kostya Serebryany 6a068a715d [asan] initialize fake_stack lazily and increase its maximal size. This makes -fsanitize=address,use-after-return more robust: all SPEC tests pass now. In the default mode thread stacks become a bit smaller.
llvm-svn: 184934
2013-06-26 12:16:05 +00:00
Chandler Carruth fc9d259c98 Revert the Darwin half of r184805: "Remove the sysroot (or isysroot)
restriction from the GCDAProfile.c"

Bill added a much more effective way of coping with the use of errno and
other system interactions for Darwin for now by disabling it on that
platform. Building against the SDK stuff is more fundamental to the
darwin build process.

llvm-svn: 184929
2013-06-26 10:05:37 +00:00
Evgeniy Stepanov b598c0b527 [sanitizer] Reformat line >80 chars.
llvm-svn: 184926
2013-06-26 09:16:45 +00:00
Evgeniy Stepanov 2c7d4d379e [sanitizer] Fix build with OSS4 kernel headers.
This fixes PR16453.

llvm-svn: 184925
2013-06-26 08:16:38 +00:00
Chandler Carruth fa95cc916f Fix a use after free I introduced and that Bill caught in code review
(thanks!) by deferring the free of the filename until we finish writing
the coverage data to that file.

Bill, let me know if you'd prefer a different approach!

llvm-svn: 184895
2013-06-26 00:26:16 +00:00
Bill Wendling 90c38bcf58 Don't use 'errno.h' on Apple just yet. This breaks for some of our buildbots.
llvm-svn: 184878
2013-06-25 21:08:40 +00:00
Dmitry Vyukov eb95448245 tsan: add missing __attribute__((visibility("default"))) to interface functions
llvm-svn: 184858
2013-06-25 15:36:25 +00:00
Sergey Matveev c3332bc8c3 [lsan] Define interceptors more correctly. Also, always clear allocated memory.
llvm-svn: 184849
2013-06-25 14:05:52 +00:00
Evgeniy Stepanov 982d56abb8 [sanitizer] Move log_path to common flag and use it in MSan.
llvm-svn: 184836
2013-06-25 13:50:44 +00:00
Chandler Carruth 825abd8649 Temporarily disable building the armv7 variants of profile_ios on
darwin.

After talking with Jim Grosbach pretty extensively, he was OK with me
punting on this to the Apple folks.

We agreed that the correct fix is either to extend the fake SDK headers
in compiler-rt to support the rest of libc needed by GCDAProfiling.c or
to teach the make build to test for the existence of a suitable SDK on
the system prior to building it. Both of these require someone with
access to the SDK which I don't have, and the latter (my preferred
solution) requires understanding the strange compiler-rt make build
system. Punting to Dan Dunbar or one of the others who support this
stuff on ios to write the appropriate fix, and we can let the build bots
proceed in the mean time.

llvm-svn: 184816
2013-06-25 02:15:14 +00:00
Chandler Carruth ffdf342728 Remove the sysroot (or isysroot) restriction from the GCDAProfile.c
runtime in the Makefile build system as well. Sorry for the temporary
fallout, it took me a while to find these bits.

Bill, I'm not at all confident of the change for Darwin and iOS, but as
discussed we're completely blocked on fixing this. Anyways, please
review and let me know if this will work for you guys. If necessary,
I can work with you to rig up an errno.h stub for Darwin, but I expect
that to be... moderately challenging.

llvm-svn: 184805
2013-06-25 00:57:06 +00:00
Chandler Carruth a26c814953 Address a few of the issues in GCDAProfiling I noted when looking
through Bill's patch:

1) Correctly test the file descriptor after the sceond attempt at
   creating the file.
2) Make the filename a global so that we can issue error messages from
   other routines.
3) Check errno in several places and print it out so that errors are
   easier to track down.

I don't really expect any of these to fix the current failures I'm
seeing, but I'm hopeful they'll at least let me debug them.

llvm-svn: 184799
2013-06-25 00:37:32 +00:00
Chandler Carruth 9fcb41d0fa Remove the sysroot restriction from building GCDAProfiling.c.
We really need the C standard library to be available to implement the
profiling runtime library reasonably, and replicating everything in the
SDKs tree really isn't addressing any problems we have. Notably, all of
the sanitizer runtimes take the same approach, and this isn't a library
which could end up in a bootstrapping problem where the system headers
aren't even available.

This will hopefully prevent subsequent changes which start using various
other bits of C standard library to make things more debuggable.

llvm-svn: 184798
2013-06-25 00:37:28 +00:00
Dmitry Vyukov 5001d43dcb tsan: make the test more robust
currently it episodically fails
the hypothesis it is due to racy race detection algorithm
the sleep should make it more robust

llvm-svn: 184752
2013-06-24 16:28:02 +00:00
Dmitry Vyukov b4711b2c24 tsan: update dynamic export syms file
now it includes proper functions (including interceptors)
and does not include local functions that lead to build failures

llvm-svn: 184747
2013-06-24 15:17:36 +00:00
Evgeniy Stepanov 60d964d4f2 [sanitizer] Intercept sysinfo.
llvm-svn: 184739
2013-06-24 14:25:33 +00:00
Evgeniy Stepanov 8fb2c264a2 [sanitizer] Fix TSan build.
llvm-svn: 184736
2013-06-24 14:03:13 +00:00
Evgeniy Stepanov 02a7460d12 [sanitizer] Intercept inet_aton.
llvm-svn: 184735
2013-06-24 13:56:14 +00:00
Evgeniy Stepanov 830550ce4c [msan] Unpoison param-tls in signal handler wrapper.
This an entry point from uninstrumented code.

llvm-svn: 184734
2013-06-24 13:48:42 +00:00
Evgeniy Stepanov 0e8053af08 [sanitizer] Intercept readv, preadv, writev, pwritev.
llvm-svn: 184717
2013-06-24 10:43:23 +00:00
Sergey Matveev b8cd986b5d [lsan] Fix android build.
llvm-svn: 184704
2013-06-24 09:12:11 +00:00
Sergey Matveev 4e0215a71c Revert to C-style callbacks for iteration over allocator chunks.
Also clean up LSan code, fix some comments and replace void* with uptr
to bring down the number of reinterpret_casts.

llvm-svn: 184700
2013-06-24 08:34:50 +00:00
Alexey Samsonov 43937b3758 Add cmake rules for building LSan common on Mac OS
llvm-svn: 184639
2013-06-22 16:33:52 +00:00
Sergey Matveev 38fa1ff710 [lsan] Try REALLY hard to fix Win build.
llvm-svn: 184557
2013-06-21 15:50:49 +00:00
Sergey Matveev 85f1fffdfb [lsan] This time really fix Win build.
llvm-svn: 184556
2013-06-21 15:22:12 +00:00
Sergey Matveev 7ed5c687ed [lsan] Fix win build.
llvm-svn: 184555
2013-06-21 15:14:57 +00:00
Sergey Matveev d28c03c03a [lsan] Increase allocator space; minor fixes.
llvm-svn: 184554
2013-06-21 15:10:20 +00:00
Sergey Matveev b94d5e2d1c [asan] Move lsan_disabled out of thread context.
Fix for the case where disabler is used in pthread key destructor.

llvm-svn: 184553
2013-06-21 14:51:52 +00:00
Alexey Samsonov a9db3f9757 [ASan] reimplement strdup() interceptor to get nicer stack traces for memory chunks allocated there
llvm-svn: 184546
2013-06-21 14:41:59 +00:00
Evgeniy Stepanov b58b72e151 [msan] Intercept (v)asprintf.
llvm-svn: 184545
2013-06-21 13:32:26 +00:00
Evgeniy Stepanov ae4e1ec4e6 [msan] Add keep_going runtime flag.
llvm-svn: 184542
2013-06-21 12:37:58 +00:00
Alexey Samsonov f9e6624663 [ASan] make test for LSan annotations Linux-only for now
llvm-svn: 184541
2013-06-21 12:18:52 +00:00
Alexey Samsonov ad25b50a89 [ASan] Check that ASan user may include and use LSan headers
llvm-svn: 184540
2013-06-21 11:11:44 +00:00
Evgeniy Stepanov 57a40e5a94 [santizer] Disable several EVIOxxx ioctls on older kernels.
llvm-svn: 184539
2013-06-21 10:54:57 +00:00
Dmitry Vyukov 03ec9545f5 tsan: fix potential false positive race on fd
llvm-svn: 184430
2013-06-20 14:32:12 +00:00
Sergey Matveev 5e6b9eccce [asan] Define LSan annotations as no-ops if leak detection is not supported.
llvm-svn: 184422
2013-06-20 13:39:42 +00:00
Evgeniy Stepanov 673cf23d06 Fix unused function warning w/o changing compiler flags.
We have way too many different build systems.

llvm-svn: 184409
2013-06-20 09:45:36 +00:00
Evgeniy Stepanov 3ce228faf3 [sanitizer] Fix Mac build.
llvm-svn: 184407
2013-06-20 09:39:34 +00:00
Evgeniy Stepanov d271563e5a Remove an outdated comment.
llvm-svn: 184406
2013-06-20 09:21:25 +00:00
Evgeniy Stepanov fbea5b95c6 [sanitizer] Handle EVIOxxxx ioctls.
llvm-svn: 184405
2013-06-20 09:19:28 +00:00
Alexey Samsonov 686c229b03 [ASan] Clear allocation magic value before recycling the chunk. This led to spurious crashes in LSan when it walked through reused chunks. Don't know how to create not-brittle test case for this.
llvm-svn: 184404
2013-06-20 08:13:06 +00:00
Sergey Matveev 7014179ccb [lsan] Prevent inlining of WipeStack().
llvm-svn: 184312
2013-06-19 15:39:13 +00:00
Sergey Matveev dac35c24c0 [lsan] Move symbolization and reporting out of StopTheWorld callback.
llvm-svn: 184303
2013-06-19 14:04:11 +00:00
Evgeniy Stepanov 49b4314cfd [sanitizer] Fix struct ifconf definition on Mac and restore the size checks.
llvm-svn: 184296
2013-06-19 13:21:38 +00:00
Sylvestre Ledru 6e0a254ec9 When the compiler is not providing a clean triple, we should fail
the build right from the start. 
For now, it is only done with DEBUGMAKE is provided. That makes
things harder to debug during ports of compiler-rt on other systems.

llvm-svn: 184295
2013-06-19 12:59:56 +00:00
Alexander Potapenko 29b9fcf0a8 [ASan] Delete excessive 'extern "C"' around mlock* interceptors.
llvm-svn: 184294
2013-06-19 11:36:51 +00:00
Evgeniy Stepanov 41060fd728 [sanitizer] Fix Android build.
llvm-svn: 184293
2013-06-19 10:36:31 +00:00
Evgeniy Stepanov f9cfe76526 [sanitizer] Fix build on RHEL 6.3, 6.4.
linux/if_ppp.h is broken in certain kernels.

llvm-svn: 184290
2013-06-19 08:55:28 +00:00
Kostya Serebryany 63d84f8149 [asan] fix a rare failure in fast unwinder, found by asan/clang bootstrap
llvm-svn: 184190
2013-06-18 14:47:40 +00:00
Sergey Matveev 2717e7be06 [lsan] Set current_thread_tid correctly for main thread.
llvm-svn: 184189
2013-06-18 14:44:45 +00:00
Evgeniy Stepanov 394b09b00f [sanitizer] Fix Android build.
llvm-svn: 184187
2013-06-18 13:56:12 +00:00
Evgeniy Stepanov fc3f61fcf0 [sanitizer] Remove a set of deprecated ioctls.
llvm-svn: 184185
2013-06-18 10:37:17 +00:00
Evgeniy Stepanov b9c1020696 [sanitizer] Replace ext2_ ioctls with generic fs_ ioctls.
They are actually the same, but ext2_fs.h header is not available in userspace
with newer kernels.

llvm-svn: 184184
2013-06-18 09:49:04 +00:00
Evgeniy Stepanov 8fa046e288 [sanitizer] Symbolic ioctl names.
Replace hardcoded ioctl request ids with symbolic names.
Disable certain ioctls on platforms where such names are not found in the
system headers.
Fix a bug in ioctl_lookup.
Reenable ioctl test on Mac.

llvm-svn: 184183
2013-06-18 09:22:24 +00:00
Dmitry Vyukov 5cf581a8d4 tsan: consistently use return pc as top frame pc
always substract 1 from the top pc
this allows to get correct stacks with -O2

llvm-svn: 184112
2013-06-17 19:57:03 +00:00
Alexey Samsonov 7e325fb477 Properly install LSan interface header, rely on sanitizer header presence in lit tests
llvm-svn: 183977
2013-06-14 11:45:36 +00:00
Alexey Samsonov 0d7012debb [TSan] use InternalMmapVector to store fired suppressions
llvm-svn: 183974
2013-06-14 11:18:58 +00:00
Alexey Samsonov bd0428b81a [LSan] Use a typedef for frontier vector
llvm-svn: 183973
2013-06-14 10:07:56 +00:00
Alexey Samsonov b0d92b3312 [Sanitizer] Rename InternalVector to InternalMmapVector
llvm-svn: 183972
2013-06-14 09:59:40 +00:00
Dmitry Vyukov 26daccaddb tsan: fix Windows Go crash
llvm-svn: 183898
2013-06-13 10:15:44 +00:00
Alexey Samsonov 5e520c5e09 [LSan] fix link flags for building unit tests
llvm-svn: 183891
2013-06-13 07:23:18 +00:00
Richard Trieu 5685aa6845 Fix broken header guard.
llvm-svn: 183873
2013-06-12 22:37:22 +00:00
Sergey Matveev 978460c12c [lsan] Harmonized some naming inconsistencies.
llvm-svn: 183748
2013-06-11 15:26:20 +00:00
Dmitry Vyukov a8570d38fe tsan: add -Wno-maybe-uninitialized to Go build script
this is how the rest of the codebase is built

llvm-svn: 183738
2013-06-11 11:44:43 +00:00
Sergey Matveev 5129c5e56f [lsan] Fix the unittest makefiles.
llvm-svn: 183735
2013-06-11 09:52:02 +00:00
Alexey Samsonov bc1c6714f2 [Sanitizer] add file forgotten in r183730
llvm-svn: 183732
2013-06-11 08:14:24 +00:00
Alexey Samsonov c8e7364763 [Sanitizer] support running external llvm-symbolizer on Mac
llvm-svn: 183730
2013-06-11 08:13:36 +00:00
Dmitry Vyukov 79de34f75c tsan: fix lit test failures
llvm-svn: 183674
2013-06-10 16:06:21 +00:00
Dmitry Vyukov b08e72913a tsan: add system tests for suppressions
llvm-svn: 183673
2013-06-10 15:39:28 +00:00
Dmitry Vyukov 315bb0e687 tsan: allows to suppress races on global variables
llvm-svn: 183672
2013-06-10 15:38:44 +00:00
Alexander Potapenko 152f7edf24 [ASan] Fix unset-insert-libraries-on-exec.cc on 32-bit Darwin.
The test used to execute a 64-bit /bin/bash binary and preload a 32-bit dynamic library into it.
Now the arch-specific version of echo-env is executed instead.

llvm-svn: 183662
2013-06-10 14:47:43 +00:00
Alexey Samsonov f67191b4c3 [ASan] mark ioctl test as xfailing on darwin. remove redundant semicolons
llvm-svn: 183655
2013-06-10 14:17:08 +00:00
Kostya Serebryany 02062becea [asan] fix Android build (mark asan_malloc_usable_size as an interface function)
llvm-svn: 183651
2013-06-10 13:28:33 +00:00
Dmitry Vyukov b19a26b852 tsan: disable getaddrinfo() interceptor for tsan (causes recursion)
llvm-svn: 183649
2013-06-10 11:35:08 +00:00
Dmitry Vyukov 7e4a18c4fb tsan: fix merge bug
llvm-svn: 183648
2013-06-10 11:11:29 +00:00
Kostya Serebryany e71982d589 [asan] fix the bug with memalign and malloc_usable_size (http://code.google.com/p/address-sanitizer/issues/detail?id=193); also fix lint
llvm-svn: 183647
2013-06-10 10:46:27 +00:00
Dmitry Vyukov b278f1235f tsan: fix windows crash (incorrect stack boundaries)
llvm-svn: 183646
2013-06-10 10:30:54 +00:00
Dmitry Vyukov ddb0294dd8 tsan: fix old gcc warnings
llvm-svn: 183645
2013-06-10 10:30:19 +00:00
Dmitry Vyukov e979c5467c tsan: fix windows mingw build
llvm-svn: 183644
2013-06-10 10:02:02 +00:00
Dmitry Vyukov 8794772337 tsan: more detailed trace for atomic operations (include address and memory ordering)
llvm-svn: 183643
2013-06-10 10:01:31 +00:00
Dmitry Vyukov 50ef53ebfc tsan: fix lint warnings
llvm-svn: 183642
2013-06-10 10:00:54 +00:00
Alexey Samsonov dd489a4e15 [MSan] don't add msan unit tests to check-msan command if libcxx is not checked out
llvm-svn: 183641
2013-06-10 09:09:40 +00:00
Alexey Samsonov 4c0ea93725 [ASan] don't use -m{32,64} flag in test case, as it can be run in both 32- and 64-bit modes
llvm-svn: 183638
2013-06-10 07:55:12 +00:00
Bill Wendling 658fb53b7e Reverting r183529:
This is causing the following error on Darwin:

/Volumes/Sandbox/llvm-clean.src/projects/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc:282:1: error: 'assertion_failed__282' declared as an array with a negative size
CHECK_TYPE_SIZE(ifconf);
^~~~~~~~~~~~~~~~~~~~~~~
/Volumes/Sandbox/llvm-clean.src/projects/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc:223:3: note: expanded from macro 'CHECK_TYPE_SIZE'
  COMPILER_CHECK(sizeof(__sanitizer_##TYPE) == sizeof(TYPE))
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Volumes/Sandbox/llvm-clean.src/projects/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:239:30: note: expanded from macro 'COMPILER_CHECK'
#define COMPILER_CHECK(pred) IMPL_COMPILER_ASSERT(pred, __LINE__)
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Volumes/Sandbox/llvm-clean.src/projects/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:245:57: note: expanded from macro 'IMPL_COMPILER_ASSERT'
    typedef char IMPL_PASTE(assertion_failed_##_, line)[2*(int)(pred)-1]
                                                        ^~~~~~~~~~~~~~~
/Volumes/Sandbox/llvm-clean.src/projects/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc:284:1: error: 'assertion_failed__284' declared as an array with a negative size
CHECK_SIZE_AND_OFFSET(ifconf, ifc_ifcu);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Volumes/Sandbox/llvm-clean.src/projects/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc:228:3: note: expanded from macro 'CHECK_SIZE_AND_OFFSET'
  COMPILER_CHECK(offsetof(__sanitizer_##CLASS, MEMBER) ==          \
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Volumes/Sandbox/llvm-clean.src/projects/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:239:30: note: expanded from macro 'COMPILER_CHECK'
#define COMPILER_CHECK(pred) IMPL_COMPILER_ASSERT(pred, __LINE__)
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Volumes/Sandbox/llvm-clean.src/projects/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:245:57: note: expanded from macro 'IMPL_COMPILER_ASSERT'
    typedef char IMPL_PASTE(assertion_failed_##_, line)[2*(int)(pred)-1]
                                                        ^~~~~~~~~~~~~~~

llvm-svn: 183557
2013-06-07 20:28:29 +00:00
Evgeniy Stepanov cead69d4a3 [sanitizer] Handle SIOCGIFCONF ioctl.
llvm-svn: 183529
2013-06-07 15:49:38 +00:00
Alexey Samsonov 4fdf8d66a9 [ASan] fix test case to use absolute paths
llvm-svn: 183527
2013-06-07 15:44:21 +00:00
Alexander Potapenko 6af3fce55e [ASan] An early return from InitializeAsanInterceptors() on Mac has been considered unobvious.
Remove it and replace ASAN_INTERCEPT_FUNC with a no-op if SANITIZER_MAC==1.

llvm-svn: 183524
2013-06-07 15:10:02 +00:00
Evgeniy Stepanov c24e13e7bb [sanitizer] Fix Android build.
llvm-svn: 183523
2013-06-07 14:56:54 +00:00
Evgeniy Stepanov 74dcb1a8de [sanitizer] Fix windows build.
llvm-svn: 183518
2013-06-07 13:19:33 +00:00
Evgeniy Stepanov 0b1f41b6f4 [sanitizer] ioctl interceptor.
ASan: disabled by default
MSan: enabled by default
TSan: disabled
llvm-svn: 183517
2013-06-07 13:00:47 +00:00
Alexey Samsonov 575c599554 Drop support for 32-bit PowerPC in sanitizer tools.
llvm-svn: 183499
2013-06-07 09:44:43 +00:00
Alexey Samsonov 889e3ab83c [ASan] create separate configs for running ASan lit tests in both 32- and 64-bit mode. Clean up RUN-lines in tests.
llvm-svn: 183498
2013-06-07 09:38:55 +00:00
Sergey Matveev 1c4e214c32 [lsan] Put SANITIZER_INTERFACE_ATTRIBUTE on LSan interface functions.
llvm-svn: 183429
2013-06-06 18:40:55 +00:00
Dmitry Vyukov 0fffc0088c tsan: use memory access size for Go after all
helps to make range access functions correct and fast

llvm-svn: 183418
2013-06-06 14:31:15 +00:00
Sergey Matveev db356560fc [sanitizer] Do not fall back to SlowUnwindStack() in GetStackTrace()
llvm-svn: 183414
2013-06-06 14:19:36 +00:00
Sergey Matveev ecc4f5ba8e [lsan] Implement __lsan_ignore_object().
Leak annotation similar to HeapChecker's IgnoreObject().

llvm-svn: 183412
2013-06-06 14:17:56 +00:00
Alexey Samsonov e674320ade [ASan] make pthread_getschedparam test more robust
llvm-svn: 183411
2013-06-06 14:08:40 +00:00
Alexey Samsonov f6630ecee9 Simplify lit configs for asan/lsan/msan unit tests
llvm-svn: 183410
2013-06-06 13:48:20 +00:00
Dmitry Vyukov 5fe8a4f88f tsan: always strip bottom frame in Go reports
llvm-svn: 183408
2013-06-06 13:31:35 +00:00
Alexey Samsonov e3bf521b7c Remove a bunch of copy-paste: use common config for sanitizer lit/unit tests
llvm-svn: 183407
2013-06-06 13:28:37 +00:00
Dmitry Vyukov ce0247c93e tsan: fix darwin Go crashes
llvm-svn: 183405
2013-06-06 13:20:40 +00:00
Dmitry Vyukov c9e304afbd tsan: fix darwin Go build
llvm-svn: 183402
2013-06-06 13:00:32 +00:00
Alexey Samsonov c05aba7eaa [ASan] create common autogenerated config for running compiler-rt unit tests, and use it in ASan
llvm-svn: 183401
2013-06-06 12:48:20 +00:00
Alexey Samsonov 6a65b18992 [ASan] lit tests: create common autogenerated config for running compiler-rt lit tests, and use it in ASan
llvm-svn: 183400
2013-06-06 12:35:48 +00:00
Alexey Samsonov 2874f70250 [ASan] move all lit_tests under TestCases
llvm-svn: 183395
2013-06-06 09:23:34 +00:00
Alexey Samsonov b42b2f5c69 [ASan] Add a few tests for use-after-scope mode
llvm-svn: 183391
2013-06-06 08:30:26 +00:00
Alexey Samsonov 7a75e16c27 [ASan] One more fix for realloc: check that reallocated chunk is valid before calling memcpy
llvm-svn: 183390
2013-06-06 08:25:31 +00:00
Alexey Samsonov 87a59e5652 [ASan] make free_hook_realloc test more robust
llvm-svn: 183387
2013-06-06 07:58:00 +00:00
Evgeniy Stepanov 863746eb1a [sanitizer] Fix windows build.
llvm-svn: 183225
2013-06-04 14:06:16 +00:00
Evgeniy Stepanov 56050e8f69 [sanitizer] Fix __sanitizer_unaligned_* to work with unaligned data types.
llvm-svn: 183224
2013-06-04 13:49:10 +00:00
Evgeniy Stepanov 53c8c13bf1 [msan] Implement __sanitizer_unaligned_*.
llvm-svn: 183221
2013-06-04 13:08:36 +00:00
Alexey Samsonov 8f5138a23f Call __asan_free_hook() before marking the chunk quarantinned
Summary:
With this change, the user may safely call __asan_get_ownership()
from malloc/free hooks and assume it would return "true". If there is a
realloc/free race, free hook might be called twice, but I think it's acceptable,
as it's a data race and would later be reported anyway.

This change also fixes a bug when failing realloc incorrectly marked the
original memory as "quarantinned".

Reviewers: timurrrr, kcc, samsonov

Reviewed By: samsonov

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D913

llvm-svn: 183220
2013-06-04 12:19:31 +00:00
Sergey Matveev b256ac7584 [asan] Fix invalid thread registry access when checking if LSan is disabled.
llvm-svn: 183218
2013-06-04 10:39:24 +00:00
Timur Iskhodzhanov baf90ccfac Fix ALIGNED misuse in asan_thread.cc (built on all platforms); also, add a comment to the ALIGNED macro describing the correct usage
llvm-svn: 183214
2013-06-04 08:25:17 +00:00
Kostya Serebryany c1aa0e8f69 [asan] ASan Linux MIPS32 support (compiler-rt part), patch by Jyun-Yan Y
llvm-svn: 183105
2013-06-03 14:49:25 +00:00
Sergey Matveev 17ee1abfa7 [lsan] Add __lsan_disable() and __lsan_enable().
Objects allocated after a call to __lsan_disable() will be treated as
live memory. Also add a ScopedDisabler.

llvm-svn: 183099
2013-06-03 11:21:34 +00:00
Sergey Matveev 3786ae5c54 [sanitizer] Fix kThreadDescriptorSize for glibc <= 2.11.
Address issue reported by Greg Fitzgerald.

llvm-svn: 183098
2013-06-03 10:20:23 +00:00
Alexander Potapenko 41cd6102e9 [ASan] Do not buffer stdin in asan_symbolize.py
llvm-svn: 183006
2013-05-31 14:55:06 +00:00
Sergey Matveev 1a566ced91 [lsan] Added a dummy unittest to suppress LIT warnings.
llvm-svn: 183004
2013-05-31 14:15:54 +00:00
Sergey Matveev 5494e0bec3 [lsan] Run the leak detection tests under both ASan and LSan.
Change the LSan lit test logic. Now "check-lsan" tests the leak
checking functionality in both standalone LSan and ASan.

llvm-svn: 183000
2013-05-31 13:13:55 +00:00
Evgeniy Stepanov 4717d2d494 [msan] Fix gcc build of msan runtime.
llvm-svn: 182999
2013-05-31 13:04:07 +00:00
Evgeniy Stepanov 96284becf4 [msan] Handle mixed track-origins and keep-going settings (compiler-rt part).
Before this change, each module defined a weak_odr global __msan_track_origins
with a value of 1 if origin tracking is enabled, 0 if disabled. If there are
modules with different values, any of them may win. If 0 wins, and there is at
least one module with 1, the program will most likely crash.

With this change, __msan_track_origins is only emitted if origin tracking is
on. Then runtime library detects if there is at least one module with origin
tracking, and enables runtime support for it.

llvm-svn: 182996
2013-05-31 12:04:08 +00:00
Sergey Matveev 53c24fe0e6 [sanitizer] Fix r182994 - update test.
llvm-svn: 182995
2013-05-31 11:33:21 +00:00
Sergey Matveev 69f11803ec [lsan] Use the fast version of GetBlockBegin for leak checking in LSan and ASan.
llvm-svn: 182994
2013-05-31 11:13:45 +00:00
Evgeniy Stepanov 1cf5ef5018 [sanitizer] Fix wrong size of addrinfo::ai_addrlen.
Add compile time tests for sizes and offsets of all sanitizer-posix types.

llvm-svn: 182993
2013-05-31 10:46:51 +00:00
Kostya Serebryany 3a7c6d689d [asan] workaround for the quemu bug in proc maps (http://code.google.com/p/address-sanitizer/issues/detail?id=160)
llvm-svn: 182922
2013-05-30 11:00:08 +00:00
Alexey Samsonov 2a6cc67225 Fix #if guards in sanitizer_common code
llvm-svn: 182918
2013-05-30 09:16:04 +00:00
Kostya Serebryany 831a1d7cec [sanitizer] introduce LargeMmapAllocator::GetBlockBeginFastSingleThreaded, required for LeakSanitizer to work faster. Also fix lint.
llvm-svn: 182917
2013-05-30 08:43:30 +00:00
Alexander Potapenko a8b41762e4 [ASan] Minor cleanup: remove a couple of unused variables.
llvm-svn: 182915
2013-05-30 07:30:07 +00:00
Timur Iskhodzhanov 013da5cb37 Replaced 'bool .* = 0;' with '... = false;'
llvm-svn: 182868
2013-05-29 17:26:25 +00:00
Sergey Matveev 6a0c722c23 [asan] Fix r182858.
llvm-svn: 182862
2013-05-29 15:31:52 +00:00
Sergey Matveev 4161813a50 [asan] Fix r182854: run the unpoison_tls test only on Linux.
llvm-svn: 182858
2013-05-29 14:37:04 +00:00
Timur Iskhodzhanov cc61eefd4b Fix MSVC W3 compiler warnings
llvm-svn: 182857
2013-05-29 14:11:44 +00:00
Sergey Matveev 09886cd17a [asan] Make ASan report the correct thread address ranges to LSan.
This CL enables thread support in LSan when used on top of ASan.

llvm-svn: 182854
2013-05-29 13:09:44 +00:00
Sergey Matveev 89bcec8117 [sanitizer] Change the way GetThreadStackAndTls() obtains the thread descriptor address.
Instead of using arch_prctl(ARCH_GET_FS), read the address from the
tread descriptor itself. This lets us avoid sandboxing issues. Also,
GetThreadStackAndTls() can now be implemented on i386.

llvm-svn: 182853
2013-05-29 13:07:42 +00:00
Evgeniy Stepanov 677003140c [sanitizer] Fix getaddrinfo interceptor to use the actual returned sockaddr size.
llvm-svn: 182852
2013-05-29 12:33:31 +00:00
Peter Collingbourne 112e5ba281 [nolibc] Unweak SymbolizerPrepareForSandboxing and move it to libc-independent part.
Fixes the Go build.

Differential Revision: http://llvm-reviews.chandlerc.com/D877

llvm-svn: 182851
2013-05-29 12:11:43 +00:00
Timur Iskhodzhanov 6ba477aa05 Fix MSVC warnings at the -W2 level
llvm-svn: 182848
2013-05-29 12:03:49 +00:00
Evgeniy Stepanov a4bf67e461 [sanitizer] Fix Mac build.
llvm-svn: 182845
2013-05-29 11:55:27 +00:00
Evgeniy Stepanov fc708db4c1 [sanitizer] Intercept getpeername.
llvm-svn: 182844
2013-05-29 11:49:25 +00:00
Evgeniy Stepanov a4d08c4e87 [sanitizer] Move TSan and MSan recvmsg interceptors to common.
llvm-svn: 182843
2013-05-29 11:30:00 +00:00
Dmitry Vyukov 2b997d2914 tsan: match "race" suppressions against "race on vptr" reports
llvm-svn: 182842
2013-05-29 11:23:54 +00:00
Peter Collingbourne 93aa8dfb78 [nolibc] Now that we have a custom allocator, remove dummy allocator
definitions from test.

llvm-svn: 182841
2013-05-29 10:52:59 +00:00
Alexey Samsonov 25ad5a6735 [sanitizer] Use raw check in internal allocator to prevent self-deadlocks. Try to fix Windows build.
llvm-svn: 182840
2013-05-29 10:41:53 +00:00
Sergey Matveev e615432313 [lsan] Convert the remaining LSan tests to output tests.
llvm-svn: 182839
2013-05-29 10:12:37 +00:00
Evgeniy Stepanov f28217ad0e [sanitizer] modf/modff/modfl interceptors.
llvm-svn: 182838
2013-05-29 10:03:11 +00:00
Alexey Samsonov 75289297af Exclude sanitizer_nolibc_test from TSan test run. Fix lint warnings
llvm-svn: 182837
2013-05-29 09:40:07 +00:00
Alexey Samsonov c30e2d6b3a Make InternalAlloc/InternalFree in sanitizer runtimes libc-free by switching to a custom allocator.
llvm-svn: 182836
2013-05-29 09:15:39 +00:00
Evgeniy Stepanov 08f662845d [sanitizer] Share TSan accept & accept4 interceptors with other sanitizers.
llvm-svn: 182835
2013-05-29 09:09:58 +00:00
Evgeniy Stepanov 40d7ed5d1e [sanitizer] Improve getaddrinfo interceptor.
llvm-svn: 182775
2013-05-28 14:34:37 +00:00
Evgeniy Stepanov dd0780f81c [msan] Change report header to be more alike to ASan and TSan.
llvm-svn: 182774
2013-05-28 14:27:30 +00:00
Peter Collingbourne a7887bf8be [nolibc] Add a test case for Linux/x86_64.
Differential Revision: http://llvm-reviews.chandlerc.com/D873

llvm-svn: 182770
2013-05-28 12:37:34 +00:00
Peter Collingbourne fb1a9f17e3 [nolibc] Make SymbolizerPrepareForSandboxing weak and optional.
Differential Revision: http://llvm-reviews.chandlerc.com/D872

llvm-svn: 182765
2013-05-28 11:05:05 +00:00
Peter Collingbourne 5b2669049a [nolibc] Make AddressInfo::Clear a weak function.
llvm-svn: 182743
2013-05-27 21:00:36 +00:00
Peter Collingbourne 123473d243 Use an address-of operator here to silence an MSVC warning.
llvm-svn: 182740
2013-05-27 16:02:19 +00:00
Sergey Matveev 39e8a6d87e [lsan] Begin converting LSan tests to output tests.
In this CL all old tests are removed and one LIT test is added.

llvm-svn: 182730
2013-05-27 11:41:46 +00:00
Sergey Matveev 9cda3df8bd [sanitizer] Move FindThreadByOSIdLocked from lsan to sanitizer_common.
llvm-svn: 182728
2013-05-27 10:35:51 +00:00
Alexey Samsonov 9c2bcf8c15 Improve support for compiler-rt tests in CMake build.
Now compiler-rt tests run correctly if compiler-rt is checked out into
arbitrary directory (not necessarily projects/compiler-rt).
Patch by Greg Fitzgerald!

llvm-svn: 182726
2013-05-27 09:35:24 +00:00
Nick Kledzik 23bbd617e4 <rdar://problem/12512722> Use arm divide instruction if available
llvm-svn: 182665
2013-05-24 19:38:11 +00:00
Sergey Matveev e45a0677a6 [lsan] Allow the ignored TLS range to be empty.
llvm-svn: 182657
2013-05-24 18:07:53 +00:00
Sergey Matveev 37dff38495 [lsan] Minor adjustments to LSan messages.
llvm-svn: 182648
2013-05-24 15:36:30 +00:00
Sergey Matveev c7715a228a [lsan] Prettify LSan reports and add a summary.
llvm-svn: 182646
2013-05-24 14:49:13 +00:00
Sergey Matveev bc880f3a54 [lsan] Add exitcode flag. Kill the process if leaks are found.
llvm-svn: 182641
2013-05-24 13:16:02 +00:00
Alexey Samsonov 646ec67e25 Disable init-order checking before destructors are run.
We don't want to report initialization-order bugs when a destructor of a global
variable accesses dynamically initialized global from another
(not necessarily initialized) module. We do this by intercepting __cxa_atexit and
registrering our own callback that unpoisons shadow for all dynamically initialized
global variables.

llvm-svn: 182637
2013-05-24 11:46:56 +00:00
Bill Wendling b7e7a38929 Don't override 'mode' and cleanup some variable names.
llvm-svn: 182599
2013-05-23 18:18:31 +00:00
Bill Wendling a600457cde Add 'mode' parameter when using 'O_CREAT'. Thanks to Evgeniy for pointing this out.
llvm-svn: 182598
2013-05-23 18:08:22 +00:00
Sergey Matveev a4a01975d5 [lsan] Add lit test support.
"check-lsan" now runs both the tests from lib/lsan/tests and any lit
tests found under lib/lsan/lit_tests.

llvm-svn: 182583
2013-05-23 12:58:56 +00:00
Alexander Potapenko 22e92fa954 [TSan] Try to fix the Go-TSan build.
llvm-svn: 182582
2013-05-23 12:54:35 +00:00
Evgeniy Stepanov bfbd37e6e7 [tsan] Remove -Wgnu from Makefile.old.
llvm-svn: 182580
2013-05-23 11:57:47 +00:00
Alexander Potapenko 6535f510a3 [ASan] Introduce SymbolizerPrepareForSandboxing(), which is a no-op on every platform except Linux (because we don't support sandboxing anywhere else yet)
On Linux we pre-cache the value of readlink("/proc/self/exe"), so that it can be later used when the sandbox has been turned on.

llvm-svn: 182579
2013-05-23 11:53:36 +00:00
Evgeniy Stepanov a343d1d881 [msan] Fix line >80 chars.
llvm-svn: 182578
2013-05-23 11:51:47 +00:00
Evgeniy Stepanov 5415c9c352 [sanitizer] Fix Windows build.
llvm-svn: 182576
2013-05-23 11:41:58 +00:00
Timur Iskhodzhanov e05f9ba956 [ASan] Rename a atomic_compare_exchange_strong parameter to avoid a compiler warning
llvm-svn: 182575
2013-05-23 11:40:51 +00:00
Evgeniy Stepanov b978627cb8 [sanitizer] Intercept getsockopt.
llvm-svn: 182574
2013-05-23 11:38:08 +00:00
Evgeniy Stepanov ab25369d04 [sanitizer] Interceptors for gethostbyname and friends.
llvm-svn: 182573
2013-05-23 11:10:23 +00:00
Sergey Matveev bb12f840b5 [lsan] Ensure lsan is initialized when interceptors are called.
Also remove unnecessary ifdefs.

llvm-svn: 182571
2013-05-23 10:24:44 +00:00
Alexander Potapenko fd7d9f45dd [ASan] Rename __asan_preinit to __local_asan_preinit to avoid warnings from the linker which is trying to export all the __asan_* symbols
llvm-svn: 182567
2013-05-23 09:15:20 +00:00
Bill Wendling 353fbd3516 Performance improvement.
Using fwrite and fread was very *very* slow. The resulting code was multiple
times slower than GCC's implementation of gcov. Replace the fwrite/fread system
with an mmap() version.

If the `.gcda' file doesn't exist, we (re)allocate a buffer that we write
into. That gets written to the `.gcda' file in one chunk. If the `.gcda' file
already exists, we simply mmap() the file, modify the mapped data, and use
msync() to write the contents out to disk. It's much easier than implementing
our own buffering scheme, and we don't have to use fwrite's and fread's
buffering.

For those who are numbers-oriented, here are some timings:

GCC Verison
-----------

`.gcda' files don't exist:  23s
`.gcda' files do exist:     14s

LLVM Version (before this change)
---------------------------------

`.gcda' files don't exist:  28s
`.gcda' files do exist:     28s

LLVM Version (with this change)
-------------------------------

`.gcda' files don't exist:  18s
`.gcda' files do exist:      4s

It's a win-win-win-win-lose-win-win scenario!

<rdar://problem/13466086>

llvm-svn: 182563
2013-05-23 07:18:59 +00:00
Evgeniy Stepanov d23422f025 [sanitizer] Fix Mac build one more time.
llvm-svn: 182481
2013-05-22 15:21:04 +00:00
Evgeniy Stepanov 093e499e27 [sanitizer] Fix Android build.
llvm-svn: 182479
2013-05-22 14:26:52 +00:00
Alexey Samsonov 58df72e0d2 Effectively revert r182453 - atomic.c may not be compiled if host compiler doesn't understand _Atomic
llvm-svn: 182478
2013-05-22 14:22:04 +00:00
Kostya Serebryany 6ca6ba2f2c [asan] fix the reported PCs for powerpc64
llvm-svn: 182477
2013-05-22 14:21:34 +00:00
Evgeniy Stepanov 97aea34b54 [msan] Intercept getsockname.
llvm-svn: 182475
2013-05-22 13:46:22 +00:00
Evgeniy Stepanov a8ea8a03fd [sanitizer] Fix Android build.
llvm-svn: 182473
2013-05-22 13:38:02 +00:00
Alexey Samsonov 49eb5700e2 Revert r182465 and add lsan-common library to makefile-based build
llvm-svn: 182470
2013-05-22 13:20:37 +00:00
Evgeniy Stepanov 02c9c8c9f7 [sanitizer] Fix Mac build.
llvm-svn: 182469
2013-05-22 13:07:23 +00:00
Evgeniy Stepanov bfd2122b20 [msan] getaddrinfo & nested interceptor support.
Multiple connected changes:
- Ignore reads from nested interceptors.
- Check shadow on reads from common interceptors.
- getaddrinfo interceptor.

llvm-svn: 182466
2013-05-22 12:50:26 +00:00
Alexey Samsonov 155dd46e04 [ASan] Temporary remove leak checking from ASan, while we don't have makefile-based build for LSan
llvm-svn: 182465
2013-05-22 12:44:57 +00:00
Kostya Serebryany 15fd53fa39 [asan] enhance stack-overflow.cc test: check that the location frame is properly symbolized
llvm-svn: 182463
2013-05-22 11:00:56 +00:00
Kostya Serebryany b93ae15205 [asan] attempting to fix the debian bot (on ubuntu the test builds; on debian it complains that _SC_PAGESIZE is unknown)
llvm-svn: 182462
2013-05-22 10:38:51 +00:00
Kostya Serebryany 62debd6d6a [asan] fix dlclose-test to work with non-4K pages. Properly disable interface_symbols_linux on non-x86
llvm-svn: 182461
2013-05-22 10:20:10 +00:00
Kostya Serebryany 8410a867eb [asan] workaround for asan bug 189 (swapcontext followed by throw gets OOM kill). Also, disable swapcontext_test on non-x86. Fix lint
llvm-svn: 182456
2013-05-22 08:54:30 +00:00
Alexey Samsonov 57cbb6c6cc Add atomic.c to CMake build of compiler-rt to match r182420
llvm-svn: 182453
2013-05-22 06:46:07 +00:00
Nick Kledzik 69e25c45e4 <rdar://problem/13806954> enable __atomic_* functions for Darwin
llvm-svn: 182435
2013-05-21 23:02:04 +00:00
Daniel Dunbar eaa153bdad Add atomic.c back to the builtins module sources lists (for Makefile build).
llvm-svn: 182420
2013-05-21 20:40:36 +00:00
Sergey Matveev 20ccf95f80 [lsan] Invoke leak detection with atexit().
Keeps it consistent between ASan and LSan.

llvm-svn: 182399
2013-05-21 17:56:45 +00:00
Sergey Matveev 17f5705d3c [asan] Do not invoke LSan hooks unless CAN_SANITIZE_LEAKS.
llvm-svn: 182389
2013-05-21 15:35:34 +00:00
Sergey Matveev 8c235f40d7 [asan] LSan hooks in asan_rtl.
llvm-svn: 182384
2013-05-21 14:15:35 +00:00
Sergey Matveev 620744556a [lsan] Change CMakeLists to build the common LSan module for ASan.
Also, define CAN_SANITIZE_LEAKS.

llvm-svn: 182383
2013-05-21 14:12:11 +00:00
Alexey Samsonov b99085b0b8 [MSan] Add empty default blacklist for MSan
llvm-svn: 182382
2013-05-21 13:55:56 +00:00
Alexey Samsonov e838135b6c [ASan] create default (empty) ASan blacklist file in resource directory
llvm-svn: 182380
2013-05-21 13:48:27 +00:00
Sergey Matveev 7159b2a382 [asan] LSan hooks in asan_allocator2.cc
llvm-svn: 182379
2013-05-21 13:46:41 +00:00
Sergey Matveev 65dd62abe5 [asan] LSan hooks in asan_thread.cc
llvm-svn: 182378
2013-05-21 13:40:13 +00:00
Sergey Matveev aa0b45a094 [lsan] LSan in LD_PRELOAD library form.
llvm-svn: 182376
2013-05-21 12:49:33 +00:00
Alexey Samsonov 73565f7f5d [Sanitizer] Print verbose warning if symbolizer can't read /proc/self/exe for some reason
llvm-svn: 182374
2013-05-21 12:22:36 +00:00
Peter Collingbourne c787d42f40 [nolibc] Move symbolizer to RTSanitizerCommonLibc, and make it optional using a weak symbol.
llvm-svn: 182372
2013-05-21 12:08:37 +00:00
Peter Collingbourne fa8aa4105c [nolibc] Move stoptheworld to RTSanitizerCommonLibc.
llvm-svn: 182369
2013-05-21 11:38:39 +00:00
Peter Collingbourne 8575195772 [nolibc] Move libc-dependent sanitizer_posix.cc code to sanitizer_posix_libcdep.cc.
llvm-svn: 182366
2013-05-21 10:27:07 +00:00
Alexey Samsonov 3677b18388 [ASan] Mark init-order test as XFAIL on Darwin
llvm-svn: 182365
2013-05-21 10:11:17 +00:00
Alexey Samsonov af456d0c40 [ASan] Don't run fast unwinder tests on 32-bit Linux as fast unwinder may be unexpectedly smart on some hosts
llvm-svn: 182363
2013-05-21 09:35:48 +00:00
Evgeniy Stepanov 4059d778d1 [sanitizer] Enable pthread_getschedparam interceptor on Android.
llvm-svn: 182361
2013-05-21 09:01:23 +00:00
Alexey Samsonov 1c26f007ed [ASan] Mark some tests as working only on x86_64 and i386 arches
llvm-svn: 182360
2013-05-21 09:01:13 +00:00
Evgeniy Stepanov 1d2f22825d [msan] Replace GetArgv hack with something that is slightly better.
llvm-svn: 182359
2013-05-21 08:56:22 +00:00
Alexey Samsonov 4ca93997f7 Add lit config feature <target>-supported-target to mark target-specific tests
llvm-svn: 182355
2013-05-21 08:22:03 +00:00
Dmitry Vyukov 536bff3396 tsan: detect when a thread ends with ignores enabled
llvm-svn: 182354
2013-05-21 08:12:35 +00:00
Evgeniy Stepanov 970be35808 [sanitizer] Intercept pthread_getschedparam.
llvm-svn: 182353
2013-05-21 08:12:08 +00:00
Kostya Serebryany b1333fe831 [sanitizer] fix asan on the platforms where the page size is not a compile-time constant (or at least where EXEC_PAGESIZE may not be trustworthy), e.g. powerpc64.
llvm-svn: 182351
2013-05-21 06:15:50 +00:00
Peter Collingbourne b69b8a4a8f [nolibc] Move GetPageSize to the individual platforms.
GetPageSize wraps sysconf(_SC_PAGESIZE) on POSIX platforms, but
sysconf resides in libc.  To make this libc-independent on Linux,
move the wrapper to sanitizer_mac.cc and return the Linux-specific
constant EXEC_PAGESIZE in the sanitizer_linux.cc implementation.

llvm-svn: 182303
2013-05-20 17:05:29 +00:00
Peter Collingbourne 0c8df4e1d8 [nolibc] Move libc-dependent sanitizer_linux.cc code to sanitizer_linux_libcdep.cc.
llvm-svn: 182292
2013-05-20 15:57:44 +00:00
Peter Collingbourne d5169edc36 [nolibc] Make GetArgsAndEnv libc-independent.
__libc_stack_end is made into a weak symbol if possible.  If libc is
not linked, read args and environment from /proc.

llvm-svn: 182276
2013-05-20 14:25:32 +00:00
Alexey Samsonov cbbdfc50ee Build LSan on x86_64 only if this target is supported
llvm-svn: 182272
2013-05-20 14:16:45 +00:00
Sergey Matveev 6dd91e475a [lsan] Fix r182256.
Add missing call to GetUserBegin().

llvm-svn: 182267
2013-05-20 14:04:56 +00:00
Alexey Samsonov 9711b25d4b [ASan] Nuke build of static ASan runtime on Mac OS
llvm-svn: 182261
2013-05-20 13:38:27 +00:00
Alexey Samsonov 7dcfc46253 [Sanitizer] Build sanitizer runtimes with debug info in Makefile build
llvm-svn: 182260
2013-05-20 13:35:43 +00:00
Alexander Potapenko a15d49cc1f [libsanitizer] Introduce INTERCEPTOR_WITH_SUFFIX which is to be used for appending the __DARWIN_ALIAS() version suffixes to function names on Darwin.
This should fix asan/lit_tests/wait.cc under ASan.

llvm-svn: 182259
2013-05-20 13:32:35 +00:00
Sergey Matveev bcfd838bcb [lsan] GetUserBegin() in LSan.
Separate the notions of user-visible chunk and allocator chunk, to facilitate
ASan integration.

llvm-svn: 182256
2013-05-20 13:08:23 +00:00
Timur Iskhodzhanov 67c918a424 Fix realloc'ing freed/invalid pointers
See https://code.google.com/p/address-sanitizer/issues/detail?id=187 for the details

llvm-svn: 182255
2013-05-20 13:05:58 +00:00
Sergey Matveev 6a6c5b6dee [asan] Modify ASan metadata atomically.
We need this to avoid races when ASan and LSan are used together.

llvm-svn: 182252
2013-05-20 11:25:18 +00:00
Sergey Matveev 3c20829559 [lsan] CMakeLists and lit test configs for LSan.
llvm-svn: 182251
2013-05-20 11:13:33 +00:00
Sergey Matveev 48c1d1acad [lsan] Tests for LeakSanitizer.
llvm-svn: 182250
2013-05-20 11:09:27 +00:00
Sergey Matveev b5483be858 [lsan] Common leak checking module.
Leak checking functionality which will be shared between
LSan/ASan/MSan.

llvm-svn: 182249
2013-05-20 11:06:50 +00:00
Sergey Matveev 3d97cdd140 [lsan] Standalone LSan initialization.
llvm-svn: 182248
2013-05-20 11:04:43 +00:00
Sergey Matveev a5f9691dfb [lsan] Interceptors for standalone LSan.
llvm-svn: 182247
2013-05-20 11:01:40 +00:00
Sergey Matveev c7d003ec43 [lsan] Thread registry for standalone LSan.
llvm-svn: 182246
2013-05-20 10:57:53 +00:00
Sergey Matveev 866abfb3fe [lsan] Allocator for standalone LSan.
This is the first in a series of CLs implementing LeakSanitizer.
http://clang.llvm.org/docs/LeakSanitizer.html

llvm-svn: 182245
2013-05-20 10:54:00 +00:00
Timur Iskhodzhanov 667cae7b69 [ASan] Remove an unused ChunkBase field
Also fix wrong alignment maths and an outdated comment

llvm-svn: 182238
2013-05-20 08:20:17 +00:00
Kostya Serebryany 3469375e4f [sanitizer] factor out ByteMap from SizeClassAllocator32 so that it can be later replaced with a more memory-efficient implementation on 64-bit.
llvm-svn: 182234
2013-05-20 07:29:21 +00:00
Richard Smith 73241096f7 Avoid rebuilding the RTSanitizerCommon objects when building clang_rt.san.
llvm-svn: 182218
2013-05-19 19:53:01 +00:00
Timur Iskhodzhanov 836a4f3643 Replace CHECK(a == b); with CHECK_EQ(a, b); throughout asan_allocator2.cc
llvm-svn: 182198
2013-05-18 18:27:33 +00:00
David Blaikie 97c3018aac Fix the UBSan CMake build broken in r182118
llvm-svn: 182177
2013-05-17 23:57:24 +00:00
Peter Collingbourne ffaf2eac4d [nolibc] Move all platforms to internal_getpid.
Before, we had an unused internal_getpid function for Linux, and a
platform-independent GetPid function.  To make the naming conventions
consistent for syscall-like functions, the GetPid syscall wrapper
in sanitizer_posix.cc is moved to sanitizer_mac.cc, and GetPid is
renamed to internal_getpid, bringing the Linux variant into use.

llvm-svn: 182132
2013-05-17 16:56:53 +00:00
Peter Collingbourne 6d4a7d3723 [nolibc] Begin moving sanitizer_common's libc-dependent code to a separate library
Introduce a new object library, RTSanitizerCommonLibc, which will contain
the subset of sanitizer_common with libc dependencies. RTSanitizerCommon
contains the remainder of sanitizer_common, and is intended to have no
libc dependencies. Begin moving code to RTSanitizerCommonLibc, starting
with sanitizer_common.cc, whose libc-dependent portion is moved to
sanitizer_common_libcdep.cc, the first member of the new library.

This split affects the CMake build only.  The makefile build continues
to produce the full sanitizer_common library.

llvm-svn: 182118
2013-05-17 16:17:19 +00:00
Evgeniy Stepanov bec53faad0 [sanitizer] Fix build with Android NDK r8e.
llvm-svn: 182110
2013-05-17 15:22:32 +00:00
Alexander Potapenko dd3c583211 [ASan] Make the regression test for time(NULL) Linux-specific, as it crashes on Darwin (and the problem used to occur on Linux).
Do not use zero-based shadow for the time() test.

llvm-svn: 182107
2013-05-17 15:11:26 +00:00
Evgeniy Stepanov 44ff0eb4b9 [sanitizer] Fix gcc build.
llvm-svn: 182094
2013-05-17 13:30:48 +00:00
Evgeniy Stepanov ff6728f2f8 [msan] Unpoison dlpi_name in dl_iterate_phdr interceptor.
llvm-svn: 182093
2013-05-17 12:51:13 +00:00
Dmitry Vyukov 9ff1023816 tsan: remove "printing report from signal handler. Can crash or hang" output
it was added to debug mysterious hangs, but it does not seem to happen anymore
now it only clutter up output

llvm-svn: 182089
2013-05-17 12:05:44 +00:00
Dmitry Vyukov c9af818515 tsan: introduce recursive mutex lock/unlock java interface
this is required to handle Object.Wait()

llvm-svn: 182088
2013-05-17 12:03:46 +00:00
Dmitry Vyukov 69c544d857 tsan: comment out debug output in test
llvm-svn: 182087
2013-05-17 11:54:37 +00:00
Alexander Potapenko 00b44ba778 [ASan] Fix allow_user_segv.cc on Darwin (32-bit build required a SIGBUS handler instead of the SIGSEGV one)
llvm-svn: 182080
2013-05-17 08:08:50 +00:00
Alexander Potapenko 12d09f3a3d [ASan] Fix init-order-dlopen.cc to pass under Mac OS.
llvm-svn: 182010
2013-05-16 14:51:01 +00:00
Alexander Potapenko 3917fe0d94 [ASan] Fix interface_symbols_darwin to pass a correct flag to nm.
llvm-svn: 182008
2013-05-16 13:49:12 +00:00
Kostya Serebryany 21cbaee6a9 [sanitizer] fix gcc build
llvm-svn: 182006
2013-05-16 13:24:31 +00:00
Kostya Serebryany aaf7275677 [asan] symbolize when possible, even if ASAN_SYMBOLIZER_PATH is not provided. On Linux this will use dl_iterate_phdr instead of /proc/self/maps, even if the symbolizer is not installed
llvm-svn: 182005
2013-05-16 13:04:29 +00:00
Evgeniy Stepanov 87c6ec7cfe [msan] Intercept dl_iterate_phdr.
llvm-svn: 182004
2013-05-16 13:00:25 +00:00
Sergey Matveev efb6172cb3 [sanitizer] Fix the region overflow condition in SanitizerAllocator64::PopulateFreeList().
llvm-svn: 182002
2013-05-16 12:58:34 +00:00
Kostya Serebryany 19eb46f4ca [sanitizer] fix a gcc warning
llvm-svn: 181992
2013-05-16 08:03:26 +00:00
Kostya Serebryany b7ca536888 [asan] fix ShadowGapTest on PowerPC64
llvm-svn: 181991
2013-05-16 07:54:28 +00:00
Kostya Serebryany a551aaa944 [sanitizer] fix the GetBlockBegin overflow bug while preserving the performance optimization (use 32-bit division when possible). Improve the benchmarks that checks for performance of GetBlockBegin/GetMetaData
llvm-svn: 181989
2013-05-16 07:11:16 +00:00
Kostya Serebryany ad9971d793 [sanitizer] added a test for a bug in allocator discovered by Sergey Matveev (uint32 overflow in GetBlockBegin)
llvm-svn: 181984
2013-05-16 05:22:50 +00:00
Bill Wendling c054086630 Try to improve performance by using a read/write buffer instead of I/O.
The calls to fwrite/fread can be very expensive. GCC avoids this by using a
buffer to read and write from the file, thus limiting the number of fwrite/fread
calls.

<rdar://problem/13466086>

llvm-svn: 181924
2013-05-15 21:31:22 +00:00
Kostya Serebryany 2b824f3575 [asan] disable BuiltinLongJmpTest on PowerPC
llvm-svn: 181890
2013-05-15 15:01:14 +00:00
Kostya Serebryany 2b42716213 [asan] fix powerpc build and one test; fix lint
llvm-svn: 181881
2013-05-15 12:36:29 +00:00
Sergey Matveev 2387687788 [sanitizer] Fix Android build.
llvm-svn: 181796
2013-05-14 15:22:39 +00:00
Sergey Matveev 61101ba419 [sanitizer] Fixed a bug in GetListOfModules.
llvm-svn: 181793
2013-05-14 14:48:58 +00:00
Sergey Matveev 4b603e5c50 [sanitizer] Filtering in GetListOfModules.
llvm-svn: 181791
2013-05-14 14:04:06 +00:00
Evgeniy Stepanov f1efb256f6 Add sanitizer syscall hooks to the tool's export lists.
llvm-svn: 181790
2013-05-14 13:55:21 +00:00
Sergey Matveev af05543c86 [sanitizer] LibraryNameIs in sanitizer_linux
llvm-svn: 181787
2013-05-14 13:24:46 +00:00
Sergey Matveev 14b56186ab [sanitizer] Minor fixes in sanitizer_common tests.
llvm-svn: 181786
2013-05-14 13:19:33 +00:00
Kostya Serebryany 9d987e34f7 [tsan] fix gcc build with -Wall
llvm-svn: 181763
2013-05-14 08:26:55 +00:00
Sylvestre Ledru 7b4baa91ce Fix a typo in the comment
llvm-svn: 181708
2013-05-13 14:53:09 +00:00
Sergey Matveev d9da20f56f [sanitizer] Generic sorting in sanitizer_common.
llvm-svn: 181698
2013-05-13 11:58:48 +00:00
Sergey Matveev 37432e815e [sanitizer] Fix StopTheWorld build on non-Android ARM.
Original patch by Abdoulaye Walsimou Gaye.

llvm-svn: 181697
2013-05-13 10:35:20 +00:00
Peter Collingbourne 53caf563a9 Try to fix Windows build too
llvm-svn: 181457
2013-05-08 18:15:01 +00:00
Peter Collingbourne 8e110ce57c Try to fix the mac buildbots
llvm-svn: 181440
2013-05-08 15:07:12 +00:00
Peter Collingbourne 6f4be19b57 [nolibc] Change internal syscall API to remove reliance on libc's errno.
This change moves to a model where the error value of a system call is
potentially contained in the return value itself rather than being
implicit in errno.  The helper function internal_iserror can be used
to extract the error value from a return value.  On platforms other
than Linux/x86_64 this still uses errno, but other platforms are free
to port their error handling to this new model.

Differential Revision: http://llvm-reviews.chandlerc.com/D756

llvm-svn: 181436
2013-05-08 14:43:49 +00:00
Sergey Matveev ffe38d267c Quick fix for ASan test build on Android.
llvm-svn: 181429
2013-05-08 14:11:12 +00:00
Sergey Matveev 0d8cc4a2d2 [sanitizer] Fix build breakage in Go TSan.
llvm-svn: 181428
2013-05-08 13:59:30 +00:00
Sergey Matveev af179b8d63 [sanitizer] Move GetStackTrace from ASan to sanitizer_common.
llvm-svn: 181424
2013-05-08 12:45:55 +00:00
Peter Collingbourne 5829a98c48 [nolibc] Disable the GCC stack protector when building sanitizer runtimes.
This is the first in a sequence of changes designed to eliminate the
libc dependency in sanitizer_common.  The main motivation for these
changes is to be able to provide an alternative for the current
interceptor-based technique for instrumenting functions in libc.
In this new technique, we compile libc with instrumentation.  This has
the potential advantages of being more accurate than interception and
reducing the amount of custom code required for each libc function.
As a side effect of this, we cannot depend on libc in the sanitizer
runtime due to mutual dependency issues.

This change disables the GCC stack protector, which introduces a libc
dependency and is enabled by default in Ubuntu.

Differential Revision: http://llvm-reviews.chandlerc.com/D755

llvm-svn: 181422
2013-05-08 10:39:05 +00:00
Sergey Matveev 3704453368 [sanitizer] Fixed InitTlsSize for Android.
llvm-svn: 181330
2013-05-07 16:29:26 +00:00
Sergey Matveev 88d0c664ef [sanitizer] Fixed includes in sanitizer_linux.cc for Android.
llvm-svn: 181327
2013-05-07 15:38:53 +00:00
Sergey Matveev 954c6ef10f [sanitizer] Move GetThreadStackAndTls from TSan to sanitizer_common.
Move this function to sanitizer_common because LSan uses it too. Also, fix a bug
where the TLS range reported for main thread was off by the size of the thread
descriptor from libc (TSan doesn't care much, but for LSan it's critical).

llvm-svn: 181322
2013-05-07 14:41:43 +00:00
Evgeniy Stepanov 517118e6b4 [sanitizer] Sanitizer __internal_*stat interface.
With this change, __internal_*stat always expect a "struct stat *" argument.
This avoids stat/stat64 caller-side confusion (sanitizer_common tests already
made this mistake), and allows the use of __internal_fstat() as a drop-in
replacement for libc's fstat().

llvm-svn: 181311
2013-05-07 12:47:04 +00:00
Sergey Matveev 6eff11e714 [msan] Common flags in MSan.
llvm-svn: 181194
2013-05-06 13:15:14 +00:00
Sergey Matveev 0c8ed9ce44 [asan] Common flags in ASan.
Some flags that are common to ASan/MSan/TSan/LSan have been moved to
sanitizer_common.

llvm-svn: 181193
2013-05-06 11:27:58 +00:00
Bill Wendling e575be4c0e I was wrong in my testing.
There isn't a speedup when using unbuffered I/O. It slows it down in fact.

llvm-svn: 181060
2013-05-03 22:06:41 +00:00
Bill Wendling 6ce98c49f4 Use unbuffered I/O. This reduces the runtime by about half. Our implementation is now only about 5 times slower than gcc's.
llvm-svn: 180980
2013-05-03 00:25:49 +00:00
Bob Wilson b1835b7947 Rewrite sw_vers makefile check to avoid error message on Linux.
When building compiler-rt on Linux, the "which sw_vers" check fails and
writes an error message into the build log. Apparently on Solaris "which"
writes the error message to stdout, so that the current test won't even
work properly. As far as I know sw_vers always lives in /usr/bin, so just
check for it there instead of using "which".

llvm-svn: 180792
2013-04-30 17:06:40 +00:00
Dmitry Vyukov 93b2cba03b asan: fix windows build
llvm-svn: 180788
2013-04-30 13:30:29 +00:00
Dmitry Vyukov db7d9e5db4 tsan: comment out debug output in test
llvm-svn: 180787
2013-04-30 13:09:31 +00:00
Dmitry Vyukov e8fa45a02c asan/tsan: fix printf(), on the second pass it prints garbage and crashes on random pointer dereference
llvm-svn: 180784
2013-04-30 12:27:48 +00:00
Dmitry Vyukov d0ac6c168b tsan: fix deadlock detector table (OK to lock sync var mutex during reporting)
llvm-svn: 180782
2013-04-30 12:00:40 +00:00
Dmitry Vyukov 56cf378071 tsan: reverse stack trace for failed CHECK's, this is how we print traces in other places
llvm-svn: 180781
2013-04-30 11:57:32 +00:00
Dmitry Vyukov 3f7bf08b12 tsan: add interface functions for unaligned access, e.g. __sanitizer_unaligned_load16
llvm-svn: 180780
2013-04-30 11:56:56 +00:00
Dmitry Vyukov 639ba01fc3 asna/tsan/msan: fix wait() interceptors to allow NULL arguments
llvm-svn: 180703
2013-04-29 09:04:24 +00:00
Sergey Matveev b2151b8200 Revert r180599 "[sanitizer] Clear LD_PRELOAD when forking an external symbolizer."
llvm-svn: 180602
2013-04-26 13:01:40 +00:00
Sergey Matveev 3c8fbe1013 [sanitizer] Clear LD_PRELOAD when forking an external symbolizer.
llvm-svn: 180599
2013-04-26 11:35:05 +00:00
Evgeniy Stepanov 9562bbaf9a Add -fno-rtti to ASan runtime cflags on Android.
Otherwise we are picking up an extra libstdc++ dependency.

llvm-svn: 180265
2013-04-25 14:58:23 +00:00
Alexey Samsonov 5c38383205 [ASan] Add allow_user_segv_handler to let users override SEGV handler installed by ASan
llvm-svn: 180255
2013-04-25 10:52:15 +00:00
Dmitry Vyukov a05bbe1c9a tsan: add a test that used to crash, fixed by r180180.
llvm-svn: 180251
2013-04-25 06:58:43 +00:00
Dmitry Vyukov 368d97e33c tsan: fix stack traces for malloc and free
llvm-svn: 180184
2013-04-24 11:16:47 +00:00
Dmitry Vyukov 7a8535d2f2 tsan: run tests sequentially otherwise cmake says:
make[3]: make[3]: /bin/sh: ../../../../../bin/clang: Text file busy

llvm-svn: 180183
2013-04-24 11:07:25 +00:00
Dmitry Vyukov beaf786151 tsan: disable getpwuid_r() and glob64() interceptors under tsan, because they cause interceptor recursion if user intercepts fopen()
llvm-svn: 180182
2013-04-24 11:06:05 +00:00
Dmitry Vyukov 54d9c81082 tsan: fix crash when data race happens on out-of-bounds accesses.
llvm-svn: 180180
2013-04-24 09:20:25 +00:00
Bob Wilson f7405fabf5 Use the new iOS deployment target command-line options.
We now rely on the -mios-simulator-version-min option to identify the iOS
simulator target. I'm not sure if there's anything in compiler-rt where that
matters, but it's the right thing to do regardless.

llvm-svn: 180163
2013-04-23 23:52:10 +00:00
Dmitry Vyukov c63d73e59d tsan: support heap starting at 0x04c0 (used in some custom deplyments)
llvm-svn: 180116
2013-04-23 15:59:56 +00:00
Dmitry Vyukov 43cf90f4d1 tsan: update Go memory mapping, Go now uses 0x00c0 heap base
llvm-svn: 180113
2013-04-23 15:24:26 +00:00
Evgeniy Stepanov 44b75efab4 [sanitizer] Intercept inet_pton and inet_ntop.
llvm-svn: 180107
2013-04-23 14:05:15 +00:00
Alexey Samsonov bcd32a9525 [ASan] Disable strict-init-order checker once we have more than one thread, as this mode is thread-hostile
llvm-svn: 180106
2013-04-23 13:57:35 +00:00
Alexey Samsonov 34093f0de8 [MSan] Make a few interface functions accept 'const void *' instead of 'void*'
llvm-svn: 180102
2013-04-23 13:34:19 +00:00
Evgeniy Stepanov 455abf4872 [msan] Unpoison the result of posix_memalign.
llvm-svn: 180101
2013-04-23 13:27:36 +00:00
Alexey Samsonov f36c5a8431 Revert r180082 and add a test for SetEnv function
llvm-svn: 180098
2013-04-23 12:49:12 +00:00
Alexander Potapenko 262eb01bbf [ASan] Make wait.cc more Darwin-compatible: fix the header name and the CHECK patterns.
llvm-svn: 180097
2013-04-23 12:36:37 +00:00
Alexander Potapenko 15aa1cd1ac [ASan] Disable AddressSanitizer.AllocDeallocMismatch on Darwin.
See https://code.google.com/p/address-sanitizer/issues/detail?id=131.

llvm-svn: 180093
2013-04-23 12:14:55 +00:00
Evgeniy Stepanov 3076ba0a08 [sanitizer] Intercept getgrnam{_r}, getgrgid{_r}.
llvm-svn: 180091
2013-04-23 12:01:20 +00:00
Evgeniy Stepanov 0cd7cf8217 [msan] Allow clock_getres(, 0).
llvm-svn: 180090
2013-04-23 11:48:31 +00:00
Alexey Samsonov e7540e3561 [Sanitizer] Delete unused function
llvm-svn: 180082
2013-04-23 08:18:09 +00:00
Evgeniy Stepanov 1a2262e1c9 [sanitizer] Fix lint.
llvm-svn: 180012
2013-04-22 13:28:26 +00:00
Bill Wendling 9a9141aed5 Improve performance of file I/O.
The fread / fwrite calls were happening for each timer. However, that could be
pretty expensive for a large number of timers. Instead, read and write the
timers in one call.

This gives ~10% speedup in compilation time.

llvm-svn: 179990
2013-04-22 03:36:22 +00:00
Alexey Samsonov e7ea8cfb49 Fixup for r179843: add missing header
llvm-svn: 179844
2013-04-19 08:49:05 +00:00
Alexey Samsonov dcf0ade114 [ASan] Make init-order checker allow access to already initialized globals.
This change adds ASan runtime option "strict-init-order" (off by default)
that makes init-order checker bark if global initializer accesses any global from different
translation unit (even if the latter is already initialized). strict init-order checking
doesn't play well with, e.g. LLVM registration machineries, and causes issue 
https://code.google.com/p/address-sanitizer/issues/detail?id=178.

llvm-svn: 179843
2013-04-19 08:35:16 +00:00
Alexey Samsonov 6021e94774 [TSan] Allocate fd table in user heap instead of using internal allocator. We need this to catch races on fds.
llvm-svn: 179841
2013-04-19 08:04:46 +00:00
Alexey Samsonov 1a6cfb46e5 [Sanitizer] Rework r176802: share code between Printf and Report and simplify it a bit
llvm-svn: 179755
2013-04-18 13:18:23 +00:00
Alexey Samsonov d1efa5ef96 [Sanitizer] Don't die in symbolizer if it can't read /proc/self/exe link
llvm-svn: 179754
2013-04-18 12:46:33 +00:00
Andy Gibbs f6edda8c30 Wrap macro invocations in braces to supress 'suggest braces around empty body in an ‘if’ statement' warning.
llvm-svn: 179597
2013-04-16 15:18:55 +00:00
Sergey Matveev 0136943e03 [asan] Fix spelling in asan_rtl.cc Test commit.
Reviewers: kcc, glider, samsonov

Reviewed By: glider

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D676

llvm-svn: 179595
2013-04-16 14:58:45 +00:00
Evgeniy Stepanov d1dae90bf2 [msan] Fix gcc build of msan_test.
llvm-svn: 179594
2013-04-16 14:09:47 +00:00
Evgeniy Stepanov 9b59a39f42 [sanitizer] Implement wait4 and waitpid syscall hooks.
llvm-svn: 179592
2013-04-16 13:06:20 +00:00
Evgeniy Stepanov b0d786798c [msan] Fix sigaction test.
Restore SIGPROF handler to the original state after the test.

llvm-svn: 179524
2013-04-15 13:35:05 +00:00
Evgeniy Stepanov 7332acac4c [msan] Really disable replacement new and delete.
llvm-svn: 179522
2013-04-15 12:41:52 +00:00
Evgeniy Stepanov 755eb32a39 [sanitizer] Add syscall handlers to ASan and TSan runtimes.
ASan checks addressability of syscall arguments. TSan does nothing for now.

llvm-svn: 179380
2013-04-12 14:57:03 +00:00
Evgeniy Stepanov 9fb82357dc [sanitizer] More syscall handler placeholders.
This time it's the full list scavenged from syscalls.h
Fixed return value type.

llvm-svn: 179378
2013-04-12 14:06:40 +00:00
Timur Iskhodzhanov 664ec5d7a8 Finally drop the 'static' from INLINE and ALWAYS_INLINE
The ALWAYS_INLINE doesn't have static on POSIX anyways since r178341; the INLINE is only used in .h files, so shouldn't have been 'static' in the first place

llvm-svn: 179371
2013-04-12 09:37:20 +00:00
Alexey Samsonov e48866969e [MSan] Demangle function name in description of stack origin
llvm-svn: 179368
2013-04-12 07:27:30 +00:00
Alexey Samsonov 1a345ad502 [MSan] don't build tests with -fPIE/-pie, as these flags are implied by -fsanitize=memory now
llvm-svn: 179366
2013-04-12 07:14:04 +00:00
Alexey Samsonov 0d725b1408 [TSan] remove -fPIE -pie from TSan lit tests to check that -fsanitize=thread implies them now
llvm-svn: 179365
2013-04-12 07:11:00 +00:00
Kostya Serebryany fd27b83ef2 [asan] inline flags(), up to 1% perf gain on malloc-intensive code
llvm-svn: 179307
2013-04-11 18:36:04 +00:00
Kostya Serebryany bb68f2cd65 [asan] make heavy_uar_test even heavier
llvm-svn: 179306
2013-04-11 18:27:02 +00:00
Alexey Samsonov 9f3938e271 Explicitly list all sanitizer headers in CMake build rules. Make sure sanitizer lit_tests depend on fresh headers.
llvm-svn: 179293
2013-04-11 15:49:52 +00:00
Kostya Serebryany 1c77de3aeb [asan] improve the UAR reporting (try harder to find the correct frame), try to make the test more stable
llvm-svn: 179292
2013-04-11 15:35:40 +00:00
Evgeniy Stepanov f5523116e9 [sanitizer] Syscall hooks.
Pre- and post- hooks for linux syscalls. Not wired into anything, but exposed
through public interface.

llvm-svn: 179288
2013-04-11 14:37:04 +00:00
Kostya Serebryany 18f0820552 [asan] make heavy_uar_test a bit more heavy and fix he fake stack to pass this test
llvm-svn: 179286
2013-04-11 14:07:02 +00:00
Alexey Samsonov a672ba6e8f [ASan] test source-based init-order blacklisting added in r179280
llvm-svn: 179281
2013-04-11 13:21:41 +00:00
Kostya Serebryany 3fec2f534a [asan] fix use-after-return functionality (PR15672) and enable the corresponding test. We still don't guarantee anything with regard to use-after-return checking
llvm-svn: 179278
2013-04-11 12:49:38 +00:00
Alexey Samsonov 46cc45a291 [ASan] Symbolize correct address when printint error summary
llvm-svn: 179274
2013-04-11 11:45:04 +00:00
Kostya Serebryany 4e0a33c8be [asan] move fake stack into a separate .h file; actually disable a failing test
llvm-svn: 179273
2013-04-11 11:39:19 +00:00
Kostya Serebryany fd7f924016 [asan] add heavy_uar_test (disabled); fix lint
llvm-svn: 179271
2013-04-11 11:29:07 +00:00
Alexander Potapenko 227e22de5a [ASan] Do not check the shadow of NULL argument in the time() interceptor.
Add a test for time().

llvm-svn: 179177
2013-04-10 15:13:00 +00:00
Kostya Serebryany 92684efb1d [asan] implement callbacks for unaligned loads/stores
Reviewers: samsonov

Reviewed By: samsonov

CC: samsonov, llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D652

llvm-svn: 179175
2013-04-10 13:59:32 +00:00
Alexey Samsonov c0443c5d25 [ASan] fix a typo in legend in error report
llvm-svn: 179161
2013-04-10 07:00:25 +00:00
Evgeniy Stepanov 460067823b [sanitizer] Interceptors for wait*.
llvm-svn: 179096
2013-04-09 14:34:59 +00:00
Evgeniy Stepanov 69967c2835 [msan] Intercept glob() with tests.
llvm-svn: 179091
2013-04-09 11:35:13 +00:00
Alexey Samsonov 7ad129277e [Sanitizer] fix TSan tests: remove global ctor from sanitizer_common, run load_shared_lib test only in lit
llvm-svn: 179090
2013-04-09 07:46:20 +00:00
Kostya Serebryany 9d28efc1ad [asan] relax Linux/zero-base-shadow.cc to make it pass on newer Ubuntu; fix lint
llvm-svn: 179088
2013-04-09 07:08:05 +00:00
Chandler Carruth 2b3c00eec7 Revert r179012: "[msan] Intercept glob()."
This was committed without tests and contains obvious bugs. That's not
acceptable. It broke address sanitizer for most programs using glob(3).

llvm-svn: 179054
2013-04-08 20:59:44 +00:00
Alexander Potapenko 32efd25b93 [libsymbolized] If we can't find an address in the list of shared libraries, try to reload it.
Add a regression test for the case where such behavior helps TSan:
  1. race is reported in the main module
  2. new shared library is loaded
  3. race is reported in the shared library

llvm-svn: 179032
2013-04-08 17:46:34 +00:00
Evgeniy Stepanov b4eac2f810 [msan] Interceptors for pipe2 and socketpair.
llvm-svn: 179022
2013-04-08 13:45:12 +00:00
Evgeniy Stepanov 8cd707a1a6 [msan] Intercept glob().
llvm-svn: 179012
2013-04-08 09:03:00 +00:00
Evgeniy Stepanov e20c780aaf [tsan] Fix build.
llvm-svn: 179008
2013-04-08 08:46:25 +00:00
Kostya Serebryany e6459977b8 [sanitizer] Fix boundary condition in LargeMmapAllocator::GetBlockBegin. Patch by Sergey Matveev
llvm-svn: 179007
2013-04-08 08:43:22 +00:00
Evgeniy Stepanov 7ba7207f1d [msan] Intercept time().
llvm-svn: 179002
2013-04-08 08:25:22 +00:00
Kostya Serebryany 228ecf46ab [asan] make huge_negative_hea_oob more meaningful
llvm-svn: 178876
2013-04-05 15:16:48 +00:00
Kostya Serebryany f5407e8d8f [asan] add a test for huge left oob
llvm-svn: 178874
2013-04-05 15:13:23 +00:00
Kostya Serebryany 5b4267f7e7 [sanitizer] found a bug by code inspection: CHECK(a=b) instead of CHECK(a==b). Was puzzled why lint did not catch it. Turns out this check was disabled for asan source. fix all cases and enable the check
llvm-svn: 178872
2013-04-05 14:40:25 +00:00
Evgeniy Stepanov e7a7a9b972 [msan] Fix sigaction interceptor.
llvm-svn: 178868
2013-04-05 12:58:07 +00:00
Evgeniy Stepanov c7af878a01 [msan] Conditionally disable new() and delete() wrappers.
To be used with static libstdc++.

llvm-svn: 178866
2013-04-05 12:03:47 +00:00
Evgeniy Stepanov 7948c648bf [msan] A runtime option to disable wrapping of signal handlers.
llvm-svn: 178865
2013-04-05 11:59:16 +00:00
Alexey Samsonov 2a4668557f [Sanitizer] enquote the module name when passing it to external symbolizer
llvm-svn: 178864
2013-04-05 11:54:23 +00:00
Alexey Samsonov 5afe6aa141 [ASan] init-order checker tests: move constexpr test that requires -std=c++11 to a separate test case. Check that structs with no ctor but non-trivial dtor are ignored.
llvm-svn: 178857
2013-04-05 07:51:49 +00:00
Alexey Samsonov 46b8665ea4 Remove InternalAlloc/InternalFree calls from StopTheWorld. Patch by Sergey Matveev.
llvm-svn: 178855
2013-04-05 07:41:21 +00:00
Alexey Samsonov 734aab4066 [Sanitizer] Use a common mutex to prevent mixing reports from different sanitizers. This fixes PR15516
llvm-svn: 178853
2013-04-05 07:30:29 +00:00
Alexey Samsonov 70a9c263d4 [TSan] Make path to FileCheck configurable
llvm-svn: 178760
2013-04-04 12:18:12 +00:00
Kostya Serebryany eef8bd4355 [asan] nuke the old unused allocator code
llvm-svn: 178758
2013-04-04 11:32:49 +00:00
Kostya Serebryany 13b07733b1 [asan] fill first 4K of malloc-ed memory with garbage, implement flags max_malloc_fill_size and malloc_fill_byte
llvm-svn: 178757
2013-04-04 11:17:14 +00:00
Evgeniy Stepanov 24b2169e07 [sanitizer] Android lacks ucontext_t definition.
llvm-svn: 178756
2013-04-04 09:21:48 +00:00
Evgeniy Stepanov 7b0e132551 [sanitizer] Use ucontext_t instead of "struct ucontext".
Fixes Mac build.

llvm-svn: 178755
2013-04-04 09:03:56 +00:00
Evgeniy Stepanov 1f8b3538b4 [msan] Unpoison siginfo_t and ucontext_t in signal handlers.
Add wrappers for all user signal handlers to unpoison the handler's arguments.

llvm-svn: 178754
2013-04-04 08:22:52 +00:00
Kostya Serebryany c3525ce6ac [sanitizer] while doing fast unwinding make sure that the frame pointer is aligned; fix lint
llvm-svn: 178747
2013-04-04 06:52:40 +00:00
Alexey Samsonov 87c2a87b50 [Sanitizer] Fix OnPrint weak hook. Disable weak hooks for gotsan.
llvm-svn: 178640
2013-04-03 13:22:54 +00:00
Alexey Samsonov 60adc1781e [Sanitizer] Be more careful with arch-specific defines in StopTheWorld code
llvm-svn: 178630
2013-04-03 08:26:03 +00:00
Alexey Samsonov 21cb74318c [ASan] Kill the remainders of platform defines in favor of SANITIZER_ defines
llvm-svn: 178629
2013-04-03 07:29:53 +00:00
Alexey Samsonov a0e28a7aaa [Sanitizer] Kill the remainders of platform defines in favor of SANITIZER_ defines
llvm-svn: 178627
2013-04-03 07:24:35 +00:00
Alexey Samsonov 8d18cc3096 [Sanitizer] Fix StopTheWorld includes on Android. Patch by Sergey Matveev.
llvm-svn: 178625
2013-04-03 07:06:10 +00:00
Alexander Potapenko bbfc722e46 [TSan] Add the WTFAnnotateBenignRaceSized implementation and a test for
WTFAnnotateBenignRaceSized and AnnotateBenignRaceSized.

llvm-svn: 178534
2013-04-02 11:21:53 +00:00
Evgeniy Stepanov f8213b4eb3 [sanitizer] More interceptors.
getpwnam, getpwuid, getpwnam_r, getpwuid_r, clock_getres, clock_gettime,
clock_settime, getitimer, setitimer, sigaction (MSan).

llvm-svn: 178465
2013-04-01 14:47:21 +00:00
Alexander Potapenko 1d021bff28 [libsanitizer] Run the callback on a separate stack in StopTheWorld.
Currently the callback runs on the caller's stack. If this stack
contains values that have gone out of scope, and we are not super careful, those
values can propagate into global variables (the libc sigaction() in particular
has a side effect that can lead to this). This has caused false negatives in
leak checking code.

Changes: map a separate stack space for the tracer thread. Also, move some
globals into local scope (they had no business being global anyway).

Patch by Sergey Matveev (earthdok@google.com)

llvm-svn: 178464
2013-04-01 14:38:56 +00:00
Alexander Potapenko 401bed0b9a [libsanitizer] Added data() and capacity() getters to InternalVector.
Same interface as in STL. Needed for LSan.

Patch by Sergey Matveev (earthdok@google.com)

llvm-svn: 178463
2013-04-01 13:55:34 +00:00
Alexander Potapenko 9cc2e436bb [libsanitizer] Add register dumping support to SuspendedThreadsList.
An interface for obtaining register contexts from suspended threads. Tailored
for LSan use.

Patch by Sergey Matveev (earthdok@google.com)

llvm-svn: 178461
2013-04-01 13:36:42 +00:00
Alexey Samsonov e624795558 [ASan] More careful reports for globals that are ASCII strings
llvm-svn: 178458
2013-04-01 08:57:38 +00:00