Commit Graph

4318 Commits

Author SHA1 Message Date
Timur Iskhodzhanov 7f29181323 [ASan tests] Exclude some tests from Windows runs
Some features are not supported yet and some are not planned to be fixed soon

llvm-svn: 209733
2014-05-28 13:06:14 +00:00
Evgeniy Stepanov 0651b561a6 [asan] Fix android test setup.
llvm-svn: 209724
2014-05-28 09:58:58 +00:00
Timur Iskhodzhanov a09b70579a [ASan tests] Move one more test to POSIX-only directory
llvm-svn: 209722
2014-05-28 09:38:51 +00:00
Timur Iskhodzhanov 82ee0433da [ASan/Win] Use clang rather than clang-cl by default for lit tests. Make Windows-only tests explicitly use clang-cl.
Reviewed at http://reviews.llvm.org/D3893

llvm-svn: 209719
2014-05-28 08:38:13 +00:00
Evgeniy Stepanov d74bdccafe [asan] Add a dll thunk for __sanitizer_cov_module_init.
llvm-svn: 209718
2014-05-28 08:34:53 +00:00
Evgeniy Stepanov a00ff194b7 [asan] Add a few stubs to fix windows build.
llvm-svn: 209717
2014-05-28 08:26:24 +00:00
Greg Fitzgerald 329912f54c [asan] use relative line numbers in tests
llvm-svn: 209699
2014-05-27 23:13:52 +00:00
Evgeniy Stepanov de9467593a [tsan] Fix tsango build.
llvm-svn: 209658
2014-05-27 14:18:43 +00:00
Evgeniy Stepanov 360c911872 [asan] Disable dlopen interceptor on Android.
It can not work, as libdl is always first in the lookup order,
even ahead of LD_PRELOAD-ed libraries.

llvm-svn: 209657
2014-05-27 14:14:03 +00:00
Evgeniy Stepanov 567e516015 [asancov] Write coverage directly to a memory-mapped file.
This way does not require a __sanitizer_cov_dump() call. That's
important on Android, where apps can be killed at arbitrary time.

We write raw PCs to disk instead of module offsets; we also write
memory layout to a separate file. This increases dump size by the
factor of 2 on 64-bit systems.

llvm-svn: 209653
2014-05-27 12:37:52 +00:00
Greg Fitzgerald 7b15cf8884 On AArch64, use clone() instead of fork()
Patch by Gideon Billings.

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

llvm-svn: 209641
2014-05-26 23:44:55 +00:00
Timur Iskhodzhanov d67df369cf [ASan tests] Use ASAN_OPTIONS in a portable way
llvm-svn: 209629
2014-05-26 13:44:57 +00:00
Sergey Matveev a531058d2b [MSan] Implement __sanitizer_print_stack_trace().
llvm-svn: 209625
2014-05-26 13:08:08 +00:00
Timur Iskhodzhanov 9011eb81cf [ASan/Win tests] Remove the extra 'cat' in front of FileCheck now that it's clear we should use GnuWin32 rather than Cygwin on the PATH on Windows (see PR19744)
llvm-svn: 209622
2014-05-26 11:54:20 +00:00
Timur Iskhodzhanov 5873419af7 [ASan/Win tests] Use the env keyword in the SUAR tests to work with gnuwin/lit correctly
llvm-svn: 209620
2014-05-26 11:25:32 +00:00
Sergey Matveev 2be4a28297 [sanitizer] Make stack traces from dlclose()'d modules more meaningful.
Previously, they silently omitted PCs belonging to unknown modules. Now we print
(<unknown module>) instead.

llvm-svn: 209522
2014-05-23 16:04:41 +00:00
Kostya Serebryany ef769fac90 [ubsan] temporary disable testing with -m32 as there are bots that don't support it
llvm-svn: 209517
2014-05-23 15:02:06 +00:00
Kostya Serebryany a72efdff9e [ubsan] handle long double in 32-bit mode; part of the patch by Marek Polacek
llvm-svn: 209516
2014-05-23 14:45:13 +00:00
Kostya Serebryany e1e9a4e2ec [asan] fix a test following r209508
llvm-svn: 209509
2014-05-23 11:52:38 +00:00
Alexey Samsonov 958a59b777 [TSan] ifdef out certain functions if 128-bit ints are not supported.
llvm-svn: 209476
2014-05-22 22:02:38 +00:00
Alexey Samsonov 00997e29e5 Unify the name of compiler-rt builtins library on Linux.
Call it "libclang_rt.builtins-<arch>.a" to be consistent
with sanitizers/profile libraries naming. Modify Makefile
and CMake build systems and Clang driver accordingly.

Fixes PR19822.

llvm-svn: 209473
2014-05-22 21:12:43 +00:00
Timur Iskhodzhanov d6ac15dd5f Quick-fix a copy-and-paste mistake in one of the ASan test
llvm-svn: 209448
2014-05-22 15:14:05 +00:00
Kostya Serebryany e31d5b6a2c [asan] relax the test for long double
llvm-svn: 209445
2014-05-22 14:50:14 +00:00
Timur Iskhodzhanov b2eb3131f4 [ASan/Win] Make sure the list of wrappers exported by the main module and imported by the DLL thunk always matches
llvm-svn: 209444
2014-05-22 14:49:56 +00:00
Timur Iskhodzhanov 8ff177ede3 [ASan/Win] Thread more library functions from the DLL thunk to the main module
llvm-svn: 209441
2014-05-22 13:57:22 +00:00
Timur Iskhodzhanov 498e56adb6 [ASan/Win] Add more tests for operator new[]
llvm-svn: 209439
2014-05-22 13:28:27 +00:00
Timur Iskhodzhanov 0c7c78f1d1 [ASan/Win] Use the new function interception approach to handle function wrappers too; wrap strlen() in DLLs
Reviewed at http://reviews.llvm.org/D3871

