Commit Graph

952 Commits

Author SHA1 Message Date
Peter Collingbourne a68d90fa52 UBSan: Enable runtime library tests on Windows, and get most tests passing.
Specifically:

- Disable int128 tests on Windows, as MSVC cl.exe does not support
  int128, so we might not have been able to build the runtime
  with int128 support.

- XFAIL the vptr tests as we lack Microsoft ABI support.

- XFAIL enum.cpp as UBSan fails to add the correct instrumentation code
  for some reason.

- Modify certain tests that build executables multiple times to use
  unique names for each executable. This works around a race condition
  observed on Windows.

- Implement IsAccessibleMemoryRange for Windows to fix the last
  misaligned.cpp test.

- Introduce a substitution for testing crashes on Windows using
  KillTheDoctor.

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

llvm-svn: 241303
2015-07-02 22:08:38 +00:00
Evgeniy Stepanov b41e87c534 [asan] Suppress read_binary_name_regtest.c test failure on unsupported hosts.
read_binary_name_regtest.c requires seccomp kernel headers.
Make the test pass if <linux/seccomp.h> is missing.

llvm-svn: 241119
2015-06-30 21:28:55 +00:00
Dmitry Vyukov 1d9b5e6ece tsan: fix handling of condition variable destruction
POSIX states that "It shall be safe to destroy an initialized condition
variable upon which no threads are currently blocked", and later clarifies
"A condition variable can be destroyed immediately after all the threads
that are blocked on it are awakened) (in examples section). Tsan reported
such destruction as a data race.
Fixes https://llvm.org/bugs/show_bug.cgi?id=23616
Reviewed in http://reviews.llvm.org/D10693

