Commit Graph

1483 Commits

Author SHA1 Message Date
Vedant Kumar a06e8ca6c5 [profile] Support hostname expansion in LLVM_PROFILE_FILE
This patch adds support for expanding "%h" out to the machine hostname
in the LLVM_PROFILE_FILE environment variable.

Patch by Daniel Waters!

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

llvm-svn: 259272
2016-01-29 23:52:11 +00:00
Evgeniy Stepanov 3cf771e367 [cfi] Get rid of a fixed size buffer for the library path in test.
llvm-svn: 259082
2016-01-28 19:37:03 +00:00
Mike Aizatsky 343322bb93 putting requires on one line - ppc still executes my tests.
llvm-svn: 259012
2016-01-28 02:24:35 +00:00
Evgeniy Stepanov 4a09234cb7 [cfi] Fix recovery from out-of-bounds vtable error.
llvm-svn: 259007
2016-01-28 00:37:54 +00:00
Mike Aizatsky b4c48d1e15 [sancov] run sancov test on x86_64 linux only
llvm-svn: 259006
2016-01-28 00:35:17 +00:00
Mike Aizatsky ecaeb1d93b [sancov] running sancov test on linux only
llvm-svn: 259004
2016-01-28 00:27:13 +00:00
Mike Aizatsky 2654299d6a [sanitizers] generating html report on coverage dump
Subscribers: tberghammer, danalbert, srhines

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

llvm-svn: 258999
2016-01-27 23:51:36 +00:00
Evgeniy Stepanov e7f8b23716 [cfi] Fix a warning in tests.
test/cfi/cross-dso/dlopen.cpp:67:45: warning: GCC does not allow 'aligned' attribute in this position on a function definition [-Wgcc-compat]
extern "C" void do_nothing() __attribute__((aligned(4096))) {}

llvm-svn: 258992
2016-01-27 21:49:03 +00:00
Alexey Samsonov d9272422a2 [CMake] Set llvm_tools_dir to LLVM_TOOLS_BINARY_DIR instead of LLVM_TOOLS_DIR
In this way, it should work for both in-LLVM and standalone
compiler-rt build.

llvm-svn: 258991
2016-01-27 21:36:38 +00:00
Evgeniy Stepanov 7cced3ba82 [cfi] Disable vtable diagnostics when no cxxabi.
This should fix the build on Mac 10.8 and earlier.

llvm-svn: 258988
2016-01-27 21:15:10 +00:00
Xinliang David Li 0747c5c808 Fix a bug in test case (both ir,fe instr were turned on
llvm-svn: 258913
2016-01-27 07:42:41 +00:00
Evgeniy Stepanov 40d7d02d3d [cfi] Better handling of wild target address.
This change enables diagnostics when the target address for a CFI
check is out of bounds of any known library, or even not in the
limits of the address space. This happens when casting pointers to
uninitialized memory.

Ubsan code does not yet handle some of these situations correctly,
so it is still possible to see a segmentation fault instead of a
proper diagnostic message once in a while.

llvm-svn: 258879
2016-01-26 23:36:28 +00:00
Evgeniy Stepanov 79685810f1 [cfi] Hide runtime implementation in a namespace.
Move all internal stuff into namespace __cfi.
Remove the double underscore prefix from anything that's now inside
the namespace.

llvm-svn: 258859
2016-01-26 21:06:26 +00:00
Evgeniy Stepanov a9e0584cce [cfi] Support for dlopen and dlclose.
Add dlopen/dlclose interceptors to update CFI shadow for loaded/unloaded libraries.

llvm-svn: 258857
2016-01-26 20:53:09 +00:00
Evgeniy Stepanov 226965259d [cfi] Cross-DSO CFI diagnostic mode (compiler-rt part)
* add __cfi_slowpath_diag with a 3rd parameter which is a pointer to
  the diagnostic info for the ubsan handlers.
*__cfi_check gets a 3rd parameter as well.
* unify vcall/cast/etc and icall diagnostic info format, and merge
  the handlers to have a single entry point (actually two points due
  to abort/noabort variants).
* tests

Note that this comes with a tiny overhead in the non-diag mode:
cfi_slowpath must pass 0 as the 3rd argument to cfi_check.

llvm-svn: 258744
2016-01-25 23:34:38 +00:00
Bill Seurer 3108513a99 [powerpc] make test case as xfail
This test case which worked for a while is now failing again.  I was unable to
trace the change in status to any particular revision.

llvm-svn: 258739
2016-01-25 23:03:04 +00:00
Xinliang David Li 3aa113321b [PGO] Add a test case covering IR based VP instrumentation
llvm-svn: 258732
2016-01-25 22:33:29 +00:00
Xinliang David Li 19c45e2e12 [PGO] Add test case covering clang FE based VP instrumentation
llvm-svn: 258730
2016-01-25 22:09:30 +00:00
Nico Weber 6a4e0dd1a6 When building without DIA SDK, don't set suppressions.cpp fail
This test requires llvm-symbolizer to be able to convert a stack
address into a function name.  It is only able to do this if the
DIA SDK was found at cmake time.  Add a lit feature for this,
and let the test depend on it.

See also discussion in D15363.

llvm-svn: 258545
2016-01-22 20:26:10 +00:00
Xinliang David Li 8b1f80779b Resubmit test case with more restriction
The original submittion triggered a BFD linker bug (2.24) on Aarch64 only. Before
the build bot is upgraded to more recent linker, restrict the test to be 
executed only with gold linker.

llvm-svn: 258437
2016-01-21 21:59:19 +00:00
Alexey Samsonov c8adcb4af6 [MSan] Add a test case for r258339.
llvm-svn: 258413
2016-01-21 17:51:08 +00:00
Kostya Serebryany af69f1c690 [asan] print an additional hint when reporting a container overflow
llvm-svn: 258337
2016-01-20 19:49:12 +00:00
Renato Golin 533c32bdda Revert "[coverage] Add a test case to cover coverage testing with comdat"
This reverts commit r258255 and r258274, as it was breaking the AArch64 bot.

llvm-svn: 258314
2016-01-20 14:27:50 +00:00
Vedant Kumar 0b9df44cf1 [test] Add a short explanation to instrprof-comdat.h
llvm-svn: 258274
2016-01-20 02:31:25 +00:00
Xinliang David Li 6900596040 [coverage] Add a test case to cover coverage testing with comdat
llvm-svn: 258255
2016-01-20 00:11:36 +00:00
Maxim Ostapenko 1965cc6258 [asan] Optionally print reproducer cmdline in ASan reports.
Differential Revision: http://reviews.llvm.org/D16070

llvm-svn: 258037
2016-01-18 07:55:12 +00:00
Peter Collingbourne f5571f5248 Fix stats.cpp test on 32-bit Windows.
llvm-svn: 257981
2016-01-16 02:08:55 +00:00
Alexey Samsonov 95cd990588 [LSan] Ignore all allocations made inside pthread_create.
Thread stack/TLS may be stored by libpthread for future reuse after
thread destruction, and the linked list it's stored in doesn't
even hold valid pointers to the objects, the latter are calculated
by obscure pointer arithmetic.

With this change applied, LSan test suite passes with
"use_ld_allocations" flag defaulted to "false". It still requires more
testing to check if the default can be switched.

llvm-svn: 257975
2016-01-16 00:57:25 +00:00
Peter Collingbourne 5788e1259b Introduce stats and stats_client libraries.
This is part of a new statistics gathering feature for the sanitizers.
See clang/docs/SanitizerStats.rst for further info and docs.

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

llvm-svn: 257972
2016-01-16 00:31:29 +00:00
Nico Weber 230af4047d Re-disable suppressions.cpp on Windows.
See discussion in http://reviews.llvm.org/D15363

llvm-svn: 257952
2016-01-15 23:19:39 +00:00
Alexey Samsonov 1f242d6a77 [LSan] Add "use_ld_allocations" flag to disable old way of DTLS handling.
This flag allows to disable old way of determining dynamic TLS by
filtering out allocations from dynamic linker. This will be eventually
superseded by __tls_get_addr interceptor (see r257785), after we:
1) Test it in several supported environments
2) Deal with existing problems (currently we can't find a pointer to
  DTV which is calloc()-ed in pthread_create).

llvm-svn: 257789
2016-01-14 19:16:05 +00:00
Xinliang David Li 944cd4d318 [Coverage] add test cases for coverage testing
1. One test covering coverage-mapping interfaction with linker GC
2. one test covering coverage-mapping with shared libaries

llvm-svn: 257782
2016-01-14 18:15:54 +00:00
Kuba Brecka 0626dd0d3b [tsan] Introduce a "ignore_interceptors_accesses" option
On OS X, TSan already passes all unit and lit tests, but for real-world applications (even very simple ones), we currently produce a lot of false positive reports about data races. This makes TSan useless at this point, because the noise dominates real bugs. This introduces a runtime flag, "ignore_interceptors_accesses", off by default, which makes TSan ignore all memory accesses that happen from interceptors. This will significantly lower the coverage and miss a lot of bugs, but it eliminates most of the current false positives on OS X.

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

llvm-svn: 257760
2016-01-14 12:24:37 +00:00
Dmitry Vyukov 529b940a77 tsan: check errors in test
Somebody reported flakiness of this test.
Let's start by checking errors.

llvm-svn: 257585
2016-01-13 10:14:05 +00:00
Adhemerval Zanella c52448872b [compiler-rt] [msan] Remove stable-runtime requirement for insertvalue_origin.cc
This patch removes the requirement on stable-runtime on insertvalue_origin.cc
testcase, added due a instrumentation failure on aarch64-linux. This is fixed
on llvm code by r257375.

llvm-svn: 257479
2016-01-12 15:16:34 +00:00
Xinliang David Li 31ad54298e [PGO] Add Linux specific test cases for profile runtime
(second try with more strict config check)
Currently, only gc-sections related tests are added. Gold
linker currently is required due to PR19161 of bfd linker.

llvm-svn: 257456
2016-01-12 07:18:53 +00:00
Xinliang David Li 452f1a5576 Revert r257444 : arm build bots failure
llvm-svn: 257446
2016-01-12 05:39:26 +00:00
Xinliang David Li cfefae8a14 [PGO] Add Linux specific test cases for profile runtime
Currently, only gc-sections related tests are added. Gold
linker currently is required due to PR19161 of bfd linker.

llvm-svn: 257444
2016-01-12 04:54:24 +00:00
Xinliang David Li 385612c5b4 Fix comment of test
llvm-svn: 257443
2016-01-12 03:57:14 +00:00
Xinliang David Li a692421adb [PGO] Add runtime hook so that IR instrumentation can override version
IR level instrumentation needs to override version with variant bits.
No change for FE instrumentation is needed. Test case is added to
detect version mismatch.