llvm-svn: 209427
2014-05-22 12:03:40 +00:00
Timur Iskhodzhanov 94ffc5bc12 [ASan/Win] Don't use INTERCEPTOR_ATTRIBUTE for operator new/delete on Windows
Reviewed at http://reviews.llvm.org/D3870

llvm-svn: 209416
2014-05-22 11:31:21 +00:00
Timur Iskhodzhanov 818b2e8f71 [ASan/Win] Add a comment about DCL-using-static vs threads
llvm-svn: 209414
2014-05-22 10:24:48 +00:00
Sergey Matveev 162d7cb9d1 [sanitizer] Attempt to fix test.
llvm-svn: 209301
2014-05-21 14:36:05 +00:00
Sergey Matveev 83f91e786c [sanitizer] Add __sanitizer_maybe_open_cov_file().
Summary: Add a new interface function required for coverage sandboxing support.
llvm-svn: 209298
2014-05-21 13:43:52 +00:00
Kostya Serebryany 301a38b0b7 [asan] add a test which ensures that we dump coverage after SEGV
llvm-svn: 209295
2014-05-21 13:20:14 +00:00
Dmitry Vyukov 96ebc5d7db tsan: deflake test
llvm-svn: 209290
2014-05-21 12:02:08 +00:00
Evgeniy Stepanov bce21acf25 [msan] Implement MSAN_OPTIONS=print_stats=1.
llvm-svn: 209287
2014-05-21 09:56:28 +00:00
Evgeniy Stepanov f77f2ece71 [tsan] Fix gotsan build.
llvm-svn: 209286
2014-05-21 09:42:56 +00:00
Evgeniy Stepanov 208aae8ee0 [msan] Chained origins re-design.
Generalize StackDepot and create a new specialized instance of it to
efficiently (i.e. without duplicating stack trace data) store the
origin history tree.

This reduces memory usage for chained origins roughly by an order of
magnitude.

Most importantly, this new design allows us to put two limits on
stored history data (exposed in MSAN_OPTIONS) that help avoid
exponential growth in used memory on certain workloads.

See comments in lib/msan/msan_origin.h for more details.

llvm-svn: 209284
2014-05-21 09:02:13 +00:00
Kostya Serebryany e88161626f [lsan] disable lsan if wordsize is not 64
llvm-svn: 209283
2014-05-21 08:30:18 +00:00
Evgeniy Stepanov 687933f55d [asan] Fix x86 asm instrumentation to preserve flags.
This change also enables asm instrumentation in asan tests that was
accidentally disabled yearlier, and adds a sanity test for that.

Patch by Yuri Gorshenin.

llvm-svn: 209282
2014-05-21 08:21:14 +00:00
Kostya Serebryany b9aa538db1 [sanitizer] fix linux_dirent for SANITIZER_X32; based on patch by H.J. Lu
llvm-svn: 209281
2014-05-21 08:21:13 +00:00
Kostya Serebryany b4e24fccd1 [sanitizer] define SANITIZER_X32 and use it in ThreadDescriptorSize; partially based on patch by H.J. Lu
llvm-svn: 209279
2014-05-21 08:01:44 +00:00
Kostya Serebryany 84019ff7e5 Cast pointers to uptr when calling internal_syscall
For Linux/x86-64, pointers passed to internal_syscall should be casted
to uptr first.  Otherwise, they won't be properly extended to 64-bit for
x32.
Patch by H.J. Lu

llvm-svn: 209278
2014-05-21 07:49:03 +00:00
Kostya Serebryany 6c9eacb384 Use 64-bit pointer to unwind stack for x86-64
X32 uses ILP32 data model in 64-bit hardware mode.  This patch always
uses 64-bit pointer to unwind stack for x86-64.
Patch by H.J. Lu

llvm-svn: 209277
2014-05-21 07:34:03 +00:00
Greg Fitzgerald 1733b5e263 XFAIL ptrace test on arm
The patch adds better target_triple and target_arch defaults for lit tests,
which allows us to XFAIL tests based on architecture.

Was:
  target_triple = LLVM_DEFAULT_TARGET_TRIPLE
  target_arch = HOST_ARCH

Now:
  target_triple = COMPILER_RT_TEST_TARGET_TRIPLE
                , otherwise LLVM_DEFAULT_TARGET_TRIPLE
  target_arch = first item in COMPILER_RT_TEST_TARGET_TRIPLE

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

llvm-svn: 209256
2014-05-20 23:31:26 +00:00
Greg Fitzgerald 38ff567743 [ubsan] fix vptr test on ARM
Differential Revision: http://reviews.llvm.org/D3751

llvm-svn: 209249
2014-05-20 22:07:58 +00:00
Greg Fitzgerald 40a6401b1f Run common and profile tests in cross-compiled builds.
Route target_cflags to common and profile tests

llvm-svn: 209248
2014-05-20 22:04:27 +00:00
Joerg Sonnenberger b1cc6d5603 Go via uintptr_t when casting away constness, otherwise GCC will warn
when using -Wcast-qual.

llvm-svn: 209214
2014-05-20 16:37:07 +00:00
Timur Iskhodzhanov e7894f3b14 [ASan Win] Simplify and improve the way we forward ASan interface calls from DLLs
Reviewed at http://reviews.llvm.org/D3848

llvm-svn: 209210
2014-05-20 14:26:19 +00:00
Sergey Matveev 6d8b9a747c [sanitizer] Fix go build following r209121.
llvm-svn: 209136
2014-05-19 16:08:53 +00:00
Joerg Sonnenberger 5c29582d53 Revert use of 128bit support on 32bit PPC, it breaks build at least with
GCC and that doesn't expose any *ti* functions either.

llvm-svn: 209133
2014-05-19 15:48:46 +00:00
Sergey Matveev 6cb47a083b [sanitizer] Support sandboxing in sanitizer coverage.
Summary:
Sandboxed code may now pass additional arguments to
__sanitizer_sandbox_on_notify() to force all coverage data to be dumped to a
single file (the default is one file per module). The user may supply a file or
socket to write to. The latter option can be used to broker out the file writing
functionality. If -1  is passed, we pre-open a file.