llvm-svn: 241082
2015-06-30 17:23:29 +00:00
Alexander Potapenko 5e70fb13de [ASan] Add a regression test for r240960 (https://crbug.com/502974)
The test simulates a sandbox that prevents the program from calling readlink().
ASan is supposed to still be able to print the executable name regardless of that.

llvm-svn: 241072
2015-06-30 15:18:03 +00:00
Evgeniy Stepanov 8fee84d01e [asan] Re-enable clang_gcc_abi test at higher opt levels.
PR23971 is fixed.

llvm-svn: 240975
2015-06-29 18:05:31 +00:00
Dmitry Vyukov 189f061353 sanitizer_common: fix and re-enable signal_segv_handler test
struct sigaction was not initialized. As the result if SA_RESETHAND is set in sa_flags, then the handler is reset after first invocation leading to crash.
Initialize struct sigaction to zero.

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

llvm-svn: 240965
2015-06-29 16:31:10 +00:00
Dmitry Vyukov ffb551b2b0 tsan: implement suppressions for top frame only
The new suppression type is called "race_top" and is matched only against top frame in report stacks.
This is required for situations when we want to suppress a race in a "thread pool" or "event loop" implementation.
If we simply use "race:ThreadPool::Execute" suppression, that can suppress everything in the program.

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

llvm-svn: 240949
2015-06-29 14:38:31 +00:00
Dmitry Vyukov 29093488d8 tsan: fix flaky test
See the comment for explanation.

llvm-svn: 240943
2015-06-29 13:56:31 +00:00
Evgeniy Stepanov 8e449f6d9f [asan] Disable 3 tests on Android.
Different reasons for failing; see source file comments.

llvm-svn: 240858
2015-06-26 23:44:43 +00:00
Evgeniy Stepanov 8dbebeb53f [asan] Add -pie to uninstrumented executables on interface_test.cc
This helps Android (which only support PIE) and does not hurt anything else.

llvm-svn: 240857
2015-06-26 23:43:03 +00:00
Evgeniy Stepanov 77d543f756 [asan] Enable 2 tests on Android.
Due to bionic improvements and "recent" sized-delete changes in clang.

llvm-svn: 240856
2015-06-26 23:41:50 +00:00
Evgeniy Stepanov 4e78a248e2 [asan] Disable -O1,-O2,-O3 in clang_gcc_abi.cc test.
A workaround for PR23971.
Fixes the test on Android.

llvm-svn: 240855
2015-06-26 23:40:27 +00:00
Anna Zaks a16075cfc9 [asan] Do not unset DYLD_ROOT_PATH before calling atos on Darwin
We were unsetting DYLD_ROOT_PATH before calling atos on Darwin in order to
address it not working for symbolicating 32 bit binaries. (atos essentiall
tries to respawn as a 32 bit binary and it's disallowed to respawn if
DYLD_ROOT_PATH is set ... ) However, processes rely on having DYLD_ROOT_PATH
set under certain conditions, so this is not the right fix. In particular, this
always crashes when running ASanified process under the debugger in Xcode with
iOS simulator, which is a very important workflow for us to support.

This patch reverts the unsetting of the DYLD_ROOT_PATH. The correct fix to the
misbehavior on 32-bit binaries should happen inside atos.

http://reviews.llvm.org/D10722

llvm-svn: 240724
2015-06-25 23:36:21 +00:00
Dmitry Vyukov 7c63340586 tsan: fix handling of dup2
Previously tsan modelled dup2(oldfd, newfd) as write on newfd.
We hit several cases where the write lead to false positives:
1. Some software dups a closed pipe in place of a socket before closing
   the socket (to prevent races actually).
2. Some daemons dup /dev/null in place of stdin/stdout.
On the other hand we have not seen cases when write here catches real bugs.
So model dup2 as read on newfd instead.

llvm-svn: 240687
2015-06-25 20:32:04 +00:00
Alexey Samsonov a084e16e4b [CFI] Run tests that use cfi diagnostic mode only if cxxabi parts of UBSan are available.
llvm-svn: 240671
2015-06-25 18:45:30 +00:00
Evgeniy Stepanov 4b4a58ada4 [sanitizer] Disable signal_segv_handler test.
Random failures on the bots.

llvm-svn: 240668
2015-06-25 18:23:58 +00:00
Jay Foad 8677baf024 Enable memory sanitizer for PPC64
Summary:
This patch adds basic memory sanitizer support for PPC64. PR23219.

I have further patches ready to enable it in LLVM and Clang, and to fix
most of the many failing tests in check-msan.

Reviewers: kcc, willschm, samsonov, wschmidt, eugenis

Reviewed By: eugenis

Subscribers: wschmidt, llvm-commits

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

llvm-svn: 240623
2015-06-25 06:22:31 +00:00
Alexey Samsonov 3fa03e3e9d [CMake] Fix PR23539: Don't reference C++ ABI symbols prior to Mac OS 10.9.
Summary:
This patch implements step 1 from
https://llvm.org/bugs/show_bug.cgi?id=23539#c10

I'd appreciate if you could test it on Mac OS and verify that parts of UBSan
runtime that reference C++ ABI symbols are properly excluded, and fix ASan/UBSan
builds.

Test Plan: regression test suite

Reviewers: thakis, hans

Subscribers: llvm-commits, zaks.anna, kubabrecka

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

llvm-svn: 240617
2015-06-25 00:57:42 +00:00
Dmitry Vyukov d58df749c1 tsan: fix false positive between dlopen and dl_iterate_phdr
We see false reports between dlopen and dl_iterate_phdr.
This happens because tsan does not see dynamic linker
internal synchronization. Unpoison module names
in dl_iterate_phdr callback.

llvm-svn: 240576
2015-06-24 19:49:32 +00:00
Dmitry Vyukov c871c03550 tsan: don't print external PCs in reports
They are meaningless.

llvm-svn: 240539
2015-06-24 13:04:12 +00:00
Dmitry Vyukov 89e0d57157 tsan: fix unbounded memory consumption for large mallocs
This happens only in corner cases, but we observed this on a real app.
See the test for description of the exact scenario that lead to unbounded memory consumption.

llvm-svn: 240535
2015-06-24 11:51:41 +00:00
Pirama Arumuga Nainar 4a39e80809 Fix incorrect truncation at the overflow boundary
Summary:
This patch fixes incorrect truncation when the input wider value is
exactly 2^dstBits.  For that value, the overflow to infinity is not
correctly handled.  The fix is to replace a strict '>' with '>='.

Currently,
__truncdfsf2(340282366900000000000000000000000000000.0) returns infinity
__truncdfsf2(340282366920938463463374607431768211456.0) returns 0
__truncdfsf2(400000000000000000000000000000000000000.0) returns infinity

Likewise, __truncdfhf2 and __truncsfhf2 (and consequently gnu_f2h_ieee)
are discontinuous at 65536.0.

This patch adds tests for all three cases, along with adding a missing
header include to fp_test.h.

Reviewers: joerg, ab, srhines

Subscribers: llvm-commits

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

llvm-svn: 240450
2015-06-23 20:24:53 +00:00
Jay Foad 2aec6216cb [msan] Mark one test as only supported on x86
Summary: This test uses x86 intrinsics, so it can't work on other platforms.

Reviewers: garious, eugenis, samsonov

Reviewed By: samsonov

Subscribers: llvm-commits

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

llvm-svn: 240449
2015-06-23 20:17:45 +00:00
Alexey Samsonov 3959263545 Add -flto to clang flags for cfi tests.
llvm-svn: 240168
2015-06-19 19:48:40 +00:00
Peter Collingbourne 175d633271 Add control flow integrity diagnosis function to UBSan runtime library.
Also includes execution tests for the feature.

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

llvm-svn: 240111
2015-06-19 01:52:55 +00:00
Alexey Samsonov 2a567835d1 Revert "Revert "[CMake] LSan is not actually available on Darwin.""
Re-land fixed version of r239955.

llvm-svn: 240108
2015-06-19 01:34:06 +00:00
Evgeniy Stepanov 9a10674079 [msan] Intercept fopencookie.
https://code.google.com/p/memory-sanitizer/issues/detail?id=86

llvm-svn: 240107
2015-06-19 01:28:41 +00:00
Justin Bogner 66afb72e2a Revert "[CMake] LSan is not actually available on Darwin."
This change makes cmake fail to even run on Darwin with errors
evaluating "$<TARGET_OBJECTS:RTInterception.x86_64>".

This reverts r239955

llvm-svn: 239985
2015-06-18 03:39:51 +00:00
Alexey Samsonov 5cce9e1e59 [CMake] LSan is not actually available on Darwin.
llvm-svn: 239955
2015-06-17 22:24:44 +00:00
Peter Collingbourne 187bfddb12 SafeStack: XFAIL the pthread.c test on Darwin.
llvm-svn: 239841
2015-06-16 18:52:31 +00:00
Filipe Cabecinhas 65e703ac84 [ASan tests] Revert a bad change from r239754
Hopefully the last partial revert. Sorry about the noise.

llvm-svn: 239785
2015-06-15 23:44:53 +00:00
Filipe Cabecinhas 0ff92e6e3e [ASan tests] Leftover that didn't get reverted in r239754
llvm-svn: 239773
2015-06-15 22:19:47 +00:00
Filipe Cabecinhas 1b66f5dc82 [ASan tests] Use export, not env.
llvm-svn: 239771
2015-06-15 22:14:21 +00:00
Filipe Cabecinhas 9d8663f8d0 Revert "[ASan tests] Try to fix Windows buildbots due to r239754"
This reverts commit r239764 and the TestCases/Windows part of r239754.

llvm-svn: 239768
2015-06-15 21:49:35 +00:00
Filipe Cabecinhas 0470998860 [ASan tests] Try to fix Windows buildbots due to r239754
llvm-svn: 239764
2015-06-15 21:15:26 +00:00
Peter Collingbourne b64d0b1e6d Protection against stack-based memory corruption errors using SafeStack: compiler-rt runtime support library
This patch adds runtime support for the Safe Stack protection to compiler-rt
(see http://reviews.llvm.org/D6094 for the detailed description of the
Safe Stack).

This patch is our implementation of the safe stack on top of compiler-rt. The
patch adds basic runtime support for the safe stack to compiler-rt that
manages unsafe stack allocation/deallocation for each thread.

Original patch by Volodymyr Kuznetsov and others at the Dependable Systems
Lab at EPFL; updates and upstreaming by myself.

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

llvm-svn: 239763
2015-06-15 21:08:47 +00:00
Filipe Cabecinhas 91244924cb [ASan] Test churn for setting ASAN_OPTIONS=symbolize_vs_style=false
Summary:
This commit adds symbolize_vs_style=false to every instance of
ASAN_OPTIONS in the asan tests and sets
ASAN_OPTIONS=symbolize_vs_style=false in lit, for tests which don't set
it.

This way we don't need to make the tests be able to deal with both
symbolize styles.

This is the first patch in the series. I will eventually submit for the
other sanitizers too.

We need this change (or another way to deal with the different outputs) in
order to be able to default to symbolize_vs_style=true on some platforms.

Adding to this change, I'm also adding "env " before any command line
which sets environment variables. That way the test works on other host
shells, like we have if the host is running Windows.

Reviewers: samsonov, kcc, rnk

Subscribers: tberghammer, llvm-commits

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

llvm-svn: 239754
2015-06-15 20:43:42 +00:00
Ahmed Bougacha f190def830 [builtins] Hide long double fp_test.h helpers if it's not fp128.
Like we do for the various __*tf* tests, check that long double is the
128bit type we expect directly in the header. The latter is now used by
unrelated tests (__*hf* since r237161), and those tests will break for
no reason if uint128_t doesn't exist, and long double isn't fp128.

llvm-svn: 239630
2015-06-12 18:28:47 +00:00
Yury Gribov ef40f0bbff [ASan] Quick-fix tests for new string interceptors.
Patch by Maria Guseva.

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

llvm-svn: 239461
2015-06-10 07:16:02 +00:00
Anna Zaks dd9e6578f0 [asan] Fixup to r239134. This test does pass on darwin.
This should restore the darwin buildbot.

llvm-svn: 239364
2015-06-08 23:24:55 +00:00
Yury Gribov 2d45554b82 [ASan] Add process basename to log name and error message to
simplify analysis of sanitized systems logs.
    
Differential Revision: http://reviews.llvm.org/D7333

llvm-svn: 239134
2015-06-05 06:08:23 +00:00
Evgeniy Stepanov 8e27f59a1b [tsan] Disable a flaky test.
llvm-svn: 239063
2015-06-04 18:28:35 +00:00
Filipe Cabecinhas 094c04ec81 [Sanitizers] Add *SAN_OPTIONS to possibly_dangerous_env_vars
Summary:
This way, if they're set when running ninja check-ubsan (or another
sanitizer), they get cleared before we start invoking the programs.