llvm-svn: 257230
2016-01-08 23:31:57 +00:00
Kostya Serebryany abc2c998d2 [tsan] don't crash on closedir(0)
llvm-svn: 257223
2016-01-08 22:48:19 +00:00
Evgeniy Stepanov cfe331042a Fix CMake warning in CFI tests.
CFI tests do not require the CFI runtime library on Windows.
Do not add "cfi" as a dependency of "check-cfi" in that case.

llvm-svn: 257202
2016-01-08 20:04:01 +00:00
Evgeniy Stepanov 6922ab1ff6 Revert "Fix CMake warning in CFI tests."
This is a bit more complex than that.

llvm-svn: 257201
2016-01-08 19:56:45 +00:00
Evgeniy Stepanov bec6f6b731 Fix CMake warning in CFI tests.
Fix incorrect condition for enabling the CFI tests. This removes the following CMake warnings on Windows:

The dependency target "cfi" of target "check-all" does not exist.
The dependency target "cfi" of target "check-cfi-and-supported" does not exist.

llvm-svn: 257199
2016-01-08 19:46:18 +00:00
Nico Weber 2beaab358c Make ubsan suppression test pass on Windows.
llvm-svn: 257183
2016-01-08 17:26:03 +00:00
Xinliang David Li ec58c819fa Use more strict checks for merge Profile results
llvm-svn: 257151
2016-01-08 06:18:18 +00:00
Xinliang David Li 6d464151a6 [PGO] Update test to match sorted output
llvm-svn: 257146
2016-01-08 05:45:54 +00:00
Dimitry Andric 6e8526358f Ensure safestack overflow test doesn't segfault
Summary:
In rL255491, the safestack overflow test was disabled for aarch64, since
it "is currently failing on an AArch64 buildbot with a segfault, but it
is currently passing on other configuration".

While testing on FreeBSD on x86, I also encountered a segfault.  This is
because the `fct()` function actually writes before and after `buffer`,
and on FreeBSD this crashes because `buffer` is usually allocated at the
end of a page.  That this runs correctly on Linux is probably just by
accident.

I propose to fix this by adding a pre and post buffer, to act as a
safety zone.  The pre and post buffers must be accessed in an 'unsafe'
way, otherwise -fsanitize=safestack will allocate them on the safe
stack, and they will not bookend `buffer` itself.  Therefore, I create
them large enough for `fct()`, and call it on both of them.

On FreeBSD, this makes the test run as expected, without segfaulting,
and I suppose this will also fix the segfault on AArch64.  I do not have
AArch64 testing capabilities, so if someone could try that out, I would
be much obliged.

Reviewers: pcc, kcc, zatrazz

Subscribers: llvm-commits, aemerson, emaste

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

llvm-svn: 257106
2016-01-07 22:19:12 +00:00
Mike Aizatsky 54fc6575c5 [sancov] coverage pc buffer
Differential Revision: http://reviews.llvm.org/D15871

llvm-svn: 256804
2016-01-05 01:49:39 +00:00
Xinliang David Li cda3bc2062 [PGO]: Refactor VP data writer
Extract the buffered filer writer code used by value profile 
writer and turn it into common/sharable buffered fileIO 
interfaces. Added a test case for the buffered file writer and
rewrite the VP dumping using the new APIs.

llvm-svn: 256604
2015-12-29 23:54:41 +00:00
Xinliang David Li 54dd683726 [PGO]: Do not update Data->Value field during profile write.
The profile reader no longer depends on this field to be updated and point
to owning func's vp data. The VP data also no longer needs to be allocated
in a contiguous memory space.

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

llvm-svn: 256543
2015-12-29 07:13:59 +00:00
Xinliang David Li 69773fb0d2 Add more testing checks
llvm-svn: 256538
2015-12-29 06:42:12 +00:00
Xinliang David Li ebc4c25a50 [PGO] Make the test case more robust
Make the testing results not depending on function 
output order. This allows more strict result check.

llvm-svn: 256537
2015-12-29 06:28:44 +00:00
Xinliang David Li c30c88a240 Check test results more strictly (NFC)
llvm-svn: 256536
2015-12-29 06:26:43 +00:00
Bill Seurer 8a39ce8d32 [power] Fix test case target checks
Several test cases that used to fail on both power LE and BE
now run correctly on LE.

llvm-svn: 256391
2015-12-24 20:21:36 +00:00
Nico Weber 95ef4b3bf0 XFAIL ubsan suppressions.cpp test on Windows for now.
llvm-svn: 256307
2015-12-23 00:30:32 +00:00
Evgeniy Stepanov f02b782aa7 [cfi] Fix handling of uninstrumented libraries.
CFI shadow for non-CFI libraries should be "unchecked", not "invalid".

llvm-svn: 256285
2015-12-22 21:40:09 +00:00
Evgeniy Stepanov ed61ae6cde [asan] Add mincore test.
ASan does not really do anything interesting with mincore, but this
test verifies that the function still works correctly.

llvm-svn: 256207
2015-12-21 22:35:03 +00:00
Adhemerval Zanella b2910ea67e [compiler-rt] [tsan] Add support for PIE build on AArch64
This patch adds PIE executable support for aarch64-linux.  It adds
two more segments:

- 0x05500000000-0x05600000000: 39-bits PIE program segments
- 0x2aa00000000-0x2ab00000000: 42-bits PIE program segments

Fortunately it is possible to use the same transformation formula for
the new segments range with some adjustments in shadow to memory
formula (it adds a constant offset based on the VMA size).

A simple testcase is also added, however it is disabled on x86 due the
fact it might fail on newer kernels [1].

[1] https://git.kernel.org/linus/d1fd836dcf00d2028c700c7e44d2c23404062c90

llvm-svn: 256184
2015-12-21 19:27:57 +00:00
Kostya Serebryany 1d1be3dd88 [asan] fix fopen interceptor to not crash if path is NULL
llvm-svn: 256182
2015-12-21 19:22:26 +00:00
Alexey Samsonov 081a24e3a7 [UBSan] Implement runtime suppressions (PR25066).
Summary:
Add the ability to suppress UBSan reports for files/functions/modules
at runtime. The user can now pass UBSAN_OPTIONS=suppressions=supp.txt
with the contents of the form:

signed-integer-overflow:file-with-known-overflow.cpp
alignment:function_doing_unaligned_access
vptr:shared_object_with_vptr_failures.so

Suppression categories match the arguments passed to -fsanitize=
flag (although, see below). There is no overhead if suppressions are
not provided. Otherwise there is extra overhead for symbolization.

Limitations:
1) sometimes suppressions need debug info / symbol table to function
   properly (although sometimes frontend generates enough info to
   do the match).
2) it's only possible to suppress recoverable UB kinds - if you've
   built the code with -fno-sanitize-recover=undefined, suppressions
   will not work.
3) categories are fine-grained check kinds, not groups like "undefined"
   or "integer", so you can't write "undefined:file_with_ub.cc".

Reviewers: rsmith, kcc

Subscribers: cfe-commits

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

llvm-svn: 256018
2015-12-18 19:56:42 +00:00
Evgeniy Stepanov 65c3a4b9c0 [cfi] Limit cross-dso tests to Linux.
Mac is missing the driver support to link the CFI runtime library.

llvm-svn: 255730
2015-12-16 00:24:18 +00:00
Evgeniy Stepanov da1cf9287c Cross-DSO control flow integrity (compiler-rt part).
This is an initial version of the runtime cross-DSO CFI support
library.

It contains a number of FIXMEs, ex. it does not support the
diagnostic mode nor dlopen/dlclose, but it works and can be tested.
Diagnostic mode, in particular, would require some refactoring (we'd
like to gather all CFI hooks in the UBSan library into one function
so that we could easier pass the diagnostic information down to
__cfi_check). It will be implemented later.

Once the diagnostic mode is in, I plan to create a second test
configuration to run all existing tests in both modes. For now, this
patch includes only a few new cross-DSO tests.

llvm-svn: 255695
2015-12-15 23:00:33 +00:00
Kostya Serebryany 48b840dda1 [asan] try to fix ARM bots
llvm-svn: 255594
2015-12-15 01:05:35 +00:00
Kostya Serebryany 354bbb2ccd [asan] add option: handle_sigill
llvm-svn: 255588
2015-12-15 00:33:45 +00:00
Evgeniy Stepanov 04621bd888 [msan] Intercept ctermid, ctermid_r.
llvm-svn: 255566
2015-12-14 22:57:49 +00:00
Adhemerval Zanella ac764fabb8 [compiler-rt] [msan] Variadic support for AArch64
Now with variadic support for msan on aarch6 there is no need for
XFAIL signal_stress_test anymore.  Also to garantee aligned stores
for the FP/SIMD arguments enforce the '__msan_va_arg_tls' alignment
to sizeof the SIMD register (16).

llvm-svn: 255496
2015-12-14 14:15:32 +00:00
Kuba Brecka 2cdb522a5a [tsan] Update dispatch_group support to avoid using a disposed group object
We're using the dispatch group itself to synchronize (to call Release() and Acquire() on it), but in dispatch group notifications, the group can already be disposed/deallocated. This causes a later assertion failure at `DCHECK_EQ(*meta, 0);` in `MetaMap::AllocBlock` when the same memory is reused (note that the failure only happens in debug builds).

Fixing this by retaining the group and releasing it in the notification. Adding a stress test case that reproduces this.

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

llvm-svn: 255494
2015-12-14 13:32:57 +00:00
Adhemerval Zanella c974545cde [compiler-rt] [safestack] Silent overflow.c test on aarch64
The safestack overflow.c test is currently failing on an aarch64
buildbot with a segfault, but it is currently passing on other
configuration.

This patch silent the issue for now on aarch64 by setting to all
supported architectures the 'stable-runtime' configure and set
the test to requires it.

llvm-svn: 255491
2015-12-14 11:58:43 +00:00
Xinliang David Li dad2b8f79a [PGO] add a test case in profiler runtime
Add a test case to cover profile dumping of functions with no
value sites, functions with value sites but no dynamic VP data, 
and functions with runtime VP data.

llvm-svn: 255327
2015-12-11 05:43:55 +00:00
Xinliang David Li 449133d8b4 [PGO] Split value profiling runtime into its own file
Value profile runtime depends on libc which breaks
buffer API implemenation with current file organization.

Test case is also updated to check more symbols.

llvm-svn: 255294
2015-12-10 20:24:09 +00:00
Bill Seurer 6845fb3671 [power] Fix test case target checks
Several test cases that used to fail on both power LE and BE
now run correctly on LE.

llvm-svn: 255262
2015-12-10 17:09:53 +00:00
Yury Gribov a8ffa6189e [asan] Move halt_on_error_suppress_equal_pcs.cc to Posix directory.
Patch by Max Ostapenko.