llvm-svn: 209121
2014-05-19 12:53:03 +00:00
Sergey Matveev 73f64a8f9f [asan] Make the coverage tests clean up after themselves.
llvm-svn: 209119
2014-05-19 11:34:35 +00:00
Kostya Serebryany 6c039b3459 [asan] update asan_symbolize.py to use the new llvm-symbolizer flag syntax
llvm-svn: 209116
2014-05-19 08:30:51 +00:00
Timur Iskhodzhanov 930ffe94aa [Sanitizer tests] Don't need to use -lstdc++ thanks to --driver-mode=g++
Reviewed at http://reviews.llvm.org/D3796

llvm-svn: 209115
2014-05-19 08:19:38 +00:00
Saleem Abdulrasool 44a8c7233a profile: explicitly initialize file name in the test
The instrprofile-write-file-only test was failing on the builtbots.  The runtime
library initialization is explicitly being discarded to avoid the atexit hook.
However, this would also prevent the filename from being initialized.  Thus,
when the write file was invoked, the filename would not be setup, and the test
would fail as the profiling data would never be written out.  Explicitly
initialize the filename to ensure that the data is written out when requested.
This should hopefully finally get the build bots all green again.

llvm-svn: 209099
2014-05-18 20:05:35 +00:00
Saleem Abdulrasool b2aa4726d2 profile: adjust flags for libdl
dlopen expects that the flags contains RTLD_LAZY or RTLD_NOW.  RTLD_LAZY will
resolve the symbol on first use, and is generally preferred due to efficiency.
Add this to fix the test failure on the build bots.

llvm-svn: 209098
2014-05-18 19:33:39 +00:00
Saleem Abdulrasool 1d338a3406 profile: add logging on failure
Add logging to report any failures that may occur on calls to libdl.  Without
this, it is difficult to identify the actual problem if the test fails.

llvm-svn: 209097
2014-05-18 19:33:37 +00:00
Saleem Abdulrasool 864e0740c0 profile: explicitly link against libdl
Add an explicit link against libdl.  libdl may not be indirectly pulled on some
Linux hosts.  Explicitly link against it.  This should hopefully improve the
state of the build bots.

llvm-svn: 209096
2014-05-18 18:39:19 +00:00
Saleem Abdulrasool dd9b0344cd assembly: support symbol definitions for COFF
Extend the function definition macros further to support COFF object emission.
The function definition in COFF includes the type and storage class in the
symbol definition context.  This is needed to make the assembly routines
possible to be built for COFF environments (i.e. Windows).

llvm-svn: 209095
2014-05-18 18:39:15 +00:00
Saleem Abdulrasool 9a614bd488 assembly: rework HIDDEN_DIRECTIVE to accomodate COFF
Rename the HIDDEN_DIRECTIVE macro to HIDDEN and give it a parameter providing
the name of the symbol to be given hidden visibility.  This makes the macros
more amenable to COFF.

llvm-svn: 209094
2014-05-18 18:39:10 +00:00
Duncan P. N. Exon Smith 55e4d66f0c InstrProf: Support profiling dlopen'd shared libraries
Shared objects are hard.  After this commit, we do the right thing when
profiling two separate shared objects that have been dlopen'd with
`RTLD_LOCAL`, when the main executable is *not* being profiled.

This mainly simplifies the writer logic.

  - At initialization, determine the output filename and truncate the
    file.  Depending on whether shared objects can see each other, this
    may happen multiple times.

  - At exit, each executable writes its own profile in append mode.

<rdar://problem/16918688>

llvm-svn: 209053
2014-05-17 01:27:30 +00:00
Alexey Samsonov 41c7302888 [TSan] Improve support for running TSan test suite with GCC-TSan.
Test results with GCC-4.9.0: 78 expected passes, 74 unexpected failures.

llvm-svn: 209014
2014-05-16 20:33:56 +00:00
Alexey Samsonov 995bdd43f8 Exclude several ASan tests from test suite if we're using GCC
llvm-svn: 209013
2014-05-16 20:12:27 +00:00
Alexey Samsonov 36132035ca [CMake] Don't build libcxx_tsan with compilers other than Clang
llvm-svn: 209003
2014-05-16 18:22:04 +00:00
Timur Iskhodzhanov 37c00b4b19 [ASan/Win] Refactor __interception::OverrideFunction a bit, allow the orig_old_func parameter to be zero
Reviewed at http://reviews.llvm.org/D3798

llvm-svn: 208989
2014-05-16 14:04:57 +00:00
Saleem Abdulrasool da2c2ce6ce clang-format assembly.h
Reformat assembly.h with clang-format.  NFC.

llvm-svn: 208950
2014-05-16 06:16:21 +00:00
Duncan P. N. Exon Smith 870b77cd4d InstrProf: Create a PIC version of the profile runtime
These tests were XPASS-ing on Linux bots creating Mach-O, which makes
sense, since the real difference is the object format.

I'm hoping a short-term fix to get these tests passing on ELF is to
create two copies of the runtime -- one built with -fPIC, and one
without.  A follow-up patch will change clang's driver to pick between
them depending on whether `-shared` is specified.

llvm-svn: 208947
2014-05-16 04:07:09 +00:00
Duncan P. N. Exon Smith f6366cbeff InstrProf: XFAIL tests from r208940 on Linux
According to the buildbots, the new features for shared objects don't
work on ELF since it requires an -fPIC when building the profile
library.  XFAIL these tests for now.

It's possible we'll have to build two versions of the profile library on
Linux (one with -fPIC and one without), but it's not clear to me exactly
how to resolve this.

llvm-svn: 208946
2014-05-16 02:53:19 +00:00
Duncan P. N. Exon Smith 084398857a InstrProf: Fix shared object profiling
Change the API of the instrumented profiling library to work with shared
objects.

  - Most things are now declared hidden, so that each executable gets
    its own copy.

  - Initialization hooks up a linked list of writers.

  - The raw format with shared objects that are profiled consists of a
    concatenated series of profiles.  llvm-profdata knows how to deal
    with that since r208938.

