Commit Graph

4483 Commits

Author SHA1 Message Date
Viktor Kutuzov 82041bbc08 Add FreeBSD support to the address sanitizer's null_deref.cc test case
Differential Revision: http://reviews.llvm.org/D4421

llvm-svn: 213130
2014-07-16 09:37:40 +00:00
Kuba Brecka 58f44dce96 [ASan] Add ASan debugging API to get malloc/free stack traces and shadow memory mapping info
Reviewed at http://reviews.llvm.org/D4466

llvm-svn: 213080
2014-07-15 17:33:23 +00:00
Dmitry Vyukov 1015f8d753 tsan: remove special handling of false reports coming from JVM
There is now a more common functionality in the form of called_from_lib suppressions.

llvm-svn: 213057
2014-07-15 09:38:30 +00:00
Dmitry Vyukov 48b00fe8f9 tsan: remove compat mapping
There are no known usages anymore, so one less thing to support.

llvm-svn: 213056
2014-07-15 09:31:29 +00:00
Evgeniy Stepanov bce3cf8074 [sanitizer] De-flake one test.
llvm-svn: 213054
2014-07-15 08:46:51 +00:00
Timur Iskhodzhanov 9e4580c8ee [ASan] Only define macros in asan_init_version.h, move the __asan_init declaration back to asan_interface_internal.h
This fixes the issues we've uncovered after landing r212815.

Reviewed at http://reviews.llvm.org/D4500

llvm-svn: 213053
2014-07-15 08:16:04 +00:00
Ehsan Akhgari 911ea4e2be Add support for intercepting thunks of the form
llvm-svn: 212979
2014-07-14 20:28:21 +00:00
Timur Iskhodzhanov 0aad92e0d6 [ASan/Win] Add a test for the case when dll_thunk is linked twice to the same DLL
This is a test case for r212815.

llvm-svn: 212959
2014-07-14 17:04:03 +00:00
Kostya Serebryany 6cdb0b8051 [tsan] honour XFAIL in tsan/test_output.sh
llvm-svn: 212952
2014-07-14 16:03:13 +00:00
Kostya Serebryany 850a837cf2 [tsan] add a printf to a test
llvm-svn: 212951
2014-07-14 15:52:33 +00:00
Kostya Serebryany 94b6801839 [tsan] add a currently-failing test with a must-deadlock
llvm-svn: 212944
2014-07-14 14:27:21 +00:00
Timur Iskhodzhanov 9b8fa878ea [ASan] Fix a couple of nits in NULL deref tests
This is a follow-up to r212807

llvm-svn: 212943
2014-07-14 14:26:35 +00:00
Evgeniy Stepanov d73e7cc879 [sanitizer] Intercept getpass.
llvm-svn: 212937
2014-07-14 13:07:51 +00:00
Evgeniy Stepanov 465466e80c [msan] Stop demangling function name in the stack origin report.
This was done by calling __cxa_demangle directly, which is bad
when c++abi library is instrumented. The following line always
contains the demangled name (when running with a symbolizer) anyway.

llvm-svn: 212929
2014-07-14 09:35:27 +00:00
Evgeniy Stepanov 6c254aa70e [asan] Remove XFAIL:android from 2 newly passing tests.
Fixed in r212872.

llvm-svn: 212926
2014-07-14 08:54:10 +00:00
Alexey Samsonov 15c9669615 [ASan] Collect unmangled names of global variables in Clang to print them in error reports.
Currently ASan instrumentation pass creates a string with global name
for each instrumented global (to include global names in the error report). Global
name is already mangled at this point, and we may not be able to demangle it
at runtime (e.g. there is no __cxa_demangle on Android).

Instead, create a string with fully qualified global name in Clang, and pass it
to ASan instrumentation pass in llvm.asan.globals metadata. If there is no metadata
for some global, ASan will use the original algorithm.

This fixes https://code.google.com/p/address-sanitizer/issues/detail?id=264.

llvm-svn: 212872
2014-07-12 00:42:52 +00:00
Alexey Samsonov ae9d59e8c4 [ASan] Improve ODR-violation error reports.
Demangle names of involved globals. Print a more consistent summary line.

llvm-svn: 212857
2014-07-11 23:34:26 +00:00
Kostya Serebryany 8e9a5b1899 [asan] fix x32 build, patch by H.J. Lu
llvm-svn: 212823
2014-07-11 15:22:45 +00:00
Timur Iskhodzhanov 03f1e408de [ASan/Win] Don't apply dllexport to __asan_init in the DLL thunk
This fixes '___asan_init_v4 already defined' errors when linking some of Chromium DLLs.
Looks like one of the DLL is using a .lib produced while linking another DLL and it exploded after r212699.
I'm trying to come up with a small testcase...