llvm-svn: 255230
2015-12-10 08:34:28 +00:00
Yury Gribov 6bfade1b81 [asan] Suppress duplicated errors in ASan recovery mode.
Patch by Max Ostapenko.

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

llvm-svn: 255228
2015-12-10 08:08:53 +00:00
Chris Bieneman 5c64ddfa88 Revert "[CMake] Provide options for toggling on and off various runtime libraries."
This reverts r255170. This change caused a bunch of bot failures and needs to be revised.

llvm-svn: 255184
2015-12-10 00:40:58 +00:00
Chris Bieneman e82ad46f15 [CMake] Provide options for toggling on and off various runtime libraries.
Summary:
Rather than having to add new "experimental" options each time someone wants to work on bringing a sanitizer to a new platform, this patch makes options for all of them.

The default values for the options are set by the platform checks that would have enabled them, but they can be overridden on or off.

Reviewers: kubabrecka, samsonov

Subscribers: llvm-commits

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

llvm-svn: 255170
2015-12-09 22:45:03 +00:00
Reid Kleckner 0497da4643 Adjust line numbers to account for new XFAIL comments
llvm-svn: 255076
2015-12-08 23:36:35 +00:00
Bill Schmidt 2979162732 [PPC64, TSAN] LLVM basic enablement of thread sanitizer for PPC64 (BE and LE)
This patch is by Simone Atzeni with portions by Adhemerval Zanella.

This contains the LLVM patches to enable the thread sanitizer for
PPC64, both big- and little-endian.  Two different virtual memory
sizes are supported:  Old kernels use a 44-bit address space, while
newer kernels require a 46-bit address space.

There are two companion patches that will be added shortly.  There is
a Clang patch to actually turn on the use of the thread sanitizer for
PPC64.  There is also a patch that I wrote to provide interceptor
support for setjmp/longjmp on PPC64.

Patch discussion at reviews.llvm.org/D12841.

llvm-svn: 255057
2015-12-08 21:54:39 +00:00
Dmitry Vyukov eee690b29a tsan: fix test invisible barrier
Another attempt at fixing tsan_invisible_barrier.
Current implementation causes:
https://llvm.org/bugs/show_bug.cgi?id=25643

There were several unsuccessful iterations for this functionality:

Initially it was implemented in user code using REAL(pthread_barrier_wait). But pthread_barrier_wait is not supported on MacOS. Futexes are linux-specific for this matter.
Then we switched to atomics+usleep(10). But usleep produced parasitic "as-if synchronized via sleep" messages in reports which failed some output tests.
Then we switched to atomics+sched_yield. But this produced tons of tsan- visible events, which lead to "failed to restore stack trace" failures.
Move implementation into runtime and use internal_sched_yield in the wait loop.
This way tsan should see no events from the barrier, so not trace overflows and
no "as-if synchronized via sleep" messages.

llvm-svn: 255030
2015-12-08 17:54:47 +00:00
Kuba Brecka 25dba9b781 [tsan] Add dispatch_group API interceptors and synchronization
This patch adds release and acquire semantics for dispatch groups, plus a test case.

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

llvm-svn: 255020
2015-12-08 14:54:43 +00:00
Alexey Samsonov e243d45285 [TSan] Use llvm-objdump+FileCheck instead of standalone .sh script.
llvm-svn: 254959
2015-12-07 22:43:30 +00:00
Alexey Samsonov dc37ee2226 [TSan] Port check_memcpy.sh script to a regular lit test.
Check that TSan runtime doesn't contain compiler-inserted calls
to memset/memmove functions.

In future, we may consider moving this test to test/sanitizer_common,
as we don't want to have compiler-inserted memcpy/memmove calls in
any sanitizer runtime.

llvm-svn: 254955
2015-12-07 21:53:59 +00:00
Xinliang David Li 55d927a4fd [PGO] Stop leaking libc function to buffer API impl
llvm-svn: 254943
2015-12-07 21:18:16 +00:00
Alexey Samsonov 5d47be186d [TSan] Delete legacy test_output.sh script.
This script is superseded by lit test suite integrated into CMake
for quite a while now. It doesn't support many tests, and require
custom hacks for a few other.

llvm-svn: 254932
2015-12-07 19:40:33 +00:00
Kuba Brecka 87cd9c63df [tsan] Enable building and testing TSan Go runtime on OS X
The build and test actually work now, so let's just enable them.

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

llvm-svn: 254716
2015-12-04 14:29:11 +00:00
Yury Gribov b18e2c7110 [asan] Enable alloca_vla_interact.cc test on PowerPC64.
Patch by Max Ostapenko.

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

llvm-svn: 254708
2015-12-04 09:32:45 +00:00
Xinliang David Li da29bc41a6 [PGO] Fix build failure with -fprofile-instr-generate
and -no-integrated-as for source with static function.

The compiler generates assembly names containing \" in the
.s dump causing gnu assembler to complain. That issue will be
investigated separately. 

llvm-svn: 254705
2015-12-04 06:06:07 +00:00
Xinliang David Li ffb827f2bc [PGO] Unify VP data format between raw and indexed profile (runtime)
With the latest refactoring and code sharing patches landed, 
it is possible to unify the value profile implementation between
raw and indexed profile. This is part  in prfofile runtime.

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

llvm-svn: 254678
2015-12-04 01:02:24 +00:00
Xinliang David Li 9ea3064be5 [PGO] Introduce error report macro in profile-rt
Also added a test case for runtime error reporting.

llvm-svn: 254625
2015-12-03 18:31:59 +00:00
Kuba Brecka 0423e5cd57 [tsan] Add interceptors for Darwin-specific locking APIs
On OS X, there are other-than-pthread locking APIs that are used quite extensively - OSSpinLock and os_lock_lock. Let's add interceptors for those.

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

llvm-svn: 254611
2015-12-03 15:10:52 +00:00
Kuba Brecka ab43f42d9c Follow-up of r254600 to fix the dyld_insert_libraries_reexec.cc testcase on OS X 10.10.
llvm-svn: 254604
2015-12-03 11:34:16 +00:00
Kuba Brecka f642e88342 [tsan] Use MAP_ANON instead of MAP_ANONYMOUS
In mmap_large.cc, let's use MAP_ANON instead of MAP_ANONYMOUS, because MAP_ANONYMOUS is only available on OS X 10.11 and later.

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

llvm-svn: 254601
2015-12-03 10:46:26 +00:00
Sumanth Gundapaneni b32a22eab7 Fix the RUN on UBSAN unit tests
For the build set up which runs the unit tests using an emulator like QEMU,
the unit tests must be run using %run.

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

llvm-svn: 254467
2015-12-01 23:03:08 +00:00
Kuba Brecka ac5f5d10d5 [tsan] Add interceptors and sychronization for libdispatch semaphores on OS X
This patch adds release and acquire semantics for libdispatch semaphores and a test case.

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

llvm-svn: 254412
2015-12-01 13:11:42 +00:00
Yury Gribov 67a001fd17 [asan] Correctly release memory allocated during early startup.
Calloc interceptor initially allocates memory from temp buffer (to serve dlsyms called during asan_init). There is a chance that some non-instrumented library (or executable) has allocated memory with calloc before asan_init and got pointer from the same temporary buffer which later caused problems with free.

Inspired by https://github.com/google/sanitizers/issues/626

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

llvm-svn: 254395
2015-12-01 09:22:41 +00:00
Adhemerval Zanella 7a096596b2 [compiler-rt] Remove SANITIZER_AARCH64_VMA usage
This patch complete removed SANITIZER_AARCH64_VMA definition and usage.
AArch64 ports now supports runtime VMA detection and instrumentation
for 39 and 42-bit VMA.

It also Rewrite print_address to take a variadic argument list
(the addresses to print) and adjust the tests which uses it to the new
signature.

llvm-svn: 254319
2015-11-30 19:43:03 +00:00
Kuba Brecka 6c9122ffba [tsan] Change comments referencing code.google.com to point to GitHub instead. NFC.
Changing comments that have references to code.google.com to point to GitHub instead, because the current links are not redirected properly (they instead redirect to different issues, mostly ASan). NFC.

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

llvm-svn: 254300
2015-11-30 14:11:48 +00:00
Kuba Brecka 77ff411247 [tsan] Fix signals and setjmp/longjmp on OS X
1) There's a few wrongly defined things in tsan_interceptors.cc,
2) a typo in tsan_rtl_amd64.S which calls setjmp instead of sigsetjmp in the interceptor, and
3) on OS X, accessing an mprotected page results in a SIGBUS (and not SIGSEGV).

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

llvm-svn: 254299
2015-11-30 14:11:02 +00:00
Kuba Brecka 8f9607a616 [tsan] Add release+acquire semantics for serial dispatch queues
Serial queues need extra happens-before between individual tasks executed in the same queue. This patch adds `Acquire(queue)` before the executed task and `Release(queue)` just after it (for serial queues only). Added a test case.

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

llvm-svn: 254229
2015-11-28 12:53:57 +00:00
Kuba Brecka bdb5cef272 [tsan] Add a testcase for a race on a Obj-C instance variable
Let's add a testcase for a race on a Obj-C instance variable.

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

llvm-svn: 254226
2015-11-28 10:32:05 +00:00
Kuba Brecka 8910d652a9 [tsan] Mark a few more tests with "UNSUPPORTED: darwin"
There's a few more lit tests that require features not available on OS X (MAP_32BIT, pthread_setname_np), let's mark them with "UNSUPPORTED: darwin".

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

llvm-svn: 254225
2015-11-28 09:22:27 +00:00
Kuba Brecka fbbdd7bdee [tsan] Change mutexset6.cc to use a mutex instead of spinlock
Pthread spinlocks are not available on OS X and this test doesn't really require a spinlock.

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

llvm-svn: 254224
2015-11-28 09:18:43 +00:00
Kuba Brecka 11d8c1f8dd [tsan] Fix an assertion failure in FindThreadByUidLocked with recycled threads
When a race on file descriptors is detected, `FindThreadByUidLocked()` is called to retrieve ThreadContext with a specific unique_id. However, this ThreadContext might not exist in the thread registry anymore (it may have been recycled), in which case `FindThreadByUidLocked` will cause an assertion failure in `GetThreadLocked`. Adding a test case that reproduces this, producing:

    FATAL: ThreadSanitizer CHECK failed: sanitizer_common/sanitizer_thread_registry.h:92 "((tid)) < ((n_contexts_))" (0x34, 0x34)

This patch fixes this by replacing the loop with `FindThreadContextLocked`.

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