<rdar://problem/16918688>

llvm-svn: 208940
2014-05-16 01:30:24 +00:00
Greg Fitzgerald f42b49787b cleanup and test litlint
llvm-svn: 208907
2014-05-15 18:52:11 +00:00
Chandler Carruth 332e1b1909 Exclude MSVC to try to unbreak their builds. We have a bad skew between
how CMake drives a windows link and how our custom command does.

llvm-svn: 208903
2014-05-15 16:33:58 +00:00
Timur Iskhodzhanov bd6cee7cc3 [ASan/Win tests] Add memcpy/strdup/strlen interception tests
llvm-svn: 208899
2014-05-15 16:02:56 +00:00
Chandler Carruth 57e0ec7d20 Teach the compiler-rt custom compilation and linking CMake rules used
for sanitizers to pass the C++ compilation and exe linking flags through
from the host CMake configuration. We pass the target flags afterward,
allowing them to trump flags as needed. This is particularly important
when the flags direct Clang, even the just-built-Clang, toward the
standard library, linker, and other tools to use.

llvm-svn: 208896
2014-05-15 15:21:11 +00:00
Timur Iskhodzhanov 5910d6d126 [ASan/Win tests] Add more DLL tests
llvm-svn: 208893
2014-05-15 15:13:06 +00:00
Timur Iskhodzhanov e23889692b [ASan/Win tests] Add more DLL tests: malloc & friends
llvm-svn: 208889
2014-05-15 14:42:41 +00:00
Timur Iskhodzhanov 3bd2c2fe90 [ASan/Win tests] Add the first DLL test
llvm-svn: 208884
2014-05-15 14:27:46 +00:00
Timur Iskhodzhanov 130b5651d1 [ASan/Win tests] Add tests for malloc/calloc/realloc
llvm-svn: 208881
2014-05-15 13:50:12 +00:00
Dmitry Vyukov 547089e2a5 tsan: allow to disable history collection
The mode is enabled with -DTSAN_NO_HISTORY=1 flag.
Intended mostly for research purposes (how fast can it go w/o history).

llvm-svn: 208878
2014-05-15 12:51:48 +00:00
Timur Iskhodzhanov a357badc58 [ASan/Win tests] Add tests for stack array manipulation, as well as a use-after-return test
llvm-svn: 208873
2014-05-15 12:09:45 +00:00
Timur Iskhodzhanov 2dbedf5e93 [ASan/Win tests] Add tests for operator new/new[]/delete/delete[]
llvm-svn: 208871
2014-05-15 11:55:40 +00:00
Timur Iskhodzhanov dd2d84a223 [ASan/Win tests] Add tests for downcast-related overflows, as well as CRT initiazliers
llvm-svn: 208865
2014-05-15 11:14:00 +00:00
Timur Iskhodzhanov f32b690f69 [ASan/Win tests] Add tests for aligned mallocs, bitfields and global strings
llvm-svn: 208859
2014-05-15 10:58:35 +00:00
Timur Iskhodzhanov 8bf36cae28 [ASan tests] Add ASan Windows threading tests
llvm-svn: 208854
2014-05-15 09:12:55 +00:00
Evgeniy Stepanov f532c5bfd5 [sanitizer] Remove the definition of xdr_ops.
User-visible instances of xdr_ops always seem to be allocated statically, and
don't need unpoisoning. Also, it's size differs between platforms.

llvm-svn: 208851
2014-05-15 07:18:34 +00:00
Alp Toker 1ee7fc7a1a Fix typos
llvm-svn: 208841
2014-05-15 02:22:34 +00:00
Greg Fitzgerald ceae1fbafd migrate litlint from argparse to optparse. reenabled
llvm-svn: 208826
2014-05-14 23:31:20 +00:00
Greg Fitzgerald 73bd03cee9 Disabled litlint. It requires Python 2.7 or later
llvm-svn: 208823
2014-05-14 23:20:30 +00:00
Greg Fitzgerald a310d98ff1 add script to ensure lit test contains %run
llvm-svn: 208819
2014-05-14 22:49:46 +00:00
Timur Iskhodzhanov 07109b4161 [ASan/Win tests] Add a PR reference for the FileCheck bug
llvm-svn: 208807
2014-05-14 19:47:58 +00:00
Timur Iskhodzhanov 78dccb0822 Remove an unneeded stderr redirection
llvm-svn: 208805
2014-05-14 19:34:13 +00:00
Timur Iskhodzhanov 3653790410 Remove --check-prefix=CHECK as it's useless
llvm-svn: 208803
2014-05-14 19:31:56 +00:00
Timur Iskhodzhanov 2bdca20069 [ASan tests] Add the first Windows-only lit test
Reviewed at http://reviews.llvm.org/D3767

llvm-svn: 208802
2014-05-14 19:10:43 +00:00
Timur Iskhodzhanov 9de6fe7b83 [ASan tests] Get rid of SharedLibs/
llvm-svn: 208780
2014-05-14 14:41:38 +00:00
Timur Iskhodzhanov b2e723e448 [ASan tests] Update relative paths from POSIX-only tests to their shared libraries
llvm-svn: 208778
2014-05-14 14:16:09 +00:00
Timur Iskhodzhanov 6a9121904d [ASan tests] Create a Posix/ directory for tests that we don't plan to run on Windows
llvm-svn: 208777
2014-05-14 14:12:02 +00:00
Kostya Serebryany b9e31d7fcd [asan] use some LIKELY/UNLIKELY
llvm-svn: 208776
2014-05-14 14:03:31 +00:00
Timur Iskhodzhanov 86e2470a5b [ASan/Win] Enable demangling of global variable names
llvm-svn: 208775
2014-05-14 13:55:59 +00:00
Evgeniy Stepanov 99d3791a88 [sanitizer] Fix crash in getgrnam_r and similar interceptors.
When no matching record is found, getgrnam_r return 0 but sets result to NULL.
Should fix PR19734.