Reviewers: samsonov, kcc

Subscribers: llvm-commits

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

llvm-svn: 238991
2015-06-04 00:12:55 +00:00
Tim Northover b1f5879f3a Tests: disable test of /proc filesystem on Darwin.
We don't have it. I'm not entirely sure "Posix" is a good name for that
directory, but perhaps we should see how it develops.

llvm-svn: 238874
2015-06-02 21:59:04 +00:00
Yury Gribov ddf646b8c7 [ASan] Fixed tests to pass on Darwin. Patch by Maria Guseva!
Differential Revision: http://reviews.llvm.org/D10159

llvm-svn: 238837
2015-06-02 14:59:26 +00:00
Justin Bogner ba6e2ae0c5 profile: Fix link errors in this test on darwin
llvm-svn: 238622
2015-05-29 22:41:25 +00:00
Evgeniy Stepanov 8e9c70be7f Add descriptive names to sanitizer entries in /proc/self/maps. Helps debugging.
This is done by creating a named shared memory region, unlinking it
and setting up a private (i.e. copy-on-write) mapping of that instead
of a regular anonymous mapping. I've experimented with regular
(sparse) files, but they can not be scaled to the size of MSan shadow
mapping, at least on Linux/X86_64 and ext3 fs.

Controlled by a common flag, decorate_proc_maps, disabled by default.

This patch has a few shortcomings:
* not all mappings are annotated, especially in TSan.
* our handling of memset() of shadow via mmap() puts small anonymous
  mappings inside larger named mappings, which looks ugly and can, in
  theory, hit the mapping number limit.

llvm-svn: 238621
2015-05-29 22:31:28 +00:00
Yury Gribov 9ebb303459 [ASan] Fix flaky tests (see https://llvm.org/bugs/show_bug.cgi?id=23230).
Patch by Maria Guseva!

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

llvm-svn: 238545
2015-05-29 06:45:13 +00:00
Yury Gribov 83aaa8e05c [ASan] Disable alloca tests on ARM targets due to flakiness.
llvm-svn: 238426
2015-05-28 14:29:12 +00:00
Yury Gribov 64c701b3f7 [ASan] XFAIL VLA tests on ARM and PowerPC. Patch by Max Ostapenko!
llvm-svn: 238409
2015-05-28 10:30:46 +00:00