llvm-svn: 254223
2015-11-28 09:16:34 +00:00
Adhemerval Zanella 066c5f0f92 [compiler-rt] [tsan] Unify aarch64 mapping
This patch unify the 39 and 42-bit support for AArch64 by using an external
memory read to check the runtime detected VMA and select the better mapping
and transformation.  Although slower, this leads to same instrumented binary
to be independent of the kernel.

Along with this change this patch also fix some 42-bit failures with
ALSR disable by increasing the upper high app memory threshold and also
the 42-bit madvise value for non large page set.

llvm-svn: 254151
2015-11-26 13:10:47 +00:00
Kuba Brecka ad986d5141 [asan] Fix the atos-symbolizer-dyld-root-path.cc test case
Due to a typo, atos-symbolizer-dyld-root-path.cc is currently being skipped all the time. There's a few more typos/copy-paste-errors. Let's fix them and enable this test.

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

llvm-svn: 254058
2015-11-25 07:59:00 +00:00
Kuba Brecka 440d08600b [tsan] Implement basic GCD interceptors for OS X
We need to intercept libdispatch APIs (dispatch_sync, dispatch_async, etc.) to add synchronization between the code that submits the task and the code that gets executed (possibly on a different thread). This patch adds release+acquire semantics for dispatch_sync, and dispatch_async (plus their "_f" and barrier variants). The synchronization is done on malloc'd contexts (separate for each submitted block/callback). Added tests to show usage of dispatch_sync and dispatch_async, for cases where we expect no warnings and for cases where TSan finds races.

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

llvm-svn: 253982
2015-11-24 13:36:06 +00:00
Kuba Brecka 6cb7f7a923 [tsan] Fix stack_sync_reuse.cc test on OS X
The test relies on two variables in different frames to end up being on the same address. For some reason, this isn't true on OS X. This patch adds `__attribute__((aligned(64)))` to the variables, which actually makes the variables occupy the same address. This is still not a guarantee, but it's more likely to work (the test looks very fragile already).

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

llvm-svn: 253981
2015-11-24 13:29:15 +00:00
Kuba Brecka 941d0a756a [tsan] Replace pthread semaphore in signal_cond.cc with barrier_wait
Pthread semaphores are not available on OS X. Let's replace sem_wait/sem_post with barrier_wait, which makes the test pass on OS X. I know that sem_wait/sem_post is intercepted by TSan, whereas barrier_wait is TSan-invisible, but the purpose of the test is not affected by this.

Also, let's properly initialize the mutex and cond variables.

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

llvm-svn: 253980
2015-11-24 13:28:27 +00:00
Kuba Brecka 2f8d345adc [tsan] Modify the tls_race.cc and tls_race2.cc tests to pass on OS X
On OS X, __thread variables are lazily heap-allocated (with malloc). Therefore, they're recognized as heap blocks (which is what they are) and not as TLS variables in TSan reports. Figuring out if a heap block is a TLS or not is difficult (in malloc interceptor we could analyze the caller and then mark the object), so let's instead modify the tests so that we expect the report to say "Location is heap block" instead of "Location is TLS".

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

llvm-svn: 253858
2015-11-23 08:17:17 +00:00
Joerg Sonnenberger 47174a5a2c Add a generic version of __divtc3.c for long double complex division.
Mark the unit test as applying to all platforms.

llvm-svn: 253831
2015-11-22 19:13:49 +00:00
Joerg Sonnenberger 6719bd7d2a Use cabsl for long double, not cabs.
llvm-svn: 253829
2015-11-22 18:53:43 +00:00
Anna Zaks f30f351faf [asan] Disable the test on i386 Darwin.
This test checks if we can print a backtrace from the death callback. On old
OS X versions, backtrace is not able to symbolicate the trace past the ASan
runtime because we build with -fomit-frame-pointer.

llvm-svn: 253729
2015-11-20 22:55:22 +00:00
Peter Collingbourne d198896240 Re-enable CFI tests on Windows.
Clang driver was fixed in r253707.

llvm-svn: 253712
2015-11-20 21:16:00 +00:00
Anna Zaks 2ce9f9447c Reapply: [asan] On OS X, log reports to syslog and os_trace
When ASan currently detects a bug, by default it will only print out the text
of the report to stderr. This patch changes this behavior and writes the full
text of the report to syslog before we terminate the process. It also calls
os_trace (Activity Tracing available on OS X and iOS) with a message saying
that the report is available in syslog. This is useful, because this message
will be shown in the crash log.

For this to work, the patch makes sure we store the full report into
error_message_buffer unconditionally, and it also strips out ANSI escape
sequences from the report (they are used when producing colored reports).

I've initially tried to log to syslog during printing, which is done on Android
right now. The advantage is that if we crash during error reporting or the
produced error does not go through ScopedInErrorReport, we would still get a
(partial) message in the syslog. However, that solution is very problematic on
OS X. One issue is that the logging routine uses GCD, which may spawn a new
thread on its behalf. In many cases, the reporting logic locks threadRegistry,
which leads to deadlocks.

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

(In addition, add sanitizer_common_libcdep.cc to buildgo.sh to avoid
build failures on Linux.)

llvm-svn: 253688
2015-11-20 18:41:44 +00:00
Alexey Samsonov 3e49a7bc32 [TSan] Fix custom scripts that validate TSan on non-standard buildbot.
llvm-svn: 253682
2015-11-20 18:13:03 +00:00
Hans Wennborg 43db5b7daa Disable the cfi tests on Windows
They are currently broken and there seems to be no bot coverage
for this configuration so it's essentially unspported.

llvm-svn: 253673
2015-11-20 16:29:53 +00:00
Kuba Brecka e08533577f [tsan] Replace POSIX semaphores with pthread condition variables in vptr_benign_race.cc
OS X doesn't support POSIX semaphores (but it does have the API for it, which returns ENOSYS - "Function not implemented").

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

llvm-svn: 253665
2015-11-20 14:17:43 +00:00
Kuba Brecka 1a26ff7d17 [tsan] Fix deadlock_detector_stress_test.cc testcase for OS X
On OS X, we don't have pthread spinlocks, let's just use a regular mutex instead. Secondly, pthread_rwlock_t is much larger (200 bytes), so `char padding_[64 - sizeof(pthread_rwlock_t)]` actually underflows.

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

llvm-svn: 253659
2015-11-20 11:13:36 +00:00
Kuba Brecka 8aa56d3cc8 [tsan] Make tests that use CLOCK_MONOTONIC portable
Several tests rely on CLOCK_MONOTONIC, which doesn't exist on OS X. This patch fixes these tests by either disabling them (in case of cond_version.c which doesn't make sense on OS X), or by porting the test to also work on OS X.

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

llvm-svn: 253658
2015-11-20 11:07:16 +00:00
Kuba Brecka 153594694b [tsan] Implement "%env_tsan_opts" substitution to inherit default TSAN_OPTIONS
We already have %env_asan_opts for ASan, let's implement the same for TSan.

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

llvm-svn: 253579
2015-11-19 17:28:46 +00:00
Alexey Samsonov 89d7ff5de6 [LSan] Fix tests with some libstdc++ implementations.
Summary:
Newer libstdc++ has global pool, which is filled with objects
allocated during libstdc++ initialization, and never released.
Using use_globals=0 in the lit tests results in these objects
being treated as leaks.

Fix this by porting several tests to plain C, and introducing
a simple sanity test case for __lsan::ScopedDisabler.

Reviewers: kcc, ygribov

Subscribers: llvm-commits

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

llvm-svn: 253576
2015-11-19 17:18:02 +00:00
Kuba Brecka 6e90edf803 [tsan] Mark tests that need pthread barriers with "UNSUPPORTED: darwin"
Several testcases need pthread barriers (e.g. all bench_*.cc which use test/tsan/bench.h) which are not available on OS X. Let's mark them with "UNSUPPORTED: darwin".

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

llvm-svn: 253558
2015-11-19 12:02:02 +00:00
Kuba Brecka efd92b3d16 [tsan] Handle dispatch_once on OS X
Reimplement dispatch_once in an interceptor to solve these issues that may produce false positives with TSan on OS X:

1) there is a racy load inside an inlined part of dispatch_once,
2) the fast path in dispatch_once doesn't perform an acquire load, so we don't properly synchronize the initialization and subsequent uses of whatever is initialized,
3) dispatch_once is already used in a lot of already-compiled code, so TSan doesn't see the inlined fast-path.

This patch uses a trick to avoid ever taking the fast path (by never storing ~0 into the predicate), which means the interceptor will always be called even from already-compiled code. Within the interceptor, our own atomic reads and writes are not written into shadow cells, so the race in the inlined part is not reported (because the accesses are only loads).

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

llvm-svn: 253552
2015-11-19 10:35:35 +00:00
Yury Gribov dd679b334b [asan] Enable halt_on_error tests on ARM targets.
Differential Revision: http://reviews.llvm.org/D14751

llvm-svn: 253549
2015-11-19 08:36:26 +00:00
Reid Kleckner 4029426b17 [msan] Don't unpoison phdrs on dlopen(NULL, 0)
Summary:
dlopen(NULL, ...) is intended to give you back a handle to the
executable for use with dlsym. Casting it to link_map and using it with
ForEachMappedRegion results in a crash.

We also shouldn't unpoison the globals of a DSO that is already in
memory. This ensures that we don't do it for the executable, but in
general, MSan may have false negatives if the DSO is already loaded.

Reviewers: eugenis

Subscribers: llvm-commits

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

llvm-svn: 253530
2015-11-19 00:55:45 +00:00
Mike Aizatsky b2c5e1b263 Removing memory leak to appease windows bots.
Differential Revision: http://reviews.llvm.org/D14785

llvm-svn: 253507
2015-11-18 21:44:33 +00:00
Mike Aizatsky 52025af820 Disable gvn non-local speculative loads under asan.
Summary: Fix for https://llvm.org/bugs/show_bug.cgi?id=25550

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

llvm-svn: 253499
2015-11-18 20:43:20 +00:00
Yury Gribov 4c3baeb686 [asan] Use proper macro in runline.
llvm-svn: 253457
2015-11-18 13:38:45 +00:00
Yury Gribov 6689df85ee [asan] Enable halt_on_error tests on OS X.
llvm-svn: 253342
2015-11-17 16:34:39 +00:00
Adhemerval Zanella 2f7f5e3535 [compiler-rt] [tsan] Enable intercept setjmp/longjmp for AArch64
This patch adds assembly routines to enable setjmp/longjmp for aarch64
on linux.  It fixes:

 * test/tsan/longjmp2.cc
 * test/tsan/longjmp3.cc
 * test/tsan/longjmp4.cc
 * test/tsan/signal_longjmp.cc

I also checked with perlbench from specpu2006 (it fails to run
with missing setjmp/longjmp intrumentation).