llvm-svn: 208773
2014-05-14 12:32:40 +00:00
Alexander Potapenko 04e2f43756 [libsanitizer] Notify the runtime about file being closed before the actual call to fclose().
This shall fix spurious false positive race reports between fclose() and fopen64().

llvm-svn: 208772
2014-05-14 11:48:37 +00:00
Kostya Serebryany d5e1091c73 [asan] tyring to fix the Android build
llvm-svn: 208763
2014-05-14 09:21:22 +00:00
Kostya Serebryany 7534a60753 [asan] Respect personality in kernel area detector, patch by Yuri Gribov
llvm-svn: 208760
2014-05-14 08:13:11 +00:00
Evgeniy Stepanov adc3ff9f48 [sanitizer] Move open_memstream test under Linux.
llvm-svn: 208755
2014-05-14 07:27:18 +00:00
Greg Fitzgerald 5a1cf70ac3 removed redundant lit variable
Thanks Alexey!

llvm-svn: 208747
2014-05-14 01:04:17 +00:00
Greg Fitzgerald 320713ffbe Add target flags to ubsan tests
llvm-svn: 208746
2014-05-14 00:46:01 +00:00
Greg Fitzgerald 07c88a16e8 Enable CAN_EXECUTE_TESTS if an EMULATOR is provided
llvm-svn: 208745
2014-05-14 00:36:15 +00:00
Greg Fitzgerald 1402830dc5 Add %run to tests that used %T/name.exe
llvm-svn: 208744
2014-05-14 00:32:15 +00:00
Alexey Samsonov 5716928ae2 [TSan] Build TSan-instrumented version of libcxx and use it in lit tests.
TSan can produce false positives in code that uses C++11 threading,
as it doesn't see synchronization inside standard library. See
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-February/035408.html
for an example of such case.

We may build custom TSan-instrumented version libcxx to fight with that.
This change adds build rules for libcxx_tsan and integrates it into
testing infrastructure.

llvm-svn: 208737
2014-05-13 22:30:16 +00:00
Alexander Potapenko 291b827890 [libsanitizer] Fix the return type of internal_fork
llvm-svn: 208714
2014-05-13 17:31:09 +00:00
Alexander Potapenko 4a6cac4382 [libsanitizer] Use internal_fork() to spawn the symbolizer process.
This should fix https://code.google.com/p/thread-sanitizer/issues/detail?id=61

llvm-svn: 208707
2014-05-13 16:17:54 +00:00
Timur Iskhodzhanov b9bd76b85d Enable sanitizer tests (check-sanitizer, check-asan) on Windows
llvm-svn: 208701
2014-05-13 14:25:49 +00:00
Timur Iskhodzhanov 5ce3937ed4 [Sanitizer tests] Define 16- and 64-bit versions of atomic_compare_exchange_strong on Windows
Reviewed at http://reviews.llvm.org/D3745

llvm-svn: 208700
2014-05-13 14:23:25 +00:00
Timur Iskhodzhanov 5812350591 [Sanitizer tests] Exclude three tests that fail on Windows
llvm-svn: 208698
2014-05-13 13:34:00 +00:00
Timur Iskhodzhanov e33158bcd1 [Sanitizer tests] Land the sanitizer twin of the asan-only change r208682
llvm-svn: 208697
2014-05-13 13:29:11 +00:00
Timur Iskhodzhanov 339e8c98f8 [Sanitizer tests] Add sanitizer_test_config.h to make the inclusion of gtest.h conditional
Reviewed at http://reviews.llvm.org/D3744

llvm-svn: 208696
2014-05-13 13:25:12 +00:00
Timur Iskhodzhanov 2e9136c2da [Sanitizer/ASan tests] Automatically detect the presence of libstdc++
llvm-svn: 208695
2014-05-13 12:57:50 +00:00
Evgeniy Stepanov 68d7f43e38 [sanitizer] Disable fopen64 interceptor on osx.
llvm-svn: 208693
2014-05-13 12:05:38 +00:00
Timur Iskhodzhanov e5e92fac4a [Sanitizer tests] Fix most of the build problems on Windows
E.g. use the pthread helpers introduced in r208674

llvm-svn: 208692
2014-05-13 12:02:53 +00:00
Evgeniy Stepanov 7bd7063db0 [sanitizer] Mark several functions as possibly unused.
llvm-svn: 208686
2014-05-13 11:18:22 +00:00
Timur Iskhodzhanov 7d07fe20a0 [ASan tests] Add Windows-specific flags to lib/asan/tests/CMakeLists.txt
Reviewed at http://reviews.llvm.org/D3720

llvm-svn: 208682
2014-05-13 10:33:42 +00:00
Evgeniy Stepanov 4d16c1df0c [sanitizer] Delete an unused function.
llvm-svn: 208678
2014-05-13 09:03:45 +00:00
Evgeniy Stepanov 6b21d560c9 [sanitizer] Fix windows build.
llvm-svn: 208677
2014-05-13 08:47:40 +00:00
Evgeniy Stepanov 5680a26b0b [msan] Better open_memstream support.
Move fflush and fclose interceptors to sanitizer_common.
Use a metadata map to keep information about the external locations
that must be updated when the file is written to.

llvm-svn: 208676
2014-05-13 08:36:31 +00:00
Timur Iskhodzhanov 711269966c [Sanitizer tests] Make simple pthread tests compile and pass on Windows
Reviewed at http://reviews.llvm.org/D3725