llvm-svn: 212815
2014-07-11 13:46:05 +00:00
Timur Iskhodzhanov f6827cef73 [ASan] Print register values in a consistent way
llvm-svn: 212809
2014-07-11 12:14:46 +00:00
Timur Iskhodzhanov 19853dd28c [ASan/Win] Catch NULL derefs and page faults
Reviewed at http://reviews.llvm.org/D4471

llvm-svn: 212807
2014-07-11 11:57:41 +00:00
Evgeniy Stepanov 9c62621c4b [msan] A comment for the chained-origin-depot hash function.
llvm-svn: 212801
2014-07-11 09:09:37 +00:00
Evgeniy Stepanov db298121e0 [msan] Use real memset/memcpy/memmove in interceptors.
Our versions are not exactly as fast as libc's, and
MSan uses them heavily (even compared to other sanitizers).

This will break if libc version of mem* are instrumented,
but they never are, and if they are, we should be able
to fix it on libc side.

llvm-svn: 212799
2014-07-11 08:57:57 +00:00
Evgeniy Stepanov 23e8dfd487 [msan] Make one test case less brittle.
llvm-svn: 212798
2014-07-11 08:47:51 +00:00
Diego Novillo 89360191c8 Fix expected column numbers in two tests.
This is a minor fix to two tsan tests that were expecting the wrong
column information. Now that clang emits column information by default
in its debugging output, the tests had started failing.

llvm-svn: 212779
2014-07-10 23:29:10 +00:00
Alexey Samsonov 3a2cb3ad41 [TSan] Fix a bug in libcxx-tsan build conditions spotted by Ryuta Suzuki
llvm-svn: 212749
2014-07-10 18:17:51 +00:00
Evgeniy Stepanov 8fc7e1fb13 [msan] Fix performance issue in fast_memset.
Fast path was never triggered when called from __msan_poison.

llvm-svn: 212715
2014-07-10 12:45:56 +00:00
Evgeniy Stepanov c2c435f95d [msan] Switch chained origins hash to murmur2.
llvm-svn: 212704
2014-07-10 11:02:33 +00:00
Timur Iskhodzhanov 3eb1f4bb90 [ASan/Win] Don't hardcode ASan runtime version in ASan dll thunk
Reviewed at http://reviews.llvm.org/D4459

llvm-svn: 212699
2014-07-10 10:33:48 +00:00
Tim Northover 9775cffe14 MachO: add dummy armv6m architecture directory so clang_macho_embedded builds things.
Without some mention of armv6m in a subdirectory of builtins, the make code
doesn't even know that armv6m exists and is something it should be looking for
in the platform-specific Makefiles. This means that none of the functions
listed actually get built and we end up with an almost entirely empty
libclang_rt.a for armv6m.

Unfortunately, the assembly code in the usual arm directory has no hope of
running on armv6m, which only supports Thumb-1 (not even ARM mode), so adding
it there won't work. Realistically, we probably *will* want to put any
optimised versions in a separate directory, so creating it now is harmless.

rdar://problem/17613576

llvm-svn: 212696
2014-07-10 10:06:42 +00:00
Viktor Kutuzov f294f25d3a Make sanitizers' interceptors non-weak on FreeBSD
Differential Revision: http://reviews.llvm.org/D4418

llvm-svn: 212693
2014-07-10 09:16:58 +00:00
Viktor Kutuzov 794d4dde48 Only use fast stack unwinding for sanitizers failure reports on FreeBSD
Differential Revision: http://reviews.llvm.org/D4420

llvm-svn: 212691
2014-07-10 09:11:15 +00:00
Viktor Kutuzov d0907ae222 Fix getting environment variables for sanitizers needs on FreeBSD
Differential Revision: http://reviews.llvm.org/D4229

llvm-svn: 212690
2014-07-10 08:53:29 +00:00
Alexey Samsonov 84e0223a9d Fix configure+make build of profile runtime library
llvm-svn: 212665
2014-07-10 00:53:20 +00:00
Alexey Samsonov 020ac94665 [ASan] Force the compiler to generate frame pointer in certain Mac-specific interceptors.
Patch by Kuba Brecka!

llvm-svn: 212664
2014-07-10 00:06:53 +00:00
Alexey Samsonov f723794da8 [Sanitizer] Remove SANITIZER_NEEDS_SEGV from shared sanitizer_common headers.
Otherwise, it can be accidentally redefined when we build specific sanitizer
runtime. This definition should be provided only once - when we build
sanitizer_common library.

llvm-svn: 212663
2014-07-09 23:59:40 +00:00
Alexey Samsonov cd0a4aaba3 Don't check lint for SpecialCaseList.cpp
llvm-svn: 212642
2014-07-09 19:29:10 +00:00
Dmitry Vyukov 67ccf9851c tsan: reapply 212531 and 212532 with a fix
don't reset s->addr as well