llvm-svn: 253205
2015-11-16 13:55:19 +00:00
Yury Gribov bdf8751609 [asan] Restored asynch signal test.
llvm-svn: 253204
2015-11-16 13:54:32 +00:00
Kuba Brecka 04d512133f Reverting r253080 ([tsan] Don't demangle names not starting with "_Z").
This caused bot failures on ARM, e.g. http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/9068

llvm-svn: 253129
2015-11-14 10:42:08 +00:00
Xinliang David Li b6c81d2b92 [PGO] Ensure profile section symbols are created (linux)
- This is to handle a corner case where profile lib is linked
  in but non of the modules are instrumented (On linux, since
  we avoided the overhead to emit runtime hook use functions so
  this is the side effect of that size optimization).
- Added a profile runtime test case to cover all scenarios of
  shared library builds. 

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

llvm-svn: 253098
2015-11-13 22:33:07 +00:00
Kuba Brecka 1f219dcb98 [tsan] Don't demangle names not starting with "_Z"
I noticed that when a symbol is named just "x", it gets demangled to "long long". On POSIX, AFAIK, mangled names always start with "_Z", so lets just require that.

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

llvm-svn: 253080
2015-11-13 20:47:29 +00:00
Kuba Brecka 52d02ab9d9 [tsan] Expect memmove interceptor to be called from memcpy
On OS X, memcpy and memmove are actually aliases of the same function, so the memmove interceptor can be invoked on a call to memcpy. This patch updates the tests to expect either memmove or memcpy on a stack trace.

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

llvm-svn: 253077
2015-11-13 20:41:37 +00:00
Kuba Brecka 6c0b367297 [tsan] Mark dl_iterate_phdr.cc test as unsupported on OS X
The dl_iterate_phdr is not present on OS X.

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

llvm-svn: 253076
2015-11-13 20:40:02 +00:00
Kuba Brecka 770dac4382 [tsan] Don't require full paths to be present on stack traces
The OS X symbolizers (namely AtosSymbolizer) don't return full file paths, only file names. This patch modifies `mutexset*.cc` tests not to require a path to be present in the symbol on the stack trace.

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

llvm-svn: 253075
2015-11-13 20:36:08 +00:00
Yury Gribov 7e3c7ee0b1 [asan] Fixed invalid check in test.
llvm-svn: 253037
2015-11-13 12:49:58 +00:00
Yury Gribov eed2daa80c [asan] Dump test output in case of error in single-threaded mode.
llvm-svn: 253035
2015-11-13 12:07:15 +00:00
Yury Gribov a085297030 [asan] Fix test to properly handle collisions.
llvm-svn: 253025
2015-11-13 10:32:13 +00:00
Yury Gribov 1e89f53902 [asan] Get rid of rand_r (not available on all targets).
llvm-svn: 253021
2015-11-13 09:43:30 +00:00
Kuba Brecka 49fd0c138d [tsan] Add global symbolication support into AtosSymbolizer
This patch adds support for symbolication of globals (implements `SymbolizeData`) for `AtosSymbolizer` on OS X.

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

llvm-svn: 253015
2015-11-13 06:45:49 +00:00
Reid Kleckner b8e3bff98a [Windows] Fix halt_on_error-1.c test on Windows with %env_asan_opts
llvm-svn: 252958
2015-11-12 21:58:28 +00:00
Evgeniy Stepanov 833c75e554 [asan] Mark halt_on_error-torture test unsupported on android.
Android libc is missing rand_r until API 21. ASan supports API 19.

llvm-svn: 252930
2015-11-12 19:30:38 +00:00
Kuba Brecka af9525dfff [tsan] Add global symbolication support into DlAddrSymbolizer
`DlAddrSymbolizer` is used on OS X when we're running inside a sandbox that prevents us from spawning an external symbolizer. This patch adds support for symbolication of globals (implements `SymbolizeData`) for `DlAddrSymbolizer`.

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

llvm-svn: 252899
2015-11-12 15:19:40 +00:00
Kuba Brecka 3ecce92a52 [tsan] Allow symbolizers that don't obtain global symbol sizes
The default symbolizer, `llvm-symbolizer` provides sizes for global symbols. On OS X, we want to also allow using `atos` (because it's available everywhere and users don't need to copy/install it) and `dladdr` (it's the only available option when running in a sandbox). However, these symbolizers do not supply the symbol sizes, only names and starting addresses. This patch changes the reporting functions to hide the size of the symbol when this value is unavailable, and modifies tests to make this part of the report "optional".

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

llvm-svn: 252896
2015-11-12 14:34:17 +00:00
Kuba Brecka e342469c0a [tsan] Add a Darwin-specific lit test directory
Differential Revision: http://reviews.llvm.org/D14610

llvm-svn: 252887
2015-11-12 13:27:55 +00:00
Dmitry Vyukov 1041aabbb0 tsan: fix flakiness of sleep_sync2 test
llvm-svn: 252869
2015-11-12 10:24:22 +00:00
Kostya Serebryany 673283cc7c [sanitizer coverage] reset global counters in __sanitizer_reset_coverage
llvm-svn: 252815
2015-11-11 22:44:25 +00:00
Evgeniy Stepanov 77ef54288a [asan] Remove a flaky test.
llvm-svn: 252805
2015-11-11 21:37:12 +00:00
Yury Gribov 8fbd938641 [ASan] Improve portability of new tests.
llvm-svn: 252742
2015-11-11 15:42:26 +00:00
Jay Foad 305586257c Implement some TLS support for PowerPC64.
Summary: This is enough to get the asan static_tls.cc test case working.

Reviewers: eugenis, samsonov

Subscribers: llvm-commits

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

llvm-svn: 252738
2015-11-11 15:37:47 +00:00
Yury Gribov 159727d417 [ASan] Add stress test for asynch signals in nonhalting mode.
Differential Revision: http://reviews.llvm.org/D14241

llvm-svn: 252729
2015-11-11 14:02:33 +00:00
Yury Gribov 468d955b98 [ASan] Enable optional ASan recovery.
Differential Revision: http://reviews.llvm.org/D12318

llvm-svn: 252723
2015-11-11 11:59:38 +00:00
Hans Wennborg dab6b25e38 CFI: try to make test/cfi/base-derived-destructor.cpp pass on Windows
llvm-svn: 252468
2015-11-09 14:25:08 +00:00
Kuba Brecka 8eab127307 [tsan] Skip building libcxx_tsan on OS X
The TSan-instrumented version of libcxx doesn't even build on OS X at this point. Let's skip it from the OS X build for now, since most of TSan functionality doesn't depend on it. This will enable `check-tsan` to be run.

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

llvm-svn: 252455
2015-11-09 09:53:38 +00:00
Kuba Brecka be81c28ec6 [tsan] Turn lit test deadlocks into failures (OS X)
Several tests currently deadlock when the lit test suite is run on OS X. Let's mark them as unsupported.

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

llvm-svn: 252402
2015-11-07 14:29:38 +00:00
Kuba Brecka 9dcecefe67 [tsan] Add Darwin support for lit tests
This patch enables running lit tests on OS X:
1) Simply enable tests for Darwin (they were restricted to Linux and FreeBSD).
2) Disable using instrumented libcxx (libcxx_tsan) on Darwin.
3) On Darwin, override abort_on_error=0, otherwise all tests would generate crash logs and take much longer to process.

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

llvm-svn: 252309
2015-11-06 15:05:34 +00:00
Dmitry Vyukov 4cd631cd7c tsan: make invisible test barrier portable
The current implementation does not work on darwin and can have issues with other OSes in future.
See http://reviews.llvm.org/D14427
Make it portable once and for all (minus usleep call).

Reviewed in:
http://reviews.llvm.org/D14434

llvm-svn: 252292
2015-11-06 11:52:24 +00:00
Kuba Brecka 1ef2414861 [tsan] Replace pthread_yield with sched_yield in lit tests
OS X doesn't have `pthread_yield`. Let's use `sched_yield` instead.

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

llvm-svn: 252283
2015-11-06 11:05:53 +00:00
Sergey Dmitrouk 195f3a15e6 [compiler-rt][aarch64] New tests for 128-bit floating-point builtins, fixes of tests and __fixuint
Summary:
The following tests for 128-bit floating-point type behaved in a strange way, thought it were bugs, but seem to be mistakes in tests:

 * `fixtfsi` test checked for `0x80000001` as a value returned for number less than can be represented, while `LONG_MIN` should be returned on saturation;
 * `fixunstfdi` wasn't enabled for AArch64, only for PPC, but there is nothing PPC specific in that test;
 * `multf3` tried to underflow multiplication by producing result with 16383 exponent, while there are still 112 bits of fraction plus implicit bit, so resultant exponent should be 16497.

Tests for some other builtins didn't exist:

 * `fixtfdi`
 * `fixtfti`
 * `fixunstfti`

They were made by copying similar files and adjusting for wider types and adding/removing some reasonable/extra checks.

Also `__fixuint` seems to have off by one error, updated tests to catch this case.

Reviewers: rengolin, zatrazz, howard.hinnant, t.p.northover, jmolloy, enefaim

Subscribers: aemerson, llvm-commits, rengolin

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

llvm-svn: 252180
2015-11-05 18:36:42 +00:00
Juergen Ributzka d7dcffaea4 Revert "Reapply: [asan] On OS X, log reports to syslog and os_trace"
Looks like this commit is deadlocking the ASAN tests on the green dragon bot
(http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA/).

llvm-svn: 252076
2015-11-04 21:03:12 +00:00
Mike Aizatsky 1e41784f20 Asan: utility function to determine first wrongly poisoned byte in
container.

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

llvm-svn: 252071
2015-11-04 19:56:03 +00:00
Kuba Brecka 465cb8a6fa [tsan] Use malloc zone interceptors on OS X, part 1 (refactoring)
TSan needs to use a custom malloc zone on OS X, which is already implemented in ASan.  This patch is a refactoring patch (NFC) that extracts this from ASan into sanitizer_common, where we can reuse it in TSan.

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

llvm-svn: 252052
2015-11-04 15:43:45 +00:00
Kuba Brecka c9249498ce [tsan] CMake support for TSan on OS X
Hi, this patch adds a CMake flag called `COMPILER_RT_ENABLE_TSAN_OSX`, which is off by default. If enabled, the build system will be building the OS X version of the TSan runtime library (called `libclang_rt.tsan_osx_dynamic.dylib`). I'll submit patches that fix OS X build errors shortly.

This is part of an effort to port TSan to OS X, and it's one the very first steps. Don't expect TSan on OS X to actually work or pass tests at this point.

llvm-svn: 251915
2015-11-03 14:13:59 +00:00
Adhemerval Zanella 689724e578 [compiler-rt] [msan] Unify aarch64 mapping
This patch unify the 39-bit and 42-bit mapping for aarch64 to use only
one instrumentation algorithm.  A runtime check avoid mapping 42-bit 
only segments for 39-bit kernels.