llvm-svn: 208674
2014-05-13 08:07:09 +00:00
Kostya Serebryany 0d00675df2 [sanitizer] fix for ARM Linux, patch by Maxim Ostapenko
llvm-svn: 208673
2014-05-13 08:01:59 +00:00
Kostya Serebryany b7a7e55dc5 [sanitizer] define __sanitizer_time_t
llvm-svn: 208671
2014-05-13 07:49:39 +00:00
Alexey Samsonov 79b8fb5d2c Mark ptrace test as Linux-specific
llvm-svn: 208643
2014-05-13 00:02:18 +00:00
Alexey Samsonov b51d6081f3 Restrict the set of sanitizers that should run tests from test/sanitizer_common
llvm-svn: 208639
2014-05-12 22:48:29 +00:00
Alexey Samsonov 5af5f8f0b5 [CMake] Log output of configure/build/install steps for instrumented libcxx to reduce noise
llvm-svn: 208632
2014-05-12 21:07:28 +00:00
Alexey Samsonov 53363b53db [CMake] Fix standalone build after r208526
llvm-svn: 208629
2014-05-12 20:48:29 +00:00
Greg Fitzgerald fb1d83a978 Add %run to new lit test
llvm-svn: 208624
2014-05-12 20:17:14 +00:00
Alexey Samsonov 1866b58885 [ASan] Split static ASan runtime in two parts: asan and asan_cxx.
asan_cxx containts replacements for new/delete operators, and should
only be linked in C++ mode. We plan to start building this part
with exception support to make new more standard-compliant.

See https://code.google.com/p/address-sanitizer/issues/detail?id=295
for more details.

llvm-svn: 208609
2014-05-12 18:39:22 +00:00
Jonathan Roelofs b351c1aba2 Move .subsections_via_symbols directives into DEFINE_COMPILERRT_PRIVATE_FUNCTION
llvm-svn: 208603
2014-05-12 17:38:36 +00:00
Timur Iskhodzhanov 1ac44dd087 [Sanitizer tests] Fix a comment that got out of sync with the #if
llvm-svn: 208602
2014-05-12 17:33:00 +00:00
Saleem Abdulrasool a374f43ec8 builtins: add missing file
Add (missing) definition of COMPILER_RT_EXPORT which is meant to be used for
decorating functions that are meant to be exported.  This is useful for
platforms where exports and imports must be decorated explicitly (i.e. Windows).

llvm-svn: 208593
2014-05-12 16:47:01 +00:00
Saleem Abdulrasool c17450236e __clear_cache: decorate with COMPILER_RT_EXPORT
Use COMPILER_RT_EXPORT rather than COMPILER_RT_ABI for this function.  Adding an
explicit PCS standard to the function causes a mismatch between the
declarations.  Furthermore, the function is implemented in C, and should take
the CC based on the target triple.

llvm-svn: 208591
2014-05-12 16:28:11 +00:00
Saleem Abdulrasool 2e3ad036a2 CompilerRT: .align was supposed to be power-of-aligned in this case
Use .balign instead of .p2align 3.  This should fix the buildbots.

llvm-svn: 208585
2014-05-12 16:06:11 +00:00
Saleem Abdulrasool 310874ae3c [CompilerRT] use .p2align, .balign instead of .align
The .align statements in ARM assembly routines is actually meant to be a power
of 2 alignment (e.g. .align 2 == 4 byte alignment, not 2).  Switch to using
.p2align.  .p2align is guaranteed to be a power-of-two alignment always and much
more explicit.

The .align in the case of x86_64 is byte alignment, use .balign instead of
.align.

llvm-svn: 208578
2014-05-12 15:23:37 +00:00
Timur Iskhodzhanov a9e9e9d640 [ASan tests] Don't define __asan_default_options in tests on Windows as it is not supported
llvm-svn: 208575
2014-05-12 15:12:44 +00:00
Timur Iskhodzhanov 90278c626f [ASan] Add references to the issue tracker about malloc/free/new/delete mismatch check on Mac and Windows
llvm-svn: 208574
2014-05-12 15:06:59 +00:00
Timur Iskhodzhanov d5d5f6a8b9 [ASan tests] Exclude/simplify a bunch of tests to make them build on Windows
(This also requires D3720, D3725 and a few more small changes to land)

llvm-svn: 208573
2014-05-12 15:04:25 +00:00
Timur Iskhodzhanov 9bd988b33b [ASan tests] Don't run FakeStack.CreateDestroy on Windows as it OOMs
llvm-svn: 208572
2014-05-12 14:49:17 +00:00
Timur Iskhodzhanov 36fc9b18b7 [ASan tests] Also define USED/UNUSED in lib/sanitizer_common/sanitizer_internal_defs.h if Clang is used on Windows
Otherwise we end up with macro redefinition warnings

llvm-svn: 208571
2014-05-12 14:44:29 +00:00
Timur Iskhodzhanov 9a205ed8ee [ASan tests] Use the proper attribute on RunStrChrTest helper functions to avoid "unused function" warnings
llvm-svn: 208568
2014-05-12 14:31:57 +00:00
Sergey Matveev f37bd92c3a [asan] Move the "coverage" flag to common flags.
The implementation lives in sanitizer_common and will need to access that flag.

llvm-svn: 208566
2014-05-12 14:27:36 +00:00
Hal Finkel 10c6c06656 Define CRT_HAS_128BIT even for PPC32
r201909, which introduced CRT_HAS_128BIT, unintentionally broke self-hosting on
PPC32. We used to define CRT_HAS_128BIT only on LP64 systems, but this is not
quite right (at least for Clang-compiled code). Even though __int128 is not
supported on PPC32, SROA can (and does) still form i128 variables at the IR
level, and operations on those variables may turn into the associated runtime
calls. As a result, we still need to compile __ashlti3, __ashrti3, __lshrti3,
and perhaps others, on PPC32.

llvm-svn: 208560
2014-05-12 13:43:29 +00:00
Kostya Serebryany 118d469660 [asan] one more attempt to enable lsan by default (PR19521)
llvm-svn: 208545
2014-05-12 12:49:48 +00:00
Viktor Kutuzov 626edb6f49 Add FreeBSD support to address sanitizer process mapping facilities
llvm-svn: 208537
2014-05-12 11:03:46 +00:00
Kostya Serebryany e61f4d5155 [tsan] force tls_model='initial-exec' for tsan's cur_thread_placeholder so that we don't depend on the compiler flags
llvm-svn: 208536
2014-05-12 10:40:33 +00:00
Sergey Matveev aeb18fc787 [asan] Further fix the test from r208333.
Remove a debug print and some copypasta.