llvm-svn: 212565
2014-07-08 20:37:16 +00:00
Alexey Samsonov 047ea1717b [TSan] Revert r212531 and r212532.
They cause "check-tsan" command to hang. Details in r212532 review thread.

llvm-svn: 212562
2014-07-08 20:17:19 +00:00
Dmitry Vyukov 3f5ad1a98e tsan: allow memory overlap in __tsan_java_move
JVM actually moves memory between overlapping ranges.

llvm-svn: 212560
2014-07-08 20:01:12 +00:00
Evgeniy Stepanov eb893a1fd6 [msan] Fix out of bounds access in origin copying.
llvm-svn: 212534
2014-07-08 14:15:23 +00:00
Kostya Serebryany 6136aae323 [tsan] Enable tsan's deadlock detector by default.
The tsan's deadlock detector has been used in Chromium for a while;
it found a few real bugs and reported no false positives.
So, it's time to give it a bit more exposure.

llvm-svn: 212533
2014-07-08 13:40:08 +00:00
Dmitry Vyukov edbb54d60c tsan: fix a potential hang
idx0 is not updated in the branch,
so if we take that branch idx0 will stay updated forever

llvm-svn: 212532
2014-07-08 13:36:59 +00:00
Dmitry Vyukov a480d3013a tsan: fix a bug in metamap
The bug happens in the following case:
Mutex is located at heap block beginning,
when we call MutexDestroy, s->next is set to 0,
so free can't find the MBlock related to the block.

llvm-svn: 212531
2014-07-08 13:28:01 +00:00
Kostya Serebryany 3d570b960e [tsan] fix deadlock detector's interoperation with java locks (https://code.google.com/p/thread-sanitizer/issues/detail?id=67)
llvm-svn: 212529
2014-07-08 13:16:03 +00:00
Dmitry Vyukov b0250948c6 tsan: remove unnecessary line split
llvm-svn: 212527
2014-07-08 13:07:23 +00:00
Kostya Serebryany 7e49b06446 [tsan] fix pthread_rwlock_tryrdlock interceptor, don't try to detect deadlocks when reporting bad unlock
llvm-svn: 212526
2014-07-08 12:46:30 +00:00
Viktor Kutuzov cc02abbb20 Support building floating-point facilities on FreeBSD 9.2 in 32-bit mode
Differential Revision: http://reviews.llvm.org/D3909

llvm-svn: 212518
2014-07-08 08:52:57 +00:00
Alexey Samsonov 1ce0929465 [MSan] Make one more test standalone
llvm-svn: 212487
2014-07-07 20:59:10 +00:00
Alexey Samsonov efe7828c69 [MSan] Use a single file for dso-origin test
llvm-svn: 212484
2014-07-07 20:37:12 +00:00
Alexey Samsonov c1856835d1 [Sanitizer] Move test for malloc/free hooks under test/sanitizer_common
llvm-svn: 212474
2014-07-07 18:47:29 +00:00
Alexey Samsonov 58a046fe56 [ASan] Clean up leftovers from assembly instrumentation helpers
llvm-svn: 212471
2014-07-07 18:11:24 +00:00
Alexey Samsonov 91bb8e0e3a Generalize sanitizer allocator public interface.
Introduce new public header <sanitizer/allocator_interface.h> and a set
of functions __sanitizer_get_ownership(), __sanitizer_malloc_hook() etc.
that will eventually replace their tool-specific equivalents
(__asan_get_ownership(), __msan_get_ownership() etc.). Tool-specific
functions are now deprecated and implemented as stubs redirecting
to __sanitizer_ versions (which are implemented differently in each tool).

Replace all uses of __xsan_ versions with __sanitizer_ versions in unit
and lit tests.

llvm-svn: 212469
2014-07-07 17:39:31 +00:00
Timur Iskhodzhanov 575180dbd2 [ASan/Win] Unbreak the build after r211216
llvm-svn: 212465
2014-07-07 16:22:04 +00:00
Evgeniy Stepanov 86c077b3a2 [asan] Remove runtime assembly helpers.
Remove helper functions that were used in assembly instrumentation.

Patch by Yuri Gorshenin.

llvm-svn: 212456
2014-07-07 13:59:12 +00:00
Evgeniy Stepanov f0831ee8d2 [msan] Increase hash table size for chained origins.
llvm-svn: 212448
2014-07-07 10:45:15 +00:00
Evgeniy Stepanov 037f77092e [msan] Better hash function for chained origins.
llvm-svn: 212440
2014-07-07 08:31:55 +00:00
Evgeniy Stepanov 50498e114f [msan] Reformat one source file.
llvm-svn: 212329
2014-07-04 10:07:39 +00:00
Kostya Serebryany 7c163a44aa [sanitizer] support c11 aligned_alloc, Linux only for now
llvm-svn: 212322
2014-07-04 07:30:34 +00:00
Evgeniy Stepanov 4af9c0ea80 [asan] i686-linux-android support.
Large part of this change is required due to
  https://code.google.com/p/android/issues/detail?id=61799