The mapping to use now is for 39 and 42-bits:

    0x00000000000ULL-0x01000000000ULL  MappingDesc::INVALID
    0x01000000000ULL-0x02000000000ULL  MappingDesc::SHADOW
    0x02000000000ULL-0x03000000000ULL  MappingDesc::ORIGIN
    0x03000000000ULL-0x04000000000ULL  MappingDesc::SHADOW
    0x04000000000ULL-0x05000000000ULL  MappingDesc::ORIGIN
    0x05000000000ULL-0x06000000000ULL  MappingDesc::APP
    0x06000000000ULL-0x07000000000ULL  MappingDesc::INVALID
    0x07000000000ULL-0x08000000000ULL  MappingDesc::APP

And only for 42-bits:

    0x08000000000ULL-0x09000000000ULL  MappingDesc::INVALID
    0x09000000000ULL-0x0A000000000ULL  MappingDesc::SHADOW
    0x0A000000000ULL-0x0B000000000ULL  MappingDesc::ORIGIN
    0x0B000000000ULL-0x0F000000000ULL  MappingDesc::INVALID
    0x0F000000000ULL-0x10000000000ULL  MappingDesc::APP
    0x10000000000ULL-0x11000000000ULL  MappingDesc::INVALID
    0x11000000000ULL-0x12000000000ULL  MappingDesc::APP
    0x12000000000ULL-0x17000000000ULL  MappingDesc::INVALID
    0x17000000000ULL-0x18000000000ULL  MappingDesc::SHADOW
    0x18000000000ULL-0x19000000000ULL  MappingDesc::ORIGIN
    0x19000000000ULL-0x20000000000ULL  MappingDesc::INVALID
    0x20000000000ULL-0x21000000000ULL  MappingDesc::APP
    0x21000000000ULL-0x26000000000ULL  MappingDesc::INVALID
    0x26000000000ULL-0x27000000000ULL  MappingDesc::SHADOW
    0x27000000000ULL-0x28000000000ULL  MappingDesc::ORIGIN
    0x28000000000ULL-0x29000000000ULL  MappingDesc::SHADOW
    0x29000000000ULL-0x2A000000000ULL  MappingDesc::ORIGIN
    0x2A000000000ULL-0x2B000000000ULL  MappingDesc::APP
    0x2B000000000ULL-0x2C000000000ULL  MappingDesc::INVALID
    0x2C000000000ULL-0x2D000000000ULL  MappingDesc::SHADOW
    0x2D000000000ULL-0x2E000000000ULL  MappingDesc::ORIGIN
    0x2E000000000ULL-0x2F000000000ULL  MappingDesc::APP
    0x2F000000000ULL-0x39000000000ULL  MappingDesc::INVALID
    0x39000000000ULL-0x3A000000000ULL  MappingDesc::SHADOW
    0x3A000000000ULL-0x3B000000000ULL  MappingDesc::ORIGIN
    0x3B000000000ULL-0x3C000000000ULL  MappingDesc::APP
    0x3C000000000ULL-0x3D000000000ULL  MappingDesc::INVALID
    0x3D000000000ULL-0x3E000000000ULL  MappingDesc::SHADOW
    0x3E000000000ULL-0x3F000000000ULL  MappingDesc::ORIGIN
    0x3F000000000ULL-0x40000000000ULL  MappingDesc::APP

And although complex it provides a better memory utilization that
previous one.

[1] http://reviews.llvm.org/D13817

llvm-svn: 251625
2015-10-29 13:04:19 +00:00
Anna Zaks 7920eb0b1f Reapply: [asan] On OS X, log reports to syslog and os_trace
When ASan currently detects a bug, by default it will only print out the text
        of the report to stderr. This patch changes this behavior and writes the full
        text of the report to syslog before we terminate the process. It also calls
        os_trace (Activity Tracing available on OS X and iOS) with a message saying
        that the report is available in syslog. This is useful, because this message
        will be shown in the crash log.

        For this to work, the patch makes sure we store the full report into
        error_message_buffer unconditionally, and it also strips out ANSI escape
        sequences from the report (they are used when producing colored reports).

        I've initially tried to log to syslog during printing, which is done on Android
        right now. The advantage is that if we crash during error reporting or the
        produced error does not go through ScopedInErrorReport, we would still get a
        (partial) message in the syslog. However, that solution is very problematic on
        OS X. One issue is that the logging routine uses GCD, which may spawn a new
        thread on its behalf. In many cases, the reporting logic locks threadRegistry,
        which leads to deadlocks.

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

        (In addition, add sanitizer_common_libcdep.cc to buildgo.sh to avoid
         build failures on Linux.)

llvm-svn: 251577
2015-10-28 23:18:44 +00:00
Evgeniy Stepanov d10e6280cb [asan] Disable a flaky test on Android.
Bug: https://github.com/google/sanitizers/issues/618
llvm-svn: 251554
2015-10-28 20:45:52 +00:00
Anna Zaks 55fbb6d7f5 Revert "[asan] On OS X, log reports to syslog and os_trace"
This reverts commit 251447.

(Which caused failures on a Linux bot.)

llvm-svn: 251467
2015-10-27 23:15:05 +00:00
Daniel Sanders 6c583b8b25 [mips][asan] XFAIL ptrace.cc
It was recently enabled for non-x86 targets and doesn't seem to work for MIPS.
The reason is currently unclear so XFAILing while I investigate.

llvm-svn: 251466
2015-10-27 23:13:26 +00:00
Anna Zaks 9a95c9a633 [asan] On OS X, log reports to syslog and os_trace
When ASan currently detects a bug, by default it will only print out the text
of the report to stderr. This patch changes this behavior and writes the full
text of the report to syslog before we terminate the process. It also calls
os_trace (Activity Tracing available on OS X and iOS) with a message saying
that the report is available in syslog. This is useful, because this message
will be shown in the crash log.

For this to work, the patch makes sure we store the full report into
error_message_buffer unconditionally, and it also strips out ANSI escape
sequences from the report (they are used when producing colored reports).

I've initially tried to log to syslog during printing, which is done on Android
right now. The advantage is that if we crash during error reporting or the
produced error does not go through ScopedInErrorReport, we would still get a
(partial) message in the syslog. However, that solution is very problematic on
OS X. One issue is that the logging routine uses GCD, which may spawn a new
thread on its behalf. In many cases, the reporting logic locks threadRegistry,
which leads to deadlocks.

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

llvm-svn: 251447
2015-10-27 20:13:01 +00:00
Daniel Sanders 171d6fa35d Attempt to fix asan's ptrace.cc on the clang-cmake-mips builder after r251331.
llvm-svn: 251379
2015-10-27 01:35:57 +00:00
Evgeniy Stepanov 12ffb42893 [msan] Yet another attempt to fix process_vm_readv test.
llvm-svn: 251372
2015-10-27 00:11:28 +00:00
Evgeniy Stepanov f0344626d2 [asan] Mark 5 tests unsupported on Android.
llvm-svn: 251362
2015-10-26 22:19:50 +00:00
Evgeniy Stepanov fb38728241 [asan] Fix throw-call-test to properly XFAIL on android/aarch64.
The test is sensitive to stack layout changes. Tweak it a bit to
expose the bug on aarch64 as well as on arm.

llvm-svn: 251361
2015-10-26 22:19:47 +00:00
Evgeniy Stepanov 798d4f0329 [asan] Switch back to BFD linker in asan/android tests.
We've switched to Gold earlier because of a minor misconfiguration
of the BFD linker in Android NDK. It turns out, Gold has much bigger
problems:

https://sourceware.org/bugzilla/show_bug.cgi?id=19163
(a bug is actually in the android runtime loader, but it means that
gold does not work with android L and even M).

Switching back to BFD and adding a workaround by explicitly linking
libm to all tests.

llvm-svn: 251360
2015-10-26 22:19:46 +00:00
Evgeniy Stepanov 9944209a0a [asan] Don't use asanwrapper in 64-bit android tests.
Asanwrapper is required on older android versions to work around undesired
linker behavior. It is not required on L and newer, and does not fully
support multiarch devices.

llvm-svn: 251359
2015-10-26 22:19:44 +00:00
Evgeniy Stepanov 1a1973b846 [msan] Fix process_vm_readv test.
The check for the glibc version was not working as expected (dlsym
was finding the interceptor instead of the libc implementation).

llvm-svn: 251345
2015-10-26 20:55:35 +00:00
Adhemerval Zanella 6153ecc4fd [compiler-rt] Fix ptrace interceptor for aarch64
This patch fixes the ptrace interceptor for aarch64. The PTRACE_GETREGSET
ptrace syscall with with invalid memory might zero the iovec::iov_base
field and then masking the subsequent check after the syscall (since it
will be 0 and it will not trigger an invalid access). The fix is to copy
the value on a local variable and use its value on the checks.

The patch also adds more coverage on the Linux/ptrace.cc testcase by addding
check for PTRACE_GETREGSET for both general and floating registers (aarch64
definitions added only).

llvm-svn: 251331
2015-10-26 18:55:04 +00:00
Adhemerval Zanella 871d324799 [compiler-rt] Enable ptrace sanitizer for arm
This patch enables the ptrace syscall interceptors for arm and adds support
for both PTRACE_GETVFPREGS and PTRACE_SETVFPREGS used to get the VFP register
from ARM.

The ptrace tests is also updated with arm and PTRACE_GETVFPREGS tests.

llvm-svn: 251321
2015-10-26 18:15:14 +00:00
Hal Finkel 9f42bf047c Fixup test/ubsan/TestCases/Misc/coverage-levels.cc, LLVM is smarter
Fixing up this test case because LLVM is smarter now, and can better analyze:

  if ((argc << shift) == 16)

in this test case.

llvm-svn: 251147
2015-10-23 20:37:51 +00:00
Evgeniy Stepanov 1e9aadba17 [msan] Re-submit test for process_vm_readv.
Includes a workaround for glibc < 2.15, which does not provide the
function under test.

llvm-svn: 251079
2015-10-23 00:00:22 +00:00
Evgeniy Stepanov 7b04acd28d [msan] Temporarily remove a failing test to fix the bot.
The test requires a newer glibc version that the one on the bot.

llvm-svn: 251077
2015-10-22 23:40:06 +00:00
Kostya Serebryany e3d25c3873 [sanitizer-coverage] introduce __sanitizer_get_total_unique_caller_callee_pairs
llvm-svn: 251071
2015-10-22 22:06:41 +00:00
Evgeniy Stepanov 0d933e0b27 [msan] Intercept process_vm_readv/writev.
llvm-svn: 251059
2015-10-22 20:35:42 +00:00
Yury Gribov 8da1408277 [asan] Get rid of UB in string tests. Patch by Max Ostapenko.
Differential revision: http://reviews.llvm.org/D13895