llvm-svn: 208535
2014-05-12 10:33:31 +00:00
Kostya Serebryany 9c81b31568 [asan] define ASAN_DYNAMIC=1 if PIC is defined
llvm-svn: 208530
2014-05-12 09:45:39 +00:00
Timur Iskhodzhanov b0279d7f7d [ASan tests] Use clang-cl to build tests on Windows
Reviewed at http://reviews.llvm.org/D3680

llvm-svn: 208526
2014-05-12 08:55:20 +00:00
Kostya Serebryany d7992fc921 [asan] fix a self deadlock when printing stats; add a relevant test, cleanup that test while at it to remove linux/darwin differences. Fixes http://code.google.com/p/address-sanitizer/issues/detail?id=306
llvm-svn: 208525
2014-05-12 08:01:51 +00:00
Duncan P. N. Exon Smith 59ad79601b InstrProf: Remove redundant declaration
llvm-svn: 208464
2014-05-10 00:22:58 +00:00
Duncan P. N. Exon Smith b6bd2f6cf7 InstrProf: Pacify buildbots after r208460
llvm-svn: 208462
2014-05-09 23:47:49 +00:00
Duncan P. N. Exon Smith 238137294f InstrProf: Test the functions in the runtime
Check that the profile runtime works as expected.  This tests the
functions that are meant to be available to advanced users.

In particular, check that the `atexit()` hook can be disabled by
defining a custom `__llvm_profile_runtime` variable, that the libc
dependencies are optional, and that the various functions for writing
out files work for basic cases.

llvm-svn: 208460
2014-05-09 23:14:58 +00:00
Alexey Samsonov eacb4d8417 [CMake] Use ExternalProject to build MSan-ified version of libcxx for unit tests.
This change lets MSan rely on libcxx's own build system instead of manually
compiling its sources and setting up all the necessary compile flags. It would
also simplify compiling libcxx with another sanitizers (in particular, TSan).

The tricky part is to make sure libcxx is reconfigured/rebuilt when Clang or
MSan runtime library is changed. "clobber" step used in this patch works well
for me, but it's possible it would break for other configurations - will
watch the buildbots.

llvm-svn: 208451
2014-05-09 22:11:03 +00:00
Alexey Samsonov 0bef819f9f [Sanitizer] Add the machinery to run the same test under several sanitizers
llvm-svn: 208378
2014-05-09 00:28:18 +00:00
Alexey Samsonov 6dd8dfb1c4 [Sanitizer] Move lit config for sanitizer_common unit tests under Unit/ dir for consistency.
llvm-svn: 208373
2014-05-08 23:53:02 +00:00
Alexey Samsonov 35744c4753 Fixup for r208066. Properly get values of PTRACE_GETREGSET/PTRACE_SETREGSET.
llvm-svn: 208363
2014-05-08 22:11:20 +00:00
Alexey Samsonov 0b9b36623a Fixup test added in r208333
llvm-svn: 208356
2014-05-08 20:21:11 +00:00
Sergey Matveev 76e02e90c5 [ASan] Fix coverage behavior when a PC belongs to an unknown address range.
This happens, e.g., when coverage data is collected for a module which is then
dlclose()'d. Currently this causes CovDump() to ignore all PCs that are greater
than the unrecognized PC. In other words, unloading a module causes ASan to
silently ignore any coverage data for modules loaded at higher addresses.
Instead we should just skip the unrecognized PCs.

llvm-svn: 208333
2014-05-08 16:09:54 +00:00
Timur Iskhodzhanov e153347cc5 [ASan tests] Fix non-Windows breakage
llvm-svn: 208332
2014-05-08 15:59:35 +00:00
Timur Iskhodzhanov 21a22d34be [ASan tests] More progress towards Windows support
llvm-svn: 208326
2014-05-08 15:13:26 +00:00
Timur Iskhodzhanov 48253ed689 [ASan tests] More progress towards Windows support
llvm-svn: 208325
2014-05-08 15:05:42 +00:00
Timur Iskhodzhanov 498052b8eb [ASan tests] More progress towards Windows support
llvm-svn: 208323
2014-05-08 15:01:29 +00:00
Timur Iskhodzhanov fddadefc33 [ASan tests] Auto-define ASAN_NEEDS_SEGV rather than hardcode it in cmake
llvm-svn: 208322
2014-05-08 14:53:59 +00:00
Timur Iskhodzhanov 76f43eecb0 [ASan] Update sanitizer_common and asan test_util headers to support building on Windows
llvm-svn: 208306
2014-05-08 12:43:33 +00:00
Evgeniy Stepanov c5e51926dc [msan] Intercept strxfrm.
llvm-svn: 208303
2014-05-08 12:04:01 +00:00
Evgeniy Stepanov ac030ffb69 [msan] Switch to common printf interceptors.
Format string parsing is disabled by default.
This is not expected to meaningfully change the tool behavior.
With this change, check_printf flag could be used to evaluate printf format
string parsing in MSan.

llvm-svn: 208295
2014-05-08 09:50:59 +00:00
Evgeniy Stepanov 9c20cb1a7c [msan] Fix potential infinite recursion in a test.
If printf is intercepted (it is not atm), REAL(printf) call in the interceptor
would get redirected back to my_lgamma, resulting in infinite recursion.

llvm-svn: 208294
2014-05-08 09:37:36 +00:00
Evgeniy Stepanov 5ee9fd5f45 [asan] Update tests for r208290.
sprintf output buffer is now always sanitized.

llvm-svn: 208291
2014-05-08 09:24:53 +00:00
Evgeniy Stepanov d31ac26230 [sanitizer] Unconditionally write to target buffer in *sprintf interceptors.
This does not change the default behavior (check_printf in on by default in all tools).
With this change, check_printf flag only affects format string parsing.