dlsym() crashes when symbol resolution fails, which means
we have to limit the interceptor list instead of relying on
runtime detection.

There are minor differencies in system headers, too.

llvm-svn: 212273
2014-07-03 14:20:56 +00:00
Evgeniy Stepanov 7c2d32bf87 [asan] Fix unused variable warning.
llvm-svn: 212272
2014-07-03 14:14:59 +00:00
Evgeniy Stepanov 174242c74c [msan] Stop propagating shadow in blacklisted functions.
With this change all values passed through blacklisted functions
become fully initialized. Previous behavior was to initialize all
loads in blacklisted functions, but apply normal shadow propagation
logic for all other operation.

This makes blacklist applicable in a wider range of situations.

It also makes code for blacklisted functions a lot shorter, which
works as yet another workaround for PR17409.

llvm-svn: 212268
2014-07-03 11:56:30 +00:00
Evgeniy Stepanov e1a5a1f7a8 Revert of r212265.
llvm-svn: 212266
2014-07-03 11:35:08 +00:00
Evgeniy Stepanov cfc40ef98a [msan] Stop propagating shadow in blacklisted functions.
With this change all values passed through blacklisted functions
become fully initialized. Previous behavior was to initialize all
loads in blacklisted functions, but apply normal shadow propagation
logic for all other operation.

This makes blacklist applicable in a wider range of situations.

It also makes code for blacklisted functions a lot shorter, which
works as yet another workaround for PR17409.

llvm-svn: 212265
2014-07-03 11:18:48 +00:00
Alexey Samsonov cf009f8a53 XFAIL test on Android (this is a known issue)
llvm-svn: 212211
2014-07-02 20:18:41 +00:00
Alexey Samsonov 4f319cca42 [ASan] Print exact source location of global variables in error reports.
See https://code.google.com/p/address-sanitizer/issues/detail?id=299 for the
original feature request.