llvm-svn: 250998
2015-10-22 08:10:56 +00:00
Ivan Krasin cffe8caed3 Disabling speculative loads under asan.
Summary:
While instrumenting std::string with asan I discovered that speculative load might load data from poisoned region. Disabling all speculative loads for asan-annotated functions.

The test follows the std::string implementation.

Corresponding CL in llvm: http://reviews.llvm.org/D13264
Patch by Mike Aizatsky, the review page for the CL is http://reviews.llvm.org/D13265

Reviewers: aizatsky

Subscribers: kcc, llvm-commits

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

llvm-svn: 250837
2015-10-20 17:34:47 +00:00
Evgeniy Stepanov 0b98b27677 [msan] Intercept mincore.
llvm-svn: 250761
2015-10-19 23:39:11 +00:00
Evgeniy Stepanov cc25301092 [msan] Intercept pthread_getcancel*.
llvm-svn: 250752
2015-10-19 23:00:13 +00:00
Evgeniy Stepanov c7ee62c561 [msan] Add __msan_copy_shadow interface function.
This can be used to annotate copies of memory that are not observed by MSan.

llvm-svn: 250124
2015-10-12 23:20:24 +00:00
Evgeniy Stepanov f4ebc08831 [asan] Zero initialize sem_t in sem_init.
Old version of sem_init (GLIBC_2.0) fails to initialize parts of
sem_t that are used in sem_timedwait. This is fixed in GLIBC_2.1,
but since ASan interceptors downgrade sem_* to the oldest available
version, this can introduce bugs that are only present in sanitized
build. Workaround by zero-initializing sem_t in sem_init.

llvm-svn: 250113
2015-10-12 21:32:30 +00:00
Filipe Cabecinhas 150def9787 [ubsan] Invoke test program using %run.
llvm-svn: 250063
2015-10-12 16:33:40 +00:00
Reid Kleckner 8da160173c Remove the XFAIL for the C++ EH test
It works on Windows now.

llvm-svn: 249799
2015-10-09 01:33:15 +00:00
Evgeniy Stepanov b688a47963 New MSan mapping layout (compiler-rt part).
This is an implementation of
https://github.com/google/sanitizers/issues/579

It has a number of advantages over the current mapping:
* Works for non-PIE executables.
* Does not require ASLR; as a consequence, debugging MSan programs in
  gdb no longer requires "set disable-randomization off".
* Supports linux kernels >=4.1.2.
* The code is marginally faster and smaller.

This is an ABI break. We never really promised ABI stability, but
this patch includes a courtesy escape hatch: a compile-time macro
that reverts back to the old mapping layout.

llvm-svn: 249754
2015-10-08 21:35:34 +00:00
Renato Golin 814e5caebc [LSAN] Mark death callback as unstable while we investigate the cause in AArch64
llvm-svn: 249398
2015-10-06 13:29:44 +00:00
Daniel Sanders bb9c116165 [asan][mips] Fix ABI incompatibility crash in pthread_create() following r248325.
Like i386, Mips needs a versioned interceptor but must select GLIBC_2.2.

llvm-svn: 249307
2015-10-05 12:43:47 +00:00
Evgeniy Stepanov 06e338b403 [asan] Disable pthread_create_version test on mips.
llvm-svn: 249191
2015-10-02 21:23:53 +00:00
Evgeniy Stepanov 25c58d124b [asan] Fix asan_symbolize.py handling of non-existing paths
llvm-svn: 248962
2015-09-30 23:17:39 +00:00
Ivan Krasin 97746d75bb CFI: add a test from base-to-derived cast from the base destructor.
Summary: This adds an interesting bad cast case, originally found in https://crbug.com/537398.

Reviewers: kcc

Subscribers: pcc

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

llvm-svn: 248958
2015-09-30 23:08:55 +00:00
Evgeniy Stepanov 01e4c87a5a [msan] Disable allocator_mapping test on mips64 and aarch64.
llvm-svn: 248835
2015-09-29 22:24:57 +00:00
Alexey Samsonov 4133c18b1c [CFI] Make CFI tests require UBSan (for diagnostic mode).
CFI itself, on the other hand, doesn't require anything, including
sanitizer_common.

llvm-svn: 248830
2015-09-29 21:43:37 +00:00
Evgeniy Stepanov 7aba3960c7 [msan] Early allocator initialization.
Map MSan heap space early (in __msan_init) so that user code can not
accidentally (i.e. w/o MAP_FIXED) create a conflicting mapping.

llvm-svn: 248829
2015-09-29 21:28:54 +00:00
Renato Golin 9be32f6317 Add armhf as unstable runtime temporarily
llvm-svn: 248819
2015-09-29 18:35:55 +00:00
Dmitry Vyukov 2fe0efcc69 tsan: add test for issue #602
llvm-svn: 248522
2015-09-24 17:38:56 +00:00
Evgeniy Stepanov a7ecbe5685 [asan] Add missing -pthread in tests.
llvm-svn: 248332
2015-09-22 22:24:46 +00:00
Evgeniy Stepanov 9147de0ddf [asan] Versioned interceptor for pthread_create.
This fixes a crash in pthread_create on linux/i386 due to abi
incompatibility between intercepted and non-intercepted functions.

See the test case for more details.

llvm-svn: 248325
2015-09-22 21:34:44 +00:00
Renato Golin 7716df5b7d Disable final MSAN test in AArch64 to get the bots green
llvm-svn: 248014
2015-09-18 18:02:55 +00:00
Renato Golin 4610486e88 Disable one MSAN test in AArch64 until we have a proper fix
llvm-svn: 248008
2015-09-18 17:22:48 +00:00
Adhemerval Zanella dab7043d89 [compiler-rt] [sanitizer] Clean buildbot failures for aarch64
Currently aarch64 lacks instrumentation support for variadic arguments
for MSan.  This patch sets the UBSan tests that uses it as to require
stable-runtime and sets aarch64/ubsan as an unstable one.

llvm-svn: 247996
2015-09-18 15:48:32 +00:00
Evgeniy Stepanov 6e663a1e32 Revert "ubsan: Implement memory permission validation for vtables."
This reverts r247484 and two follow-up commits.
Breaks ppc and x86_64 sanitizer bots.

llvm-svn: 247921
2015-09-17 19:15:54 +00:00
Reid Kleckner 3e9d733e68 [Windows] xfail a test that uses C++ EH
llvm-svn: 247845
2015-09-16 20:32:22 +00:00
Adhemerval Zanella 19074450ee [MSan] Enable MSAN for aarch64
This patch enabled msan for aarch64 with 39-bit VMA and 42-bit VMA.
As defined by lib/msan/msan.h the memory layout used is for 39-bit is:

   00 0000 0000 - 40 0000 0000:  invalid
   40 0000 0000 - 43 0000 0000:  shadow
   43 0000 0000 - 46 0000 0000:  origin
   46 0000 0000 - 55 0000 0000:  invalid
   55 0000 0000 - 56 0000 0000:  app (low)
   56 0000 0000 - 70 0000 0000:  invalid
   70 0000 0000 - 80 0000 0000:  app (high)

And for 42-bit VMA:

   000 0000 0000 - 100 0000 0000:  invalid
   100 0000 0000 - 11b 0000 0000:  shadow
   11b 0000 0000 - 120 0000 0000:  invalid
   120 0000 0000 - 13b 0000 0000:  origin
   13b 0000 0000 - 2aa 0000 0000:  invalid
   2aa 0000 0000 - 2ab 0000 0000:  app (low)
   2ab 0000 0000 - 3f0 0000 0000:  invalid
   3f0 0000 0000 - 400 0000 0000:  app (high)

Most of tests are passing with exception of:

   * Linux/mallinfo.cc
   * chained_origin_limits.cc
   * dlerror.cc
   * param_tls_limit.cc
   * signal_stress_test.cc
   * nonnull-arg.cpp

The 'Linux/mallinfo.cc' is due the fact AArch64 returns the sret in 'x8'
instead of default first argument 'x1'.  So a function prototype that
aims  to mimic (by using first argument as the return of function) won't
work. For GCC one can make a register alias (register var asm ("r8")), but
for clang it detects is an unused variable and generate wrong code.

The 'chained_origin_limits' is probably due a wrong code generation,
since it fails only when origin memory is used
(-fsanitize-memory-track-origins=2) and only in the returned code
(return buf[50]).

The 'signal_streess_test' and 'nonnull-arg' are due currently missing variadic
argument handling in memory sanitizer code instrumentation on LLVM side.

Both 'dlerror' and 'param_tls_test' are unknown failures that require
further investigation.

All the failures are XFAIL for aarch64 for now.

llvm-svn: 247809
2015-09-16 15:12:25 +00:00
Naomi Musgrave 36597fa128 Explicit reference to bug highlighted by
test/msan/dtor-trivial.cpp. Runtime testing for poisoning
vtable pointer in dtor.

Summary: Runtime testing for vtable ptr poisoning in dtor.

Reviewers: eugenis, kcc

Subscribers: llvm-commits

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

Clean test case & comments.

Update tests for vptr poisoning order.

Simplify test to rely upon globals.

Assertions verify that vtable still accessible from dtors.

Testing linear inheritance and multiple inheritance for vtable poisoning.

Macros for testing expected failing functions.

Rename macros.

Removed xfail, modified FileCheck commands, to expect test to crash.

llvm-svn: 247763
2015-09-16 00:41:28 +00:00
Alexey Samsonov f23dee5408 [ASan] Add test for .preinit_array/.init_array/.fini_array sections.
llvm-svn: 247737
2015-09-15 23:06:17 +00:00
Peter Collingbourne dcba38a78b ubsan: Also disable vptr validation on powerpc64le.
llvm-svn: 247499
2015-09-12 05:24:44 +00:00
Peter Collingbourne e299bc51b6 ubsan: Disable vptr validation on powerpc64.
Should fix sanitizer-ppc64-linux1 bot.

llvm-svn: 247493
2015-09-12 00:08:28 +00:00
Peter Collingbourne cf303a4d8b ubsan: Implement memory permission validation for vtables.
If the pointer passed to the getVtablePrefix function was read from a freed
object, we may end up following pointers into objects on the heap and
printing bogus dynamic type names in diagnostics. However, we know that
vtable pointers will generally only point into memory mapped from object
files, not objects on the heap.

This change causes us to only follow pointers in a vtable if the vtable
and one of the virtual functions it points to appear to have appropriate
permissions (i.e. non-writable, and maybe executable), which will generally
exclude heap pointers.

Only enabled for Linux; this hasn't been tested on FreeBSD, and vtables are
writable on Mac (PR24782) so this won't work there.

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