llvm-svn: 208290
2014-05-08 09:18:22 +00:00
Alexey Samsonov 9c1a57b64f [DFSan] Update build rules for Makefile build
llvm-svn: 208268
2014-05-07 23:48:59 +00:00
Alexey Samsonov 2fccdfbe70 [MSan] Fixup for r206983: MsanThread may be unavailable in signal handler: signals may be raised while thread is being destroyed
llvm-svn: 208250
2014-05-07 21:23:12 +00:00
Greg Fitzgerald dda7f8cfd0 [asan] fix i386 tests broken from r207707
llvm-svn: 208240
2014-05-07 19:22:16 +00:00
Timur Iskhodzhanov 6d58e0726d Ignore stack-buffer-overflow in std::_Find_elem<*> / std::num_get<...>::_Getifld
Reviewed at http://reviews.llvm.org/D3650

llvm-svn: 208215
2014-05-07 14:40:23 +00:00
Evgeniy Stepanov 7d46040ff2 [sanitizer] Replace a macro with a function.
llvm-svn: 208207
2014-05-07 13:24:28 +00:00
Evgeniy Stepanov 55590227f8 [sanitizer] Intercept obstack.
llvm-svn: 208196
2014-05-07 11:50:56 +00:00
Evgeniy Stepanov 8dd62dc3be [msan] Fix __msan_check_mem_is_initialized and prettify its output.
llvm-svn: 208195
2014-05-07 11:50:14 +00:00
Evgeniy Stepanov c087df0655 [asan] Include asm instrumentation source in Makefile build.
llvm-svn: 208172
2014-05-07 08:55:46 +00:00
Kostya Serebryany 7a733480c8 [asan] introduce interface function __sanitizer_verify_contiguous_container to verify annotations in vector-like containers
llvm-svn: 208092
2014-05-06 14:41:01 +00:00
Evgeniy Stepanov aa44aaee90 [sanitizer] Print addresses in hexadecimal.
llvm-svn: 208089
2014-05-06 14:01:13 +00:00
Timur Iskhodzhanov 7d5c81db0a [ASan/Win] Don't crash when ASAN_OPTIONS have disable_core=1
Reviewed at http://reviews.llvm.org/D3610

llvm-svn: 208070
2014-05-06 08:21:50 +00:00
Evgeniy Stepanov 06475bf752 [msan] Fix print_shadow test.
llvm-svn: 208069
2014-05-06 08:15:50 +00:00
Kostya Serebryany 98e55ef41a [sanitizer] fix build with glibc 2.4, patch by Sandra Loosemore
llvm-svn: 208066
2014-05-06 07:36:51 +00:00
Timur Iskhodzhanov 7721eb3f9d [ASan/Win] Add DLL thunks for the fake stack interface
llvm-svn: 207960
2014-05-05 12:26:04 +00:00
Dmitry Vyukov 3089608172 tsan: disable debug output in normal mode
llvm-svn: 207954
2014-05-05 07:45:54 +00:00
Reid Kleckner af6b2504f8 profile: Fix the build with gcc 4.9
GCC -pedantic warns that the initialization of Header is not constant:
InstrProfilingFile.c:31:5: error: initializer element is not computable at load time [-Werror]

LLVM defaults to enabling -pedantic.  If this warning is unhelpful, we
can consider revisiting that decision.

llvm-svn: 207784
2014-05-01 18:52:14 +00:00
Kostya Serebryany 12963b54a8 [asan] disable GetKernelStartAddress as it misbehaves in schroot
llvm-svn: 207768
2014-05-01 16:20:23 +00:00
Chandler Carruth c42ddde78a The newest versions of CMake require outputs of custom commands be in
DEPENDS rather than SOURCES. The SOURCES just end up looking on the
filesystem and not finding anything. Makes for very hard to debug build
errors. =/

llvm-svn: 207722
2014-04-30 23:31:45 +00:00
Greg Fitzgerald b8aae5405b Add %run to all lit tests
llvm-svn: 207709
2014-04-30 21:34:17 +00:00
Greg Fitzgerald 6759fd9fdd Allow any test to be executed via a %run command.
Configure %run with COMPILER_RT_EMULATOR:

  $ cmake -DCOMPILER_RT_EMULATOR="qemu-arm -L $SYSROOT"

llvm-svn: 207707
2014-04-30 21:32:30 +00:00
Kostya Serebryany 8b530e10a1 [asan] make AsanCoverage lock-free (and AS-safe)
llvm-svn: 207630
2014-04-30 10:40:48 +00:00
Evgeniy Stepanov fe250b0014 [msan] Prettify __msan_print_shadow.
Makes __msan_print_shadow output much more readable, adds origin info.

llvm-svn: 207622
2014-04-30 09:50:30 +00:00
Alexey Samsonov d94e87db3f [Sanitizer] Add rudimentary support for wide-character strings to scanf/printf interceptors
llvm-svn: 207443
2014-04-28 20:40:25 +00:00
Kostya Serebryany cacbac7ba9 [asan] fix a test
llvm-svn: 207417
2014-04-28 13:18:59 +00:00
Kostya Serebryany 4f9c31a2fa [asan] split detect_odr_violation into two: =2 detects all ODR violations, =1 detects only those where the variable sizes are different. BTW, the detector seems to be working well and finding nice bugs. Early adopters are welcome.
llvm-svn: 207415
2014-04-28 12:47:58 +00:00
Viktor Kutuzov f9eba2f51d Fix building Asan and common sanitizers tests on FreeBSD 9.2
llvm-svn: 207408
2014-04-28 10:33:01 +00:00
Evgeniy Stepanov c435fb07dd [sanitizer] Limit fopen interceptor to linux.
llvm-svn: 207227
2014-04-25 13:55:29 +00:00
Evgeniy Stepanov f3d5d119a8 [sanitizer] Intercept a bunch of stdio calls.
Add move fopen/freopen interceptors from TSan to common.

llvm-svn: 207224
2014-04-25 13:26:21 +00:00
Alexander Potapenko 623c989eea [ASan] Use a non-null altstack.ss_size when disabling sigaltstack on Darwin.
llvm-svn: 207220
2014-04-25 10:39:41 +00:00