Introduce llvm.asan.globals metadata, which Clang (or any other frontend)
may use to report extra information about global variables to ASan
instrumentation pass in the backend. This metadata replaces
llvm.asan.dynamically_initialized_globals that was used to detect init-order
bugs. llvm.asan.globals contains the following data for each global:
  1) source location (file/line/column info);
  2) whether it is dynamically initialized;
  3) whether it is blacklisted (shouldn't be instrumented).

Source location data is then emitted in the binary and can be picked up
by ASan runtime in case it needs to print error report involving some global.
For example:

  0x... is located 4 bytes to the right of global variable 'C::array' defined in '/path/to/file:17:8' (0x...) of size 40

These source locations are printed even if the binary doesn't have any
debug info.

This is an ABI-breaking change. ASan initialization is renamed to
__asan_init_v4(). Pre-built libraries compiled with older Clang will not work
with the fresh runtime.

llvm-svn: 212188
2014-07-02 16:54:41 +00:00
Alexey Samsonov e3a401a12b [MSan] Fixup r212082: enable tests for _mm_ intrinsics if and only if the
unit test source file is compiled with Clang.

llvm-svn: 212121
2014-07-01 19:58:41 +00:00
Alexey Samsonov 06ff6cbf4d [TSan] Equalize the behavior of __tsan_get_allocated_size and user_alloc_usable_size.
The former used to crash with a null deref if it was given a not owned pointer,
while the latter returned 0. Now they both return 0. This is still not the best possible
behavior: it is better to print an error report with a stack trace, pointing
to the error in user code, as we do in ASan.

llvm-svn: 212112
2014-07-01 18:01:20 +00:00
Alexey Samsonov c0fda339e2 Add the way to disable MSan unit tests for _mm_* intrinsics
llvm-svn: 212082
2014-07-01 01:38:52 +00:00
Alexey Samsonov cffaa1c298 Fix apparent thinko in r209744: allocator stats can be zero
llvm-svn: 212071
2014-06-30 22:40:58 +00:00
Evgeniy Stepanov 4e2d5edb0c [msan] Limit stack origin chain length.
Stack origins were created with unlimited length by mistake.

llvm-svn: 212036
2014-06-30 11:22:42 +00:00
Dmitry Vyukov 9507af2d89 tsan: fix and re-enable a test
llvm-svn: 211966
2014-06-27 22:27:02 +00:00
Evgeniy Stepanov c935ca8c3c [msan] Add store_context_size= flag.
A new flag to control stack trace size for store event (in
track-origins=2 mode) independently of malloc_context_size.

llvm-svn: 211896
2014-06-27 12:48:01 +00:00
Evgeniy Stepanov 63338af398 [tsan] Disable a failing test.
java_finalizer is failing on all sanitizer bots since it was added in r211829.

llvm-svn: 211882
2014-06-27 08:10:27 +00:00
Evgeniy Stepanov 7d3c68a9cf [msan] Fix truncated stack trace in chained origin reports.
This is a leftover from the times when the next (chained) origin id
was stored as the last frame of a stack trace.

llvm-svn: 211878
2014-06-27 07:32:08 +00:00
Dmitry Vyukov fb251f51a9 tsan: add __tsan_java_finalize interface function
It is required to prevent false positives between object ctor and finalizer,
as otherwise they look completely unsynchronized.

llvm-svn: 211829
2014-06-27 00:47:38 +00:00
Alexander Potapenko b1b8231c8b [ASan] When iterating over segments on OSX, treat the segments' initial
protection level as their current protection level.
This fixes the UNIMPLEMENTED check that started to fire on OSX after r210649.

llvm-svn: 211713
2014-06-25 15:43:19 +00:00
Evgeniy Stepanov b163f0276f [msan] Fix bad interaction between with-calls mode and chained origin tracking.
Origin history should only be recorded for uninitialized values, because it is
meaningless otherwise. This change moves __msan_chain_origin to the runtime
library side and makes it conditional on the corresponding shadow value.

Previous code was correct, but _very_ inefficient.

llvm-svn: 211700
2014-06-25 14:41:57 +00:00
Evgeniy Stepanov 0b2d93c4f0 [sanitizer] Fix build on platforms where dtls support is disabled.
llvm-svn: 211684
2014-06-25 11:43:46 +00:00
Evgeniy Stepanov 7ad0bde843 [msan] Fix false positive on dynamic tls.
Use existing DTLS code in sanitizer_tls_get_addr.{h,cc} to unpoison DTLS
blocks both on allocation and deallocation.

https://code.google.com/p/memory-sanitizer/issues/detail?id=44

llvm-svn: 211683
2014-06-25 11:30:35 +00:00
Greg Fitzgerald 7c8bfd804b Remove ARM XFAIL from passing test
llvm-svn: 211608
2014-06-24 16:58:59 +00:00
Daniel Sanders 4dc8a78b04 [asan] adding support of 32-bit address sanitizer for MIPS
Summary: The patch supports both the clang cross-compiler and native compiler

Patch by Kumar Sukhani <Kumar.Sukhani@imgtec.com>

Test Plan:
Kumar had the following asan test results when compiled on a MIPS board:

  Expected Passes    : 96
  Expected Failures  : 2
  Unsupported Tests  : 84
  Unexpected Passes  : 4
  Unexpected Failures: 19

The list of unexpected failures can be found in the review.

Reviewers: kcc, petarj, dsanders

Reviewed By: kcc

Subscribers: farazs, kcc, llvm-commits

Differential Revision: http://reviews.llvm.org/D4208

llvm-svn: 211587
2014-06-24 12:08:18 +00:00
Evgeniy Stepanov 8717fec9af [msan] Fix origin copying.
Conditions for the first and the last origin value in range were wrong.

llvm-svn: 211585
2014-06-24 11:50:26 +00:00
Evgeniy Stepanov ad8065f01a [msan] Print stats even on successful run with atexit=1.
llvm-svn: 211574
2014-06-24 09:04:06 +00:00
Dmitry Vyukov 9eaae3d8f6 tsan: fix code formatting
llvm-svn: 211429
2014-06-21 02:10:17 +00:00
Saleem Abdulrasool d0d1638f96 builtins: assembly routines are not static
Storage Class 3 is static storage.  These symbols need to be marked as external
(storage class 2) so that they can be referenced.  Note that this external is
not the same as ELF "external" visibility, which is indicated by DLL Storage
Class (i.e. __declspec(dllexport) or __declspec(dllimport)).

llvm-svn: 211428
2014-06-21 01:41:21 +00:00
Dmitry Vyukov 0eb1c6f2fb tsan: fix windows build script
llvm-svn: 211422
2014-06-20 23:22:31 +00:00
Dmitry Vyukov 73e1804c21 tsan: add Go build script for freebsd
llvm-svn: 211419
2014-06-20 22:53:43 +00:00
Dmitry Vyukov b820599a3a tsan: port to freebsd
llvm-svn: 211418
2014-06-20 22:51:18 +00:00
Dmitry Vyukov f9c22916d5 tsan: fix freebsd build
freebsd does not have /proc/self/environ

llvm-svn: 211417
2014-06-20 22:49:41 +00:00
Dmitry Vyukov d84ce00f75 tsan: remove unused header include
llvm-svn: 211389
2014-06-20 18:56:11 +00:00
Dmitry Vyukov 5c4a3d3118 tsan: remove unused header include
llvm-svn: 211386
2014-06-20 18:30:06 +00:00
Dmitry Vyukov 3fc095e031 tsan: remove unused header include
llvm-svn: 211385
2014-06-20 18:28:34 +00:00
Kostya Serebryany cd60ed53f6 [asan] when reporting an ODR violation, also print the stack traces where the globals have been registered (thus show the name of shared library or exe to which the global belongs). The reports become a bit too verbose but I do not see any *simple* way to make them more compact. This should be especially helpful when the ODR happens because the same .cc file is used twice in the project in differend DSOs
llvm-svn: 211343
2014-06-20 08:24:12 +00:00
Joerg Sonnenberger 61d5d38e80 Provide mul for IEEE quad. From GuanHong Liu.
Differential Revision: http://reviews.llvm.org/D2799

llvm-svn: 211313
2014-06-19 20:34:03 +00:00
Joerg Sonnenberger 361519f409 Provide add and sub for IEEE quad. From GuanHong Liu.
Differential Revision: http://reviews.llvm.org/D2798

llvm-svn: 211312
2014-06-19 20:24:49 +00:00
Evgeniy Stepanov a2327c3a65 [sanitizer] Intercept pthread_*attr_get*.
This is a resubmit of r211166 reverted due to osx breakage.

llvm-svn: 211264
2014-06-19 10:19:57 +00:00
Arnold Schwaighofer 868050a667 Revert "[sanitizer] Intercept pthread_*attr_get*."
This reverts commit r211166. It broke public mac os x bots.

llvm-svn: 211206
2014-06-18 19:04:47 +00:00
Evgeniy Stepanov b87f1efc5f [sanitizer] Intercept pthread_*attr_get*.
llvm-svn: 211166
2014-06-18 14:16:41 +00:00
Evgeniy Stepanov 2c27df9a33 [msan] Intercept __getdelim.
llvm-svn: 211162
2014-06-18 13:35:13 +00:00
Evgeniy Stepanov 4ea1647e8b [msan] Handle X86 *.psad.* and *.pmadd.* intrinsics.
llvm-svn: 211156
2014-06-18 12:02:29 +00:00
Alexander Potapenko 853a232e66 [ASan] Fix https://code.google.com/p/address-sanitizer/issues/detail?id=321 for time() and frexp()
Add a test for the frexp() interceptor.
Annotate the interceptors that may potentially corrupt stack IDs of freed buffers with FIXME comments.

llvm-svn: 211153
2014-06-18 09:27:40 +00:00
Evgeniy Stepanov df187feae4 [msan] Fix handling of multiplication by a constant with a number of trailing zeroes.
Multiplication by an integer with a number of trailing zero bits leaves
the same number of lower bits of the result initialized to zero.
This change makes MSan take this into account in the case of multiplication by
a compile-time constant.

We don't handle the general, non-constant, case because
(a) it's not going to be cheap (computation-wise);
(b) multiplication by a partially uninitialized value in user code is
    a bad idea anyway.

Constant case must be handled because it appears from LLVM optimization of a
completely valid user code, as the test case in compiler-rt demonstrates.

llvm-svn: 211092
2014-06-17 09:23:12 +00:00
Saleem Abdulrasool 8f2efc3a91 builtins: add it blocks for Thumb-2
Add the missing IT-blocks for Thumb-2 compilation for code paths exercised by
older ARM CPUs.  This should fix the buildbots.

llvm-svn: 211035
2014-06-16 16:36:25 +00:00
Saleem Abdulrasool 1b8f1a4430 compiler-rt: prefer thumb over ARM
When possible, use Thumb or Thumb-2 over ARM instructions.  This is particularly
important for pure-Thumb environments (e.g. Windows on ARM).  Although, it is
possible to conditionalise this for that target specifically, this is available
on most newer ARM CPUs, and the code remains compatible with older CPUs with no
adverse effects.  It therefore feels better to always prefer Thumb when
possible.

llvm-svn: 211032
2014-06-16 16:05:24 +00:00
Dan Albert 1236ac388d Swap getdtablesize() for sysconf(_SC_OPEN_MAX).
Bionic is no removing this as it was removed from POSIX 2004.

llvm-svn: 211027
2014-06-16 14:51:11 +00:00
Sergey Matveev 998d991b2d [sanitizer] Support PTRACE_GETEVENTMSG in the ptrace() interceptor.
llvm-svn: 211022
2014-06-16 13:49:13 +00:00
Joerg Sonnenberger 739f4302b5 Add Guan-Hong Liu.
llvm-svn: 211009
2014-06-16 08:38:19 +00:00
Kostya Serebryany 9f5d48c0a0 [asan] initialze varaibles to avoid a (false positive) report from gcc's -Wmaybe-uninitialized
llvm-svn: 211008
2014-06-16 08:32:02 +00:00
Viktor Kutuzov 9101af0612 Fix building InstrProfilingFile.c on FreeBSD
llvm-svn: 210989
2014-06-15 14:01:18 +00:00
Viktor Kutuzov 1f386f0f36 Fix getting IP, BP and SP for address sanitizer's needs on FreeBSD in 32-bit mode
llvm-svn: 210988
2014-06-15 13:56:28 +00:00
Dan Albert 1c71fde161 Exclude Android from the tests for valloc/pvalloc.
These functions are being removed from Android because they were removed
from POSIX 2004.

llvm-svn: 210962
2014-06-14 00:50:03 +00:00
Alexey Samsonov e287ef847a [Sanitizer] Merge AnsiColorDecorator and SanitizerCommonDecorator, use the latter in UBSan
llvm-svn: 210959
2014-06-13 23:46:37 +00:00
Alexey Samsonov 3e61c52352 [UBSan] Respect runtime flag for colorizing reports
llvm-svn: 210950
2014-06-13 22:48:40 +00:00
Alexey Samsonov e595e1ade0 Remove top-level Clang -fsanitize= flags for optional ASan features.
Init-order and use-after-return modes can currently be enabled
by runtime flags. use-after-scope mode is not really working at the
moment.

The only problem I see is that users won't be able to disable extra
instrumentation for init-order and use-after-scope by a top-level Clang flag.
But this instrumentation was implicitly enabled for quite a while and
we didn't hear from users hurt by it.

llvm-svn: 210924
2014-06-13 17:53:44 +00:00
Evgeniy Stepanov dfa5439652 [asan] Fix mmap-ed coverage with coverage=0.
llvm-svn: 210655
2014-06-11 15:11:26 +00:00
Evgeniy Stepanov 9ae3d02193 [asan] Run Android test with asanwrapper.
This better replicates the target environment.

llvm-svn: 210650
2014-06-11 10:37:06 +00:00
Evgeniy Stepanov b2b4c3ab32 [asan] Exclude non-executable mappings from coverage.
llvm-svn: 210649
2014-06-11 10:11:51 +00:00
Evgeniy Stepanov 46fa9f2d9e [asan] One more coverage test.
Test that coverage is dumped correctly (and completely) even when the processed
gets SIGKILL-ed.

llvm-svn: 210647
2014-06-11 09:23:25 +00:00
Evgeniy Stepanov 125a302257 [asan] Fix coverage-android test to avoid name conflict.
And re-enable it.

llvm-svn: 210646
2014-06-11 09:09:09 +00:00
Alexander Potapenko 14f8ac04e3 Add detection of OS X relocatable SDK to compiler-rt as a lit.util function
Clang's lit cfg already detects the currently selected SDK via
"xcrun --show-sdk-path". The same thing should be done for compiler-rt tests,
to make them work on recent OS X versions. Instead of duplicating the detection
code, this patch extracts the detection function into a lit.util method.

Patch by Kuba Brecka (kuba.brecka@gmail.com),
reviewed at http://reviews.llvm.org/D4072

llvm-svn: 210534
2014-06-10 14:22:00 +00:00
Evgeniy Stepanov 9cc3ebdd3b [sanitizer] Relax sanity checks in ioctl decoding.
Standard KVM ioctls don't pass currect ioctl_decode().

llvm-svn: 210533
2014-06-10 13:54:15 +00:00
Evgeniy Stepanov 48eccb7fb3 [asan] Disable a flaky test.
llvm-svn: 210517
2014-06-10 08:32:01 +00:00
Alexey Samsonov f0d1fd6b32 [TSan] Exclude blacklist tests from manual test runner
llvm-svn: 210494
2014-06-09 22:02:14 +00:00
Evgeniy Stepanov b22b963669 [asan] Remove dependency of tests on runtime library in standalone build.
llvm-svn: 210465
2014-06-09 11:17:37 +00:00
Evgeniy Stepanov 9959915890 [msan] Intercept __strto*_internal.
This should fix strtoimax/strtoumax on newer glibc.
https://code.google.com/p/memory-sanitizer/issues/detail?id=36

llvm-svn: 210463
2014-06-09 10:41:22 +00:00
Evgeniy Stepanov 2be29929be Fix line numbers for code inlined from __nodebug__ functions.
Instructions from __nodebug__ functions don't have file:line
information even when inlined into no-nodebug functions. As a result,
intrinsics (SSE and other) from <*intrin.h> clang headers _never_
have file:line information.

With this change, an instruction without !dbg metadata gets one from
the call instruction when inlined.

Fixes PR19001.

llvm-svn: 210459
2014-06-09 09:09:19 +00:00
Evgeniy Stepanov 66c6a18d39 [msan] Add a test for mmx.packuswb.
llvm-svn: 210458
2014-06-09 08:58:41 +00:00
Evgeniy Stepanov aaaf74f9fb [msan] Simplify tests.
llvm-svn: 210457
2014-06-09 08:57:40 +00:00
Evgeniy Stepanov 63ece03c57 [asan] Add malloc_usable_size to android malloc dispatch.
llvm-svn: 210452
2014-06-09 08:36:14 +00:00
Alexey Samsonov 2c8dda4e53 [TSan] Make lit-tests more self-contained
llvm-svn: 210370
2014-06-06 21:04:55 +00:00
Dmitry Vyukov 9ff85e9674 tsan: fix argument passing in Go interface
Go calling convention does not support bools (it probably works, but uptrs are safer)

llvm-svn: 210365
2014-06-06 18:53:52 +00:00
Greg Fitzgerald e124a30fbe Un-xfail passing ARM Android tests
llvm-svn: 210360
2014-06-06 18:06:58 +00:00
Dmitry Vyukov 13793e5121 tsan: fix CurrentStackId
FuncEnter adds FuncEnter entry to trace that nobody removes later

llvm-svn: 210359
2014-06-06 18:05:12 +00:00
Dmitry Vyukov d858fa77d6 tsan: fix mutex in Go mode
In Go it's legal to unlock from a different goroutine.

llvm-svn: 210358
2014-06-06 18:04:05 +00:00
Dmitry Vyukov fc9b5d67a6 tsan: disable reporting of mutex misuses in Go
llvm-svn: 210353
2014-06-06 17:23:27 +00:00
Dmitry Vyukov 9546afec62 tsan: minor optimizations for Go runtime
llvm-svn: 210351
2014-06-06 16:06:19 +00:00
Dmitry Vyukov 75f5cf657e tsan: fix out-of-bounds access in Go runtime
FuncEntry can resize the shadow stack, while "thr->shadow_stack_pos[0] = pc" writes out-of-bounds.

llvm-svn: 210349
2014-06-06 15:56:08 +00:00
Dmitry Vyukov 32336152af tsan: fix mapping of meta shadow for Go
Go maps heap and data+bss, these regions are not adjacent.
data+bss is mapped first.

llvm-svn: 210348
2014-06-06 15:54:49 +00:00
Dmitry Vyukov ff194daead tsan: flush metamap per-thread cache when thread finishes
llvm-svn: 210347
2014-06-06 15:52:10 +00:00
Dmitry Vyukov feb4ede8ac tsan: fix clang warning:
comparison of unsigned expression >= 0 is always true

llvm-svn: 210346
2014-06-06 15:51:20 +00:00
Dmitry Vyukov 4f6de1d684 tsan: fix Go build with TSAN_COLLECT_STATS
Go does not have cur_thread function.

llvm-svn: 210345
2014-06-06 15:50:29 +00:00
Dmitry Vyukov 8744b1c1e3 tsan: allow to build Go runtime with clang + enable SSE3
llvm-svn: 210344
2014-06-06 15:49:49 +00:00
Evgeniy Stepanov ee98fb197b [msan] Fix wrong endianness when printing shadow.
llvm-svn: 210335
2014-06-06 14:06:14 +00:00
Evgeniy Stepanov 3e810b01c3 [msan] Partial revert of r210331.
Bots did not like it.

llvm-svn: 210332
2014-06-06 13:35:25 +00:00
Evgeniy Stepanov 9438bf1f62 [msan] Better diagnostic for invalid origin id.
llvm-svn: 210331
2014-06-06 12:58:44 +00:00
Dmitry Vyukov 909b7490a3 sanitizer: document missing macro
llvm-svn: 210329
2014-06-06 12:16:26 +00:00
Evgeniy Stepanov e5c34ace7f [asan] Make ReplaceSystemMalloc optional on Android.
Don't fail if __libc_malloc_dispatch is missing; continue running
with normal linux interceptors instead.

llvm-svn: 210322
2014-06-06 10:57:21 +00:00
Kostya Serebryany 558b3363a7 [asan] initialize fake_stack_ to 0 before we call SetThreadStackAndTls, because that may actually try to use fake_stack_ (still don't know how). Yet another case where we desperately want https://sourceware.org/glibc/wiki/ThreadPropertiesAPI
llvm-svn: 210315
2014-06-06 07:35:35 +00:00
Alexey Samsonov f251e0051c [TSan] Reduce the stack frame size of ReportDeadlock
llvm-svn: 210301
2014-06-05 23:24:46 +00:00