llvm-svn: 247484
2015-09-11 22:18:35 +00:00
Peter Collingbourne 6f94087329 CFI: Run the tests only on supported architectures/OSs.
Specifically, only run the cfi-icall tests on x86/x86_64, and add
an XFAIL for darwin.

llvm-svn: 247325
2015-09-10 19:18:08 +00:00
Peter Collingbourne 1db3a448b5 CFI: Add diagnostic handler and tests for indirect call checker.
Differential Revision: http://reviews.llvm.org/D11858

llvm-svn: 247239
2015-09-10 02:18:02 +00:00
Alexey Samsonov 63eaeca7d0 [CMake] Remove all uses of LLVM_NATIVE_ARCH.
Instead, assume we're going to target triple specified by
COMPILER_RT_DEFAULT_TARGET_TRIPLE and build runtimes for this triple
(and hope that the host compiler can target them).

This will help users that use cross-compiler on their host to build
Clang that would work on a different architecture. This will also come in
handy if one would want to configure several compiler-rt build trees on
the same host, using just-built Clang that can target many
architectures.

This doesn't change the behavior in the default build configuration.

llvm-svn: 247099
2015-09-08 23:13:47 +00:00
Alexey Samsonov 0d0200d727 [CMake] Rename COMPILER_RT_TEST_TARGET_TRIPLE to more appropriate COMPILER_RT_DEFAULT_TARGET_TRIPLE.
llvm-svn: 247094
2015-09-08 22:48:35 +00:00
Naomi Musgrave 18203f763c Failing test highlighting no poisoning when destructor not declared.
Summary:
When destructor for a class is not declared, no destructor
is emitted, and members are not poisoned. Test case exhibits this
current bug in use-after-dtor implementation (detailed in
https://github.com/google/sanitizers/issues/596).

Reviewers: eugenis, kcc

Subscribers: llvm-commits

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

Rename test files.

llvm-svn: 247091
2015-09-08 22:41:50 +00:00
Kuba Brecka 6f7ef0ea3e Revert r246961 "[asan] Intercept and wrap XPC callback blocks".
There is a build failure for the simulator.

llvm-svn: 246967
2015-09-07 12:25:51 +00:00
Kuba Brecka dfaac293dc [asan] Intercept and wrap XPC callback blocks
On recent OS X systems, blocks used as callbacks for XPC events (set up e.g. via xpc_connection_set_event_handler) are not later executed via the public libdispatch API (dispatch_async, etc). Because we don't intercept the path where the block is executed, we can fail to register the newly created dispatch thread. To fix that, let's intercept libxpc's APIs that take a block as a callback handler, and let's wrap these blocks in the same way as we do for libdispatch API.

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

llvm-svn: 246961
2015-09-07 11:19:22 +00:00
Evgeniy Stepanov de77b1cdf3 [asan] Detect asanwrapper binary in android tests.
Tests need to be run either via asanwrapper or asanwrapper64
depending in the binary bitness. This matters when testing on an
aarch64 device.

llvm-svn: 246891
2015-09-04 22:39:21 +00:00
Evgeniy Stepanov 7dee008911 [asan] Disable array cookie test on ARM, enable on Android/x86.
The failure is caused by the missing implementation of array cookie
poisoning in Clang for ARMCXXABI and has nothing to do with Android
(and the test passes on Android/x86).

llvm-svn: 246832
2015-09-04 01:15:28 +00:00
Naomi Musgrave 8eb36d2210 Test triangle inheritance member poisoning.
Summary: Verify that all members are poisoned.

Reviewers: eugenis, kcc

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

Test virtual functions and virtual bases poisoning proper size.

Runtime testing of destroying diamond inheritance.

Explicit testing for 0 optimizations.

Simplify test to only test interesting values.

Test poisoning on multiple inheritance with nontrivial and trivial members.

Removed unnecessary header.

Testing (anonymous/)bit fields.

Revised object instantiation in test to avoid undefined behavior.

llvm-svn: 246817
2015-09-03 23:06:13 +00:00
Dmitry Vyukov 3464dac0ca tsan: speed up race deduplication
Race deduplication code proved to be a performance bottleneck in the past if suppressions/annotations are used, or just some races left unaddressed. And we still get user complaints about this:
https://groups.google.com/forum/#!topic/thread-sanitizer/hB0WyiTI4e4
ReportRace already has several layers of caching for racy pcs/addresses to make deduplication faster. However, ReportRace still takes a global mutex (ThreadRegistry and ReportMutex) during deduplication and also calls mmap/munmap (which take process-wide semaphore in kernel), this makes deduplication non-scalable.

This patch moves race deduplication outside of global mutexes and also removes all mmap/munmap calls.
As the result, race_stress.cc with 100 threads and 10000 iterations become 30x faster:

before:
real	0m21.673s
user	0m5.932s
sys	0m34.885s

after:
real	0m0.720s
user	0m23.646s
sys	0m1.254s

http://reviews.llvm.org/D12554

llvm-svn: 246758
2015-09-03 11:20:46 +00:00
Evgeniy Stepanov d67f1b9dbc [asan] Split a test in two.
wait3 is gone in android-21. Move it out of the common
(wait/waitpid/wait3) test, and mark as unsupported on Android.

llvm-svn: 246742
2015-09-03 01:26:30 +00:00
Evgeniy Stepanov afe6c1d466 [asan] Replace valloc with posix_memalign in test.
valloc is gone in android-21.

llvm-svn: 246741
2015-09-03 01:22:06 +00:00
Reid Kleckner b6f39cbba2 [windows] Add retries to cope with linker/filesystem flakiness
Hopefully this fixes PR24554, and we receive less build spam.

llvm-svn: 246708
2015-09-02 20:45:36 +00:00
Kostya Serebryany 94dd76aefa [tsan] workaround for a crash in deadlock detector, bug https://github.com/google/sanitizers/issues/594
llvm-svn: 246592
2015-09-01 21:36:18 +00:00
Reid Kleckner a71dabd591 Mark the log_path ubsan test as requiring a shell. It uses globs.
llvm-svn: 246566
2015-09-01 18:17:21 +00:00
Kuba Brecka b79932addf [asan] Fix the freopen interceptor to allow NULL instead of a filename
According to `man freopen`, passing NULL instead of a filename is valid, however the current implementation of the interceptor assumes this parameter is non-NULL. Let's fix that and add a test case.

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

llvm-svn: 246435
2015-08-31 12:41:55 +00:00
Adhemerval Zanella 15db6dc2fb [compiler-rt] [tsan] Enable TSan for AArch64/42-bit VMA
This patch adds support for tsan on aarch64-linux with 42-bit VMA
(current default config for 64K pagesize kernels).  The support is
enabled by defining the SANITIZER_AARCH64_VMA to 42 at build time
for both clang/llvm and compiler-rt.  The default VMA is 39 bits.

It also enabled tsan for previous supported VMA (39).

llvm-svn: 246330
2015-08-28 20:40:50 +00:00
Alexey Samsonov 53b8750e7d [Sanitizers] Make abort_on_error common flag.
Summary:
Teach all sanitizers to call abort() instead of _exit() after printing
an error report, if requested. This behavior is the default on Mac OS.

Reviewers: kcc, kubabrecka

Subscribers: llvm-commits

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

llvm-svn: 246205
2015-08-27 20:40:24 +00:00
Evgeniy Stepanov 533fde9f4d [sanitizer] Move sem_* to common interceptors.
llvm-svn: 246184
2015-08-27 18:51:18 +00:00
Reid Kleckner 255ee043cb Unit test the CRLF change to suppression parsing
It's a simpler, faster, and more portable.

llvm-svn: 246171
2015-08-27 18:05:33 +00:00
Reid Kleckner 766e507784 [windows] Avoid unix2dos, it seems to not work on our bot
llvm-svn: 246162
2015-08-27 16:56:10 +00:00
Reid Kleckner ac86c29bd0 Handle suppression files ending in CRLF (\r\n)
The gnuwin32 version of 'echo' appears to produce such files, causing a
test failure that only reproduced with gnuwin32.

llvm-svn: 246096
2015-08-26 22:23:50 +00:00
Alexey Samsonov 966eba0585 [Sanitizer] Test churn: use %env_tool_opts in sanitizer_common lit tests.
This follows the approach we use in ASan and UBSan lit tests to setup
tool options in a portable way, and to provide a nice way to specify
testsuite-wide defaults.

llvm-svn: 246058
2015-08-26 19:29:07 +00:00
Evgeniy Stepanov f8af87957c [msan] Regression test for PR24561.
Fixed in r245980.

llvm-svn: 245981
2015-08-25 22:20:15 +00:00
Alexey Samsonov 47aa53e91c [UBSan] Test churn: use the approach from r244839 and r245962 in UBSan lit tests.
Introduce %env_ubsan_opts= substitution instead of specifying
UBSAN_OPTIONS manually in the RUN-lines. This will come in handy
once we introduce some default UBSAN_OPTIONS for the whole testsuite
(for instance, make abort_on_error common option).

llvm-svn: 245967
2015-08-25 19:01:44 +00:00
Alexey Samsonov 1130681716 [ASan] More ASAN_OPTIONS churn: use %env_asan_opts where applicable.
Reviewers: filcab, rnk, kubabrecka

Subscribers: tberghammer, danalbert, srhines, llvm-commits

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

llvm-svn: 245962
2015-08-25 18:27:53 +00:00
Alexey Samsonov f3b9c895fa [UBSan] Add the ability to print more precise error kind in summary line.
Reviewers: rsmith, pcc

Subscribers: cfe-commits

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

llvm-svn: 245897
2015-08-24 23:18:49 +00:00
Alexey Samsonov eb4fe7883f [TSan] Support __sanitizer_set_death_callback().
llvm-svn: 245776
2015-08-22 01:07:02 +00:00
Alexey Samsonov fc95c85cb5 [LSan] Support __sanitizer_set_death_callback in standalone LSan.
llvm-svn: 245758
2015-08-21 23:00:30 +00:00
Chris Bieneman 2ac796d6cc [CMake] Need to filter out test architectures on ubsan as well.
llvm-svn: 245714
2015-08-21 18:06:00 +00:00
Josh Gao 1108ae03b1 Implement __aeabi_c{d,f}{cmpeq,cmple,rcmple}.
Summary: Implement more missing ARM EABI runtime functions.

Reviewers: rengolin, compnerd

Subscribers: pirama, srhines, danalbert, aemerson, llvm-commits

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

llvm-svn: 245648
2015-08-21 00:25:37 +00:00
Chris Bieneman 2335bb7e16 [CMake] Fixing r245581 based on feedback from Filcab.
llvm-svn: 245582
2015-08-20 17:46:58 +00:00