Commit Graph

5955 Commits

Author SHA1 Message Date
Peter Collingbourne cc8bb21e59 sanitizer_common: Fix implementation of bit count operations on 64-bit Windows.
llvm-svn: 242002
2015-07-13 00:26:03 +00:00
Peter Collingbourne 23efcc8ed7 Temporarily disable check-sanitizer tests on 64-bit Windows.
llvm-svn: 241940
2015-07-10 20:35:53 +00:00
Alexey Samsonov f40c1076c9 [TSan] Fix dl_iterate_phdr callback for the case when info->dlpi_name is overwritten by user.
llvm-svn: 241876
2015-07-10 00:03:54 +00:00
Diego Novillo eae951415e Add support for generating profiles in a given directory.
When the file is initialized, this patch checks whether the path
specifies a directory. If so, it creates the directory tree before
truncating the file.

Use default.profdata instead of pgo-data for default indexed profile name.

llvm-svn: 241824
2015-07-09 17:21:52 +00:00
Peter Collingbourne cca0cb6ce2 UBSan: Simplify logic for locating the RTTI object.
The image-relative complete object locator contains a reference to itself,
which we can use to compute the image base without using VirtualQuery.

Spotted by David Majnemer.

llvm-svn: 241758
2015-07-08 23:22:39 +00:00
Kostya Serebryany 7f1e1f0f8e [asan] relax the test case to allow either 'malloc' or '__interceptor_malloc' ; PR22681
llvm-svn: 241755
2015-07-08 22:57:03 +00:00
Peter Collingbourne 702548d9ea CFI: Get check-cfi passing on Windows.
Specifically:

- Start using %expect_crash.

- Provide an implementation of __ubsan::getDynamicTypeInfoFromVtable
  for the Microsoft C++ ABI. This is all that is needed for CFI
  diagnostics; UBSan's -fsanitize=vptr also requires an implementation of
  __ubsan::checkDynamicType.

- Build the sanitizer runtimes against the release version of the C
  runtime, even in debug builds.

- Accommodate demangling differences in tests.

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

llvm-svn: 241745
2015-07-08 22:10:34 +00:00
Kuba Brecka 61db9ebdea [asan] Add missing $ASAN_OPTIONS to some test cases
Since http://reviews.llvm.org/D10294, ASan test cases now respect default env. options via `ASAN_OPTION=$ASAN_OPTIONS:additional_options=xxx`.  This patch adds this to a few test cases where it's still missing.

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

llvm-svn: 241571
2015-07-07 09:55:00 +00:00
Kuba Brecka 76cc55a94d [asan] Add OS X 10.11's new dyld interposition support
On OS X 10.11 (which is currently a public beta), the dynamic linker has been improved so that it doesn't require the use of DYLD_INSERT_LIBRARIES in order for interposition/wrappers to work. This patch adds support of this behavior into ASan – we no longer need to re-exec in case the env. variable is not set.

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

llvm-svn: 241487
2015-07-06 19:07:55 +00:00
Kuba Brecka f3a493638f [asan] Fix an OS X startup crash when an empty section is present
On OS X, when the main instrumented binary contains a custom section with zero length, ASan will crash (assert failure) early in the initialization.

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

llvm-svn: 241474
2015-07-06 17:17:06 +00:00
Jay Foad b120712b29 Enable this test for PPC64.
llvm-svn: 241400
2015-07-05 08:11:36 +00:00
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
Kuba Brecka 3d2ba47a90 [sanitizer] add #ifdefs around slow unwinder to fix OS X debug build
A recent change in slow unwinder causes the OS X build to fail when using COMPILER_RT_DEBUG=On. Let's fix this by #ifdef'ing it with #if SANITIZER_CAN_SLOW_UNWIND.

See http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20150622/284294.html

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

llvm-svn: 241261
2015-07-02 13:56:37 +00:00
Peter Collingbourne 23a410cc64 Add declaration of _ReadWriteBarrier. Fixes build of asan tests on Windows.
llvm-svn: 241227
2015-07-02 02:06:59 +00:00
Peter Collingbourne d3b9917d85 Re-apply r241217 with build fixes:
- Disable building of the interceptor library on 64-bit Windows.
- Mangle names in /alternatename directive for 32-bit Windows.

llvm-svn: 241224
2015-07-02 01:44:34 +00:00
Nico Weber 41acb31623 Revert r241217, it breaks the build on Windows.
llvm-svn: 241219
2015-07-02 01:10:03 +00:00
Peter Collingbourne 191116f3eb ubsan: Port runtime library to (32- and 64-bit) Windows.
Differential Revision: http://reviews.llvm.org/D10856

llvm-svn: 241217
2015-07-02 00:35:47 +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
Jay Foad 391e53812a Revert part of r240623 (Enable memory sanitizer for PPC64) because the
buildbots are still failing in check-ubsan.

llvm-svn: 241113
2015-06-30 20:30:19 +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 856b11199f [asan] Fix SanitizerCommon.PthreadDestructorIterations test on Android L.
On Android L, TSD destructors run 8 times instead of 4.
Back to 4 times on the current master branch (as well as on K).

llvm-svn: 240992
2015-06-29 20:28:55 +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
Alexander Potapenko 1669e68b57 [libsanitizer] Replace ReadBinaryName() with ReadBinaryNameCached(),
which caches the executable name upon the first invocation.
This is necessary because Google Chrome (and potentially other programs)
restrict the access to /proc/self/exe on linux.
This change should fix https://code.google.com/p/chromium/issues/detail?id=502974

llvm-svn: 240960
2015-06-29 15:58:16 +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
Jay Foad 55f65a3554 [msan] Fix infinite recursion when _Unwind_Backtrace calls memcpy
Summary:
On PPC64, half the msan tests fail with an infinite recursion through
GetStackTrace like this:

#0 __msan::GetStackTrace
#1 __msan_memcpy
#2 ?? () from /lib64/libgcc_s.so.1
#3 ?? () from /lib64/libgcc_s.so.1
#4 _Unwind_Backtrace
#5 __sanitizer::BufferedStackTrace::SlowUnwindStack
#6 __sanitizer::BufferedStackTrace::Unwind
#7 __msan::GetStackTrace
#8 __interceptor_calloc
#9 _dl_allocate_tls
#10 pthread_create@@GLIBC_2.17
#11 __interceptor_pthread_create
#12 main

The problem is that we call _Unwind_Backtrace to get a stack trace; but
_Unwind_Backtrace calls memcpy, which we intercept and try to get
another stack trace.

This patch fixes it in __msan_memcpy by skipping the stack trace if
IsInSymbolizer(). This works because GetStackTrace already creates a
SymbolizerScope to "block reports from our interceptors during
_Unwind_Backtrace".

Reviewers: samsonov, wschmidt, eugenis

Reviewed By: eugenis

Subscribers: llvm-commits

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

llvm-svn: 240878
2015-06-27 08:39:12 +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
Evgeniy Stepanov 2f58bb6a34 [asan] Disable glibc-specific code chunk on Android.
Fixes quarantine_size_mb.cc test on the Android bot.

llvm-svn: 240854
2015-06-26 23:39:23 +00:00
Evgeniy Stepanov 609af9098c [asan] Link sanitizer_common tests on Android as -pie.
llvm-svn: 240825
2015-06-26 20:39:30 +00:00
Alexey Samsonov 1ac144b51b [ASan] Clean up obsolete stats.
Remove stats that we no longer collect after the allocator change.
Use proper constant SizeClassMap::kNumClasses to fix potential buffer
overflow (https://code.google.com/p/address-sanitizer/issues/detail?id=397).

llvm-svn: 240816
2015-06-26 19:18:02 +00:00
Alexander Potapenko f4388a2ba4 [libsanitizer] Delete the unused GetBinaryName() function.
llvm-svn: 240767
2015-06-26 09:28:24 +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
Jay Foad 86269dc5d0 [msan] Teach sanitizers about the PPC64 ptrace syscall
Summary:
This fixes test/msan/Linux/syscalls.cc, and should also fix the ppc64
sanitizer buildbots which are currently failing in
"make check-sanitizer".

Reviewers: samsonov, wschmidt, eugenis

Reviewed By: eugenis

Subscribers: llvm-commits

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

llvm-svn: 240692
2015-06-25 20:50:18 +00:00
Jay Foad 198337bf42 [msan] Fix SetShadow for mappings at the end of the application address space
Summary:
On PPC64 if you disable ASLR (or run under gdb) you're likely to see
mmap returning a mapping right at the end of the application address
space region. This caused SetShadow to call MEM_TO_SHADOW() on the
last+1 address in the region, which seems wrong to me; how can
MEM_TO_SHADOW() distinguish this from the first address in the following
region?

Fixed by only calling MEM_TO_SHADOW() once, on the start address.

Reviewers: samsonov, wschmidt, eugenis

Reviewed By: eugenis

Subscribers: llvm-commits

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

llvm-svn: 240690
2015-06-25 20:47:59 +00:00
Alexey Samsonov 368d7855da [Sanitizer] Set minimum supported Mac OS X version to 10.9, if it wasn't specified explicitly.
-fsanitize=vptr is a UBSan feature that doesn't work on older Mac OS X
versions, and we don't want to penalize users that use modern OS with
default configuration. Those who want to target older OS versions, can
specify that versions explicitly.

llvm-svn: 240688
2015-06-25 20:43:35 +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
Dmitry Vyukov b89a69dac6 tsan: merge function definition and declaration
llvm-svn: 240633
2015-06-25 11:45:45 +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
Chris Bieneman a9e77abc68 One more change required to build the sanitizers for iOS.
Summary: _Unwind_Backtrace is not available on iOS, so we should ifdef out the posix implementations of BufferedStackTrace::SlowUnwindStack and BufferedStackTrace::SlowUnwindStackWithContext on iOS.

Reviewers: samsonov

Reviewed By: samsonov

Subscribers: llvm-commits

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

llvm-svn: 240586
2015-06-24 20:13:44 +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
Peter Collingbourne 19e86199f1 SafeStack: Add another missing header to try to fix FreeBSD build.
llvm-svn: 240564
2015-06-24 18:16:05 +00:00
Peter Collingbourne 8454044b1f SafeStack: Add #include of <stdint.h>.
Should fix the FreeBSD build.

llvm-svn: 240555
2015-06-24 17:23:13 +00:00
Dmitry Vyukov b086a70206 asan: fix 32-bit build
llvm-svn: 240541
2015-06-24 13:27:56 +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
Peter Collingbourne adbde27d2d Update SafeStack TODO in the safestack.cc
This patch clarifies the TODO note at the top of safestack.cc and brings
it more in sync with what we (the CPI team) actually plan to work on in
the future.

Patch by Volodymyr Kuznetsov!

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

llvm-svn: 240473
2015-06-23 22:26:48 +00:00
Chris Bieneman f1ba141041 Working on reconciling out-of-tree patches to compiler-rt for building for iOS.
Summary:
This is one of many changes needed for compiler-rt to get it building on iOS.

Darwin doesn't have _Unwind_VRS_Get, instead use _Unwind_GetIP directly.

Note: this change does not enable building for iOS, as there are more changes to come.

Reviewers: kubabrecka, bogner, samsonov

Reviewed By: samsonov

Subscribers: samsonov, llvm-commits

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

llvm-svn: 240470
2015-06-23 21:39:57 +00:00
Chris Bieneman d1a1444c1a Working on reconciling out-of-tree patches to compiler-rt for building for iOS.
Summary:
This is one of many changes needed for compiler-rt to get it building on iOS.

This change ifdefs out headers and functionality that aren't available on iOS, and adds support for iOS and the iOS simulator to as an.

Note: this change does not enable building for iOS, as there are more changes to come.

Reviewers: glider, kubabrecka, bogner, samsonov

Reviewed By: samsonov

Subscribers: samsonov, zaks.anna, llvm-commits

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

llvm-svn: 240469
2015-06-23 21:39:54 +00:00
Chris Bieneman 04f0643a76 Working on reconciling out-of-tree patches to compiler-rt for building for iOS.
Summary:
This is one of many changes needed for compiler-rt to get it building on iOS.

This change ifdefs out headers and functionality that aren't available on iOS.

Note: this change does not enable building for iOS, as there are more changes to come.

Reviewers: glider, kubabrecka, bogner, samsonov

Reviewed By: samsonov

Subscribers: samsonov, llvm-commits

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

llvm-svn: 240468
2015-06-23 21:39:52 +00:00
Chris Bieneman e13272a008 Working on reconciling out-of-tree patches to compiler-rt for building for iOS.
Summary:
This is one of many changes needed for compiler-rt to get it building on iOS.

This change does the following:
- Don't include crt_externs on iOS (it isn't available)
- Support ARM thread state objects

Note: this change does not enable building for iOS, as there are more changes to come.

Reviewers: glider, kubabrecka, bogner, samsonov

Reviewed By: samsonov

Subscribers: samsonov, aemerson, llvm-commits

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

llvm-svn: 240467
2015-06-23 21:39:49 +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
Frederic Riss 66c868ce27 [Sanitizers] Pass the correct arch to the symbolizer for x86_64h
I have no idea how to directly test that as it depends on a particular
(micro-)architecure of the host processor.
Combined with llvm's r240339 this should fix issues people might have
be seeing intermitently on Darwin haswell machines (the symbolizer
would use the wrong slice of the binary, thus potentially resolving
to the wrong symbol).

llvm-svn: 240379
2015-06-23 05:35:19 +00:00
Alexey Samsonov c05dd074e7 [CMake] Respect the value of -mmacosx-version-min flag.
Make sure that sanitizer runtimes target OS X version provided in
-mmacosx-version-min= flag. Enforce that it should be at least 10.7.

llvm-svn: 240356
2015-06-22 23:30:28 +00:00
Alexey Samsonov 3959263545 Add -flto to clang flags for cfi tests.
llvm-svn: 240168
2015-06-19 19:48:40 +00:00
Filipe Cabecinhas 7af0a1cb84 CMake: Stop using LLVM's custom parse_arguments. NFC
Summary:
Use CMake's cmake_parse_arguments() instead.
It's called in a slightly different way, but supports all our use cases.
It's in CMake 2.8.8, which is our minimum supported version.

CMake 3.0 doc (roughly the same. No direct link to 2.8.8 doc):
http://www.cmake.org/cmake/help/v3.0/module/CMakeParseArguments.html?highlight=cmake_parse_arguments

Since I was already changing these calls, I changed ARCH and LIB into
ARCHS and LIBS to make it more clear that they're lists of arguments.

Reviewers: eugenis, samsonov, beanz

Subscribers: llvm-commits

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

llvm-svn: 240120
2015-06-19 03:39:24 +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
Dmitry Vyukov 70dd0e2087 tsan: mark meta shadow as NOHUGEPAGE
Meta shadow is compressing and we don't flush it,
so it makes sense to mark it as NOHUGEPAGE to not over-allocate memory.
On one program it reduces memory consumption from 5GB to 2.5GB.

llvm-svn: 240028
2015-06-18 16:57:37 +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 b412c47934 [CMake] Remove redundant checks in TSan CMakeLists.txt
llvm-svn: 239956
2015-06-17 22:24:49 +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
Peter Collingbourne 8727100328 SafeStack: Adjust condition for COMPILER_RT_HAS_SAFESTACK to fix sanitizer builds.
llvm-svn: 239840
2015-06-16 18:52:28 +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
Chris Bieneman 6bd006f31a [CMake] Cleanup add_compiler_rt_object_library to be platform-agnostic
Summary:
This change takes darwin-specific goop that was scattered around CMakeLists files and spread between add_compiler_rt_object_library and add_compiler_rt_darwin_object_library and moves it all under add_compiler_rt_object_library.

The goal of this is to try to push platform handling as low in the utility functions as possible.

Reviewers: rnk, samsonov

Reviewed By: rnk, samsonov

Subscribers: rnk, rsmith, llvm-commits

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

llvm-svn: 239498
2015-06-10 23:55:07 +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
Evgeniy Stepanov cbed1e4f79 [asan] Disable asan for aarch64.
lib/Target/AArch64/AArch64FrameLowering.cpp:370: virtual void llvm::AArch64FrameLowering::emitPrologue(llvm::MachineFunction&, llvm::MachineBasicBlock&) const: Assertion `!(NeedsRealignment && NumBytes==0) && "NumBytes should never be 0 when realignment is needed"' failed.

llvm-svn: 239352
2015-06-08 21:07:24 +00:00
Evgeniy Stepanov 24196c505b [asan] Enable AArch64 build of ASan runtime and tests.
llvm-svn: 239322
2015-06-08 18:19:26 +00:00
Evgeniy Stepanov e33f64f682 [asan] Fix Android build for API >= 21.
/code/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc:971:8: error: address of function 'dl_iterate_phdr' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
  if (!dl_iterate_phdr)
      ~^~~~~~~~~~~~~~~
/code/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc:971:8: note: prefix with the address-of operator to silence this warning
  if (!dl_iterate_phdr)
       ^
       &

llvm-svn: 239321
2015-06-08 18:15:52 +00:00
Evgeniy Stepanov 572cd900b2 [asan] Fix build of AsanNoinstTest on Android.
Some of the asan-ubsan build changes were not replicated in the android branch in CMakeLists.

llvm-svn: 239320
2015-06-08 18:03:33 +00:00
Alexey Samsonov 9f97bf0943 [ASan] Bump maximum allowed malloc() size in ASan allocator to 1Tb.
1Tb of RAM ought to be enough for anybody.

llvm-svn: 239187
2015-06-05 20:50:02 +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
Yury Gribov e244b49f2c [ASan] Fix Darwin and Windows builds.
llvm-svn: 239027
2015-06-04 07:56:19 +00:00
Yury Gribov c019a57099 [ASan] Make binary name reader cross-platform.
Differential Revision: http://reviews.llvm.org/D10213

llvm-svn: 239020
2015-06-04 07:29:43 +00:00
Yury Gribov c5243f0c6a [ASan] Move ASan runtime library self-checks to a more appropriate place.
llvm-svn: 239018
2015-06-04 07:23:09 +00:00
Filipe Cabecinhas 215046bf98 [sanitizer_common] Added VS-style output for source locations
Summary:
With this patch, we have a flag to toggle displaying source locations in
the regular style:
file:line:column

or Visual Studio style:
file(line,column)

This way, they get picked up on the Visual Studio output window and one
can double-click them to get to that file location.

Reviewers: samsonov, rnk

Subscribers: llvm-commits

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

llvm-svn: 239000
2015-06-04 01:20:06 +00:00
Evgeniy Stepanov 1b3d46ec30 [asan] Fix undefined MAP_NORESERVE on FreeBSD.
llvm-svn: 238995
2015-06-04 00:42:15 +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
Evgeniy Stepanov 42fb96652b [sanitizer] Add -lrt to dyndd link line.
llvm-svn: 238626
2015-05-29 22:57:15 +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
Reid Kleckner ea09c99a4c Use sanitizer_atomic_clang.h with clang-cl instead of the MSVC variant
llvm-svn: 238585
2015-05-29 17:56:39 +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
Evgeniy Stepanov bab1a075df [asan] Add new(unsigned int) to ASan interface list.
Also, sized-delete with size_t == unsigned int.
These guys appear when building for Android with gnu-stl.

Fixes a number of ASan tests in that particular configuration.

llvm-svn: 238484
2015-05-28 20:37:50 +00:00
Ed Maste 3fa1b65c1c Use /usr/bin/env to find python
Python may not be /usr/bin/python on some systems. For example, on
FreeBSD it will be /usr/local/bin/python.

Reviewers: samsonov
Differential Revision: http://reviews.llvm.org/D9914

llvm-svn: 238428
2015-05-28 14:53:14 +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
Yury Gribov 73570f4323 [ASan] Add new interceptors to asan_win_dll_thunk.cc to fix build errors on Windows.
Patch by Maria Guseva!

llvm-svn: 238407
2015-05-28 10:21:59 +00:00
Yury Gribov 0ca65fd83d [sanitizer] More string interceptors: strstr, strcasestr, strspn, strcspn, strpbrk.
Patch by Maria Guseva.

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

llvm-svn: 238406
2015-05-28 09:24:33 +00:00
Yury Gribov 63d9764585 [ASan] New approach to dynamic allocas unpoisoning. Patch by Max Ostapenko!
Differential Revision: http://reviews.llvm.org/D7098

llvm-svn: 238401
2015-05-28 07:49:05 +00:00
Evgeniy Stepanov 1f1d9f27fd [asan] Fix build dependency issues with ASan version list file.
CMake pre-3.1 has a bug where a shared library depending on a custom_target
does not really depend on it.

This commit implements a hilariously ugly workaround for this problem, see
code comments for more details.

llvm-svn: 238367
2015-05-27 22:38:01 +00:00
Diego Novillo c88d5b6acd Test case for PR 23499.
llvm-svn: 238338
2015-05-27 17:03:26 +00:00
Evgeniy Stepanov d99717226d [msan] Fix mmap test on Fedora.
llvm-svn: 238226
2015-05-26 18:02:54 +00:00
Evgeniy Stepanov 45328240dc [msan] Mprotect all inaccessible memory regions.
Fix 2 bugs in memory mapping setup:
- the invalid region at offset 0 was not protected because mmap at
  address 0 fails with EPERM on most Linux systems. We did not
  notice this because the check condition was flipped: the code was
  checking that mprotect has failed. And the test that was supposed
  to catch this was weakened by the mitigations in the mmap
  interceptor.
- when running without origins, the origin shadow range was left
  unprotected.

The new test ensures that mmap w/o MAP_FIXED always returns valid
application addresses.

llvm-svn: 238109
2015-05-24 02:47:59 +00:00
Kostya Serebryany 05425a88cd [dfsan] ignore more __sanitizer callbacks
llvm-svn: 238085
2015-05-23 01:56:39 +00:00
Saleem Abdulrasool a3b3952ccd builtins: mark functions as aapcs on Windows
Windows does not use AAPCS, but rather AAPCS-VFP, and thus the functions which
are assumed to be AAPCS will cause invalid argument setup.  Ensure that the
functions are marked as AAPCS.

llvm-svn: 238056
2015-05-22 21:47:24 +00:00
Nick Kledzik 506813892e [darwin] fix libcompiler_rt.dylib build
The dylib build of compiler-rt has been broken on darwin since the
directory restructuring to push some things down into /builtins/.

llvm-svn: 237848
2015-05-20 22:37:46 +00:00
Reid Kleckner 868a6c3023 Revert some of "Silence some CMake 3.3 dev warnings in compiler-rt"
This reverts part of r237808.

The CMP0057 warnings came from an old development build of CMake that
nobody else has. We don't need the cruft.

llvm-svn: 237819
2015-05-20 18:39:59 +00:00
Reid Kleckner aa9029691f Silence some CMake 3.3 dev warnings in compiler-rt
Fix a trivial instance of CMP0054 that came up on llvmdev.

The other warnings were CMP0057, which is about using the same file as a
MAIN_DEPENDENCY multiple times.  The old behavior hasn't been a problem
yet, so I silenced the warning and filed PR23595 to document the issue
if someone cares.

llvm-svn: 237808
2015-05-20 16:56:17 +00:00
Peter Collingbourne c6c660b3dd Factor out LTO detection to common configuration.
This will allow us to test other sanitizers with LTO.

llvm-svn: 237747
2015-05-19 23:50:13 +00:00
Peter Collingbourne 47b4e4ca01 CFI: Remove <utility> include.
It is unused, and causes a test failure on Darwin.

llvm-svn: 237746
2015-05-19 23:50:11 +00:00
Reid Kleckner 1cdd948f5b [ASan/Win] Add DLL thunk for new coverage hook
Should fix dll_host.cc test failing on bots.

llvm-svn: 237725
2015-05-19 21:02:23 +00:00
Sagar Thakur 3ee5bd9377 [sanitizer][MIPS] Add --target flag for MIPS32
Without the --target flag, clang uses the mips64 triple which selects the n64 abi. We need to add --target=mips-linux-gnu, so that clang can select the correct abi for mips32r2.

Reviewers: dsanders, kcc, samsonov
Subscribers: llvm-commits, mohit.bhakkad, jaydeep
Differential Revision: http://reviews.llvm.org/D9249

llvm-svn: 237675
2015-05-19 09:07:37 +00:00
Evgeniy Stepanov 270c5257e6 [asan] Disable static-tls test on PowerPC.
llvm-svn: 237534
2015-05-17 05:24:09 +00:00
Evgeniy Stepanov 7f6290ca9a [sanitizer] Recognize static TLS in __tls_get_addr interceptor.
Current code tries to find the dynamic TLS header to the left of the
TLS block without checking that it's not a static TLS allocation.

llvm-svn: 237495
2015-05-16 00:34:15 +00:00
Kostya Serebryany 7747762df9 [tsan] deflakify one more tsan test
llvm-svn: 237387
2015-05-14 20:27:12 +00:00
Ahmed Bougacha c9fa0b8e21 [Builtins] Wire half-precision conversions through cc_kext makefiles.
Kernel side of r237329.

llvm-svn: 237330
2015-05-14 02:21:02 +00:00
Ahmed Bougacha a5d1a91163 [Builtins] Wire half-precision conversions through Darwin makefiles.
Follow-up to r237161, modeled after r236805.

Note that arm64 is omitted on purpose, as the conversions are supported
natively there.

llvm-svn: 237329
2015-05-14 01:47:32 +00:00
Ahmed Bougacha 9a43d5be2f [Builtins] Implement f2h/h2f by jumping to trunc/extend.
Follow-up to r237161; seems like we can't use aliases, but we
can do better than duplicating the bodies, especially when that
body, after inlining, isn't as small as it looks.

Better approaches welcome.  Perhaps the best thing is just to have
an #ifndef __APPLE__ over the GNUEABI names, since they're not used
there.

llvm-svn: 237323
2015-05-14 00:50:28 +00:00
Ismail Pazarbasi 0da8da5898 Include missing 'sanitizer_platform_limits_posix.h'
Unbreak Mac builds. `#include` seems to be forgotten during staging.

llvm-svn: 237190
2015-05-12 21:30:16 +00:00
Ismail Pazarbasi 6fb3b4ba89 Call system's sigfillset and sigprocmask functions from sanitizers
Reviewers: kcc, glider, dvyukov

Subscribers: llvm-commits

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

llvm-svn: 237177
2015-05-12 20:56:44 +00:00
Ismail Pazarbasi b981dc8479 Sanitizers: Implement `GetRSS` on Mac OS X
Reviewers: kcc, glider, dvyukov

Subscribers: llvm-commits

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

llvm-svn: 237173
2015-05-12 20:47:21 +00:00
Ahmed Bougacha f1ac850e77 [Builtins] Implement half-precision conversions.
Mostly uninteresting, except:
- in __extendXfYf2, when checking if the number is normal, the old
  code relied on the unsignedness of src_rep_t, which is a problem
  when sizeof(src_rep_t) < sizeof(int): the result gets promoted to
  int, the signedness of which breaks the comparison.
  I added an explicit cast; it shouldn't affect other types.
- we can't pass __fp16, so src_t and src_rep_t are the same.
- the gnu_*_ieee symbols are simply duplicated definitions, as aliases
  are problematic on mach-o (where only weak aliases are supported;
  that's not what we want).

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

llvm-svn: 237161
2015-05-12 18:33:42 +00:00
Sergey Matveev f57fb6ce1a [sanitizer] Update "sancov.py missing" to allow __sanitizer_cov_with_check().
llvm-svn: 237149
2015-05-12 16:46:54 +00:00
Sergey Matveev 2680fe5f07 [sanitizer] Override pipefail in coverage-missing test.
This should finally fix it.

llvm-svn: 237147
2015-05-12 16:32:41 +00:00
Sergey Matveev 1a66c0ba53 [sanitizer] Re-enable a broken test with debug output.
llvm-svn: 237137
2015-05-12 14:43:31 +00:00
Evgeniy Stepanov d7b3ef65bb [asan] Disable coverage-missing test failing on the bots.
llvm-svn: 237049
2015-05-11 21:16:18 +00:00
Alexey Samsonov c200b5c6ea [UBSan] Add missing header that defines SANITIZER_CAN_USE_PREINIT_ARRAY
Otherwise this compile definition was undefined, and .preinit_array
was never used on the platforms that support it.

llvm-svn: 237045
2015-05-11 21:06:49 +00:00
Viktor Kutuzov 104a383e12 [Msan] Fix the if_indextoname.cc test to pass on FreeBSD
Differential Revision: http://reviews.llvm.org/D9456

llvm-svn: 236999
2015-05-11 14:46:16 +00:00
Kostya Serebryany 8fd66a71c4 [asan/fuzzer] define a dummy weak __sanitizer_cov_trace_cmp
llvm-svn: 236907
2015-05-08 21:32:03 +00:00
Sergey Matveev 42cc8fa592 [sanitizer] Attempt to fix the test for missing coverage script.
llvm-svn: 236877
2015-05-08 16:30:01 +00:00
Sagar Thakur 3e493037be [TSan][MIPS] XFAIL long jump tests for MIPS64
Mark longjmp tests as XFAIL because longjmp assembly for mips is not yet implemented.

Reviewers: dsanders, dvyukov, samsonov
Subscribers: llvm-commits, mohit.bhakkad, jaydeep
Differential Revision: http://reviews.llvm.org/D9526

llvm-svn: 236847
2015-05-08 12:58:03 +00:00
Sagar Thakur 6c253006b8 [ASAN] Use regex for addresses in kernel_area.cc test
This test was failing on mips because mips addresses are 40-bit long.
Using regex for address solves this issue.

Reviewers: dsanders, kcc, samsonov
Subscribers: llvm-commits, mohit.bhakkad, jaydeep
Differential Revision: http://reviews.llvm.org/D9516

llvm-svn: 236844
2015-05-08 12:47:10 +00:00
Viktor Kutuzov b0d28db6f1 [Msan] Fix the report-demangling.cc test to pass on FreeBSD
Differential Revision: http://reviews.llvm.org/D9554

llvm-svn: 236833
2015-05-08 12:10:46 +00:00
Viktor Kutuzov 7d5dfe1f34 [Msan] Make the obstack.cc test Linux-specific
Differential Revision: http://reviews.llvm.org/D9552

llvm-svn: 236831
2015-05-08 12:07:20 +00:00
Justin Bogner fa7525935b builtins: Implement the functions from stdatomic.h
Talking to John and Doug, we concluded that these functions from
stdatomic really do belong here in compiler-rt rather than in libc,
since the compiler owns stdatomic.h and these need to refer to
clang-specific builtins. Nonetheless, I've only added these on darwin
for now - other platforms should probably do the same unless their
libc does implement these functions.

llvm-svn: 236805
2015-05-08 05:39:05 +00:00
Alexey Samsonov 8e5e8fb2f3 [SanitizerCoverage] Upgrade lit tests to new -fsanitize-coverage= flags.
llvm-svn: 236796
2015-05-07 23:20:47 +00:00
Viktor Kutuzov d046d24461 Intercept scandir() on FreeBSD
Committed unreviewed with premission.

llvm-svn: 236720
2015-05-07 12:14:32 +00:00
Viktor Kutuzov 03a909f4b6 Intercept rand_r() on FreeBSD
Committed unreviewed with premission.

llvm-svn: 236719
2015-05-07 12:11:10 +00:00
Viktor Kutuzov 28c99980e6 [Msan] Make the mallinfo.cc test Linux-specific
Differential Revision: http://reviews.llvm.org/D9461

llvm-svn: 236718
2015-05-07 12:06:35 +00:00
Viktor Kutuzov bea3ca2abf [Msan] Make the ioctl_sound.cc test Linux-specific
Differential Revision: http://reviews.llvm.org/D9460

llvm-svn: 236717
2015-05-07 12:03:07 +00:00
Kostya Serebryany 13c03581ac Add dfsan_weak_hook_memcmp
Summary:
Add a weak hook to be called from dfsan's custom memcmp.
The primary user will be lib/Fuzzer.
If this works well we'll add more hooks (strcmp, etc).

Test Plan: Will be covered by lib/Fuzzer tests.

Reviewers: pcc

Reviewed By: pcc

Subscribers: llvm-commits

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

llvm-svn: 236679
2015-05-07 00:04:39 +00:00
Kostya Serebryany a86398e3fd Add api_list entries for the dfsan-based fuzzer
Summary: Add api_list entries for the dfsan-based fuzzer

Test Plan: covered by check-fuzzer

Reviewers: pcc

Reviewed By: pcc

Subscribers: llvm-commits

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

llvm-svn: 236657
2015-05-06 22:41:34 +00:00
Sergey Matveev a4cf7d71b8 [sanitizer] Restrict the missing coverage test to x86/x86_64.
Contrary to my hopes, it didn't magically work on other platforms.

llvm-svn: 236645
2015-05-06 21:50:42 +00:00
Sergey Matveev c2de346e48 [sanitizer] Extend sancov.py to show which PCs are missing from coverage.
Example usage:

sancov.py print a.out.1234.sancov | sancov.py missing a.out

llvm-svn: 236637
2015-05-06 20:48:29 +00:00
Evgeniy Stepanov 6153377219 [asan] Fall back to /proc/$PID/maps on Android L.
dl_iterate_phdr is somewhat broken in L (see the code for details).
We add runtime OS version detection and fallback to /proc/maps on L or earlier.
This fixes a number of ASan tests on L.

llvm-svn: 236628
2015-05-06 18:55:31 +00:00
Viktor Kutuzov 179ceff160 [Msan] Fix the mmap_below_shadow.cc test to pass on FreeBSD
Differential Revision: http://reviews.llvm.org/D9462

llvm-svn: 236582
2015-05-06 09:31:33 +00:00
Viktor Kutuzov 385d3f2241 [Msan] Fix the ioctl_custom.cc test to pass on FreeBSD
Differential Revision: http://reviews.llvm.org/D9459

llvm-svn: 236581
2015-05-06 09:28:48 +00:00
Viktor Kutuzov a26d2d4d5e [Msan] Fix the initgroups.cc test to build on FreeBSD
Differential Revision: http://reviews.llvm.org/D9458

llvm-svn: 236580
2015-05-06 09:26:35 +00:00
Viktor Kutuzov d04e0d7292 [Msan] Fix the ifaddrs.cc test to build and pass on FreeBSD
Differential Revision: http://reviews.llvm.org/D9457

llvm-svn: 236579
2015-05-06 09:24:02 +00:00
Sagar Thakur 26f165b04e [ASan][MIPS] Fix null_deref.cc test on MIPS64
Symbol for pc used in ucontext->uc_mcontext was wrong.

Reviewers: dsanders, kcc, samsonov
Subscribers: llvm-commits, mohit.bhakkad, jaydeep
Differential Revision: http://reviews.llvm.org/D9246

llvm-svn: 236572
2015-05-06 06:53:09 +00:00
Sagar Thakur 1d2854477c [sanitizer][MIPS] Implement clone for MIPS
Reviewers: kcc, samsonov, earthdok
Subscribers: dsanders, jaydeep, Anand.Takale, mohit.bhakkad, llvm-commits
Differential Revision: http://reviews.llvm.org/D8318

llvm-svn: 236570
2015-05-06 05:38:21 +00:00
Evgeniy Stepanov ce29096614 [asan] Fix dynamic-runtime tests.
They are not part of check-all :(

This change adds sized-delete operators to the version list, and disables the
hack that excluded versioned symbols from the dynamic list - this is not an
issue in this case.

llvm-svn: 236559
2015-05-06 00:29:57 +00:00
Evgeniy Stepanov 8af114d93c [asan] Fix compiler-rt build.
i386 runtime library was accidentally using the x86_64 version script without a dependency.

llvm-svn: 236556
2015-05-05 23:13:50 +00:00
Evgeniy Stepanov e8b9d791c2 [asan] Use a version script to limit the symbols exported by the ASan shared runtime library.
llvm-svn: 236551
2015-05-05 22:51:35 +00:00
Kostya Serebryany f3343c5b38 [asan] fix IsDeadlySignal
llvm-svn: 236545
2015-05-05 21:38:50 +00:00
Evgeniy Stepanov 91960900f8 Build ASan runtime library with -z global on Android.
llvm-svn: 236537
2015-05-05 20:13:39 +00:00
Reid Kleckner 60bdf6e4c0 Disable exceptions with Clang on Windows in lib/sanitizer-common/tests
While I'm here, fix a copy-paste bug so we get debug info for these
tests.

llvm-svn: 236505
2015-05-05 16:52:50 +00:00
Dmitry Vyukov da6d5b919d tsan: add memory access functions that accept pc
This is required for Java support, as real PCs don't work for Java.

llvm-svn: 236484
2015-05-05 08:09:46 +00:00
Kostya Serebryany b044353bb2 [asan] under handle_abort=1 option intercept SIGABRT in addition to SIGSEGV/SIGBUS. Among other things this will allow to set up a death callback for SIGABRT and thus properly handle assert() in lib/Fuzzer
llvm-svn: 236474
2015-05-05 01:37:33 +00:00
Reid Kleckner 4fe30a06b1 Fix Windows coverage test with lit shell
llvm-svn: 236446
2015-05-04 19:41:58 +00:00
Reid Kleckner 3d6011fbef Disable exceptions for clang-compiled unittest code on Windows
llvm-svn: 236357
2015-05-01 22:23:56 +00:00
Derek Schuff de036eb170 Fix float->uint conversion for inputs less than 0
Summary:
The spec for these functions says that they should return 0 in this case but
this regressed in r234148. That revision essentially delegates the conversion
to the hardware, but that has different behavior on different platforms (e.g.
it is wrong on x86).

Also fix a typo in the name of __fixunsdfti

Test Plan: The existing unit tests now pass

Reviewers: joerg, howard.hinnant

Subscribers: llvm-commits

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

llvm-svn: 236319
2015-05-01 16:02:16 +00:00
Evgeniy Stepanov b0707833a1 [asancov] Fix coverage reserving 4x the necessary amount of memory on fork.
llvm-svn: 236294
2015-05-01 00:40:42 +00:00
Alexey Samsonov 085bede949 [UBSan] Make stacktrace-matching CHECK-lines in tests Linux-specific.
Darwin doesn't yet allow to print stack trace, as it lacks the slow
unwinder. This is one more attempt to fix vptr.cpp on Mac OS X.

llvm-svn: 236195
2015-04-30 01:21:57 +00:00
Justin Bogner 2d2faae647 profile: Use unique directory for tests that write default profile file
Fix a couple of new tests that were reverted because they were causing
intermittent test failures since they were writing the same default
"default.profraw" file. Fixed by creating a unique directory and
running tests in that directory.

Patch by Teresa Johnson. Thanks!

llvm-svn: 236168
2015-04-29 21:56:35 +00:00
Alexey Samsonov 3965cdeb39 [UBSan] Disable vptr.cpp on Darwin again.
llvm-svn: 236165
2015-04-29 21:51:23 +00:00
Alexey Samsonov 299c21474c [UBSan] Various improvements to vptr.cpp test case
* Remove __ubsan_default_options, so that test would work on Darwin
* Fix unintentional undefined behavior in the code (missing return)
* Build the test with -fno-sanitize-recover to distinguish expected
  failures and expected passes by return code.

llvm-svn: 236152
2015-04-29 20:39:12 +00:00
Alexey Samsonov ff46ebe5a4 [UBSan] Add a testcase for __ubsan_default_options() function.
llvm-svn: 236151
2015-04-29 20:39:10 +00:00
Ahmed Bougacha 69b5f93cb5 Re-XFAIL UBSan vptr testcase on darwin.
Partial revert of r235961; the test still fails on Green Dragon bots.

llvm-svn: 236135
2015-04-29 17:49:05 +00:00
Dmitry Vyukov 7d6d737693 tsan: add another test for setuid
llvm-svn: 236130
2015-04-29 17:22:43 +00:00
Renato Golin 0ac9031fa1 Revert 2 tests from "Tests for r236055."
This partially reverts commit r236056, as the two tests were using the same
names and, when executed in parallel, were having intermittent failures.

llvm-svn: 236101
2015-04-29 13:40:57 +00:00
Eric Christopher 4b3dd38ce0 Tests for r236055.
Patch by Teresa Johnson.

llvm-svn: 236056
2015-04-28 22:56:57 +00:00
Eric Christopher d641b53f93 This change is the first of 3 patches to add support for specifying
the profile output from the command line via -fprofile-instr-generate=<path>,
where the specified output path/file will be overridden by the
LLVM_PROFILE_FILE environment variable.

Several changes are made to the runtime to support this:

Add a new interface __llvm_profile_override_default_filename that will
set the profile output filename, but allows LLVM_PROFILE_FILE to override.
This is the interface used by the new option.

Refactor the pid-expansion done for LLVM_PROFILE_FILE into a separate
routine that can be shared by the various filename setting routines
(so that the filename from the option can also use the "%p" syntax).

Move the truncation into setFilename, and only truncate if there is a
new filename specified (to maintain support for appending to the same
profile file in the case of multiple shared objects built with profiling).

Move the handling for a NULL filename passed to __llvm_profile_set_filename and
__llvm_profile_override_default_filename into the new setFilenamePossiblyWithPid
routine. This now correctly resets the output file to default.profraw
instead of NULL.
The handling for a null LLVM_PROFILE_FILE (which should not reset) is done
by caller setFilenameFromEnvironment.

Patch by Teresa Johnson.

llvm-svn: 236055
2015-04-28 22:54:51 +00:00
Evgeniy Stepanov f483a8a9d0 [asan] Use dl_iterate_phdr on Android.
It's available on Android/ARM starting with API 21 (L).

llvm-svn: 236014
2015-04-28 18:50:32 +00:00
Dmitry Vyukov 25c94eb152 tsan: fix a bug memory access handling
We incorrectly replaced shadow slots
when the new value is not stronger than the old one.
The bug can lead to false negatives.
The bug was detected by Go race test suite:
https://github.com/golang/go/issues/10589

llvm-svn: 236008
2015-04-28 18:08:42 +00:00
Viktor Kutuzov 86e0249235 [Msan] Fix the getline.cc test to pass on FreeBSD
Differential Revision: http://reviews.llvm.org/D9251

llvm-svn: 235975
2015-04-28 10:23:52 +00:00
Alexey Samsonov 09bff88fc4 [UBSan] Fix CMake rules for tests after r235954.
Make sure we don't run tests under TSan and MSan if they are
unavailable.

llvm-svn: 235962
2015-04-28 01:33:56 +00:00
Alexey Samsonov 4df0ebef47 Address old FIXMEs in UBSan test cases.
llvm-svn: 235961
2015-04-28 01:29:36 +00:00
Alexey Samsonov dc99a9c7a1 [TSan] Attempt to fix old Makefile build.
llvm-svn: 235960
2015-04-28 01:27:17 +00:00
Alexey Samsonov 72078b3cff Export __ubsan_* symbols from MSan and TSan runtimes.
llvm-svn: 235958
2015-04-28 01:20:34 +00:00
Alexey Samsonov b3053d9cbe Allow UBSan+MSan and UBSan+TSan combinations (Clang part).
Embed UBSan runtime into TSan and MSan runtimes in the same as we do
in ASan. Extend UBSan test suite to also run tests for these
combinations.

llvm-svn: 235954
2015-04-28 00:56:48 +00:00
Evgeniy Stepanov 948a4bbc92 [asan] Fix ASan build on Android/AArch64.
The build for aarch64 is not enabled in cmake/config-ix.cmake yet.

llvm-svn: 235944
2015-04-27 23:49:39 +00:00
Alexey Samsonov 98d79dace3 [UBSan] Reenable ASan+UBSan tests on Darwin now that PR21112 is fixed.
llvm-svn: 235929
2015-04-27 22:09:27 +00:00
Alexey Samsonov 56d6fc81a5 Introduce tsan_cxx and msan_cxx libraries (compiler-rt part).
For now tsan_cxx and msan_cxx contain only operator new/delete
replacements. In the future, when we add support for running UBSan+TSan
and UBSan+MSan, they will also contain bits ubsan_cxx runtime.

llvm-svn: 235928
2015-04-27 22:08:09 +00:00
Alexey Samsonov f430205b82 [TSan] Prepare TSan tests for splitting tsan_cxx library.
llvm-svn: 235927
2015-04-27 22:08:08 +00:00
Alexey Samsonov 042a069b25 [MSan] Prepare for splitting msan_new_delete.cc into a separate library. NFC.
llvm-svn: 235926
2015-04-27 22:08:04 +00:00
Alexey Samsonov 0eafe5df71 [TSan] Move new/delete interceptors into a separate source file. NFC.
llvm-svn: 235906
2015-04-27 19:33:55 +00:00
Viktor Kutuzov 78206c5b7e [Msan] Fix the iconv.cc test to build and pass on FreeBSD
Differential Revision: http://reviews.llvm.org/D9252

llvm-svn: 235799
2015-04-25 11:07:05 +00:00
Daniel Sanders 0568283e69 [asan] Print SHADOW_SCALE and SHADOW_GRANULARITY as decimal values.
Summary:
During the review of http://reviews.llvm.org/D9199 where I had originally
changed the debug_mapping.cc test to accept hexadecimal values, we realized
that SHADOW_SCALE and SHADOW_GRANULARITY ought to be printed as decimal values.
This patch makes that change.

This patch also adds a '0x' prefix to the SHADOW_OFFSET to make it clear that
it is hexadecimal while the other two are decimal.

Reviewers: kcc, timurrrr, samsonov

Reviewed By: timurrrr, samsonov

Subscribers: samsonov, llvm-commits, sagar

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

llvm-svn: 235798
2015-04-25 10:57:35 +00:00
Timur Iskhodzhanov aac51934cf [ASan/Win] Increase the size of the PC array for coverage on Windows
llvm-svn: 235779
2015-04-24 21:24:51 +00:00
Alexey Samsonov 5e0774631a [LSan] Add function attribute forgotten in r235728.
llvm-svn: 235761
2015-04-24 19:45:46 +00:00
Sergey Matveev cbdd0dc88a [lsan] Add an interface function for on-demand leak checking.
Summary:
Add an interface function which can be used to periodically trigger
leak detection in a long-running process.

NB: The meaning of the kIgnored tag has been changed to allow easy clean-up
between subsequent leak checks. Previously, this tag was applied to explicitly
ignored (i.e. with __lsan_disable() or __lsan_ignore_object()) chunks *and* any
chunks only reachable from those. With this change, it's only applied to
explicitly ignored chunks.

Reviewers: samsonov

Reviewed By: samsonov

Subscribers: llvm-commits

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

llvm-svn: 235728
2015-04-24 16:53:15 +00:00
Sergey Matveev 4fedac85ee Revert r235726 "interface"
Accidentally committed from local branch. :(

llvm-svn: 235727
2015-04-24 16:51:21 +00:00
Sergey Matveev a409f28b8e interface
llvm-svn: 235726
2015-04-24 16:49:04 +00:00
Derek Schuff eb0ebc367e Add COMPILER_RT_ABI attribute to declarations of builtin functions in unittests
Summary:
This makes their local declarations match their definitions for ARM targets,
where they have a different calling convention.

This really only affects functions that use floating point types (since the
runtime functions use soft-float, and some targets may default to hard-float)
but it seemed good to make it uniform and do the int-only ones too.

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

llvm-svn: 235722
2015-04-24 15:45:57 +00:00
Viktor Kutuzov 53e047de9e [Msan] XFAIL the ftime.cc test on FreeBSD
Differential Revision: http://reviews.llvm.org/D9222

llvm-svn: 235704
2015-04-24 07:54:38 +00:00
Viktor Kutuzov 0e15144ba1 [Msan] Fix the backtrace.cc tests to build and pass on FreeBSD
Differential Revision: http://reviews.llvm.org/D9221

llvm-svn: 235703
2015-04-24 07:52:47 +00:00
Viktor Kutuzov 8dee8575c6 [Sanitizers] Do not call internal_sigdelset() on non-Linux
Differential Revision: http://reviews.llvm.org/D9220

llvm-svn: 235701
2015-04-24 07:48:26 +00:00
Jay Foad fed74298cb [Sanitizer] Fix getpwnam test on ppc64le Fedora 21.
Summary:
On ppc64le Fedora 21, getpwnam_r("no-such-user", ...) returns ENOENT
instead of 0. Tolerate this in the test case.

Reviewers: eugenis

Reviewed By: eugenis

Subscribers: llvm-commits

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

llvm-svn: 235654
2015-04-23 22:20:33 +00:00
Alexey Samsonov 26856434d2 [ASan] Relax test modified in r235540 to pacify ARM buildbots.
llvm-svn: 235619
2015-04-23 18:43:08 +00:00
Daniel Sanders 9316d89d55 [asan] debug_mapping.cc should also pass when the leading digit of SHADOW_SCALE is hexadecimal.
Summary:
Previously the CHECK directive for SHADOW_SCALE only matched decimal digits
causing it to match '7' on x86_64 instead of the whole value.

This fixes a failure on mips-linux-gnu targets where the leading digit is 'a'.

Reviewers: kcc, sagar, timurrrr

Reviewed By: timurrrr

Subscribers: llvm-commits

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

llvm-svn: 235594
2015-04-23 13:23:21 +00:00
Timur Iskhodzhanov ac990bfcd3 [Sanitizer coverage] Print out the error number if OpenFile fails
llvm-svn: 235593
2015-04-23 13:18:50 +00:00
Timur Iskhodzhanov d0be0a9897 [ASan/Win] Initialize sandbox-related stuff when asked to
llvm-svn: 235591
2015-04-23 12:58:11 +00:00
Timur Iskhodzhanov 8a67368cc5 [ASan/Win] Don't forget to set *last_error if OpenFile fails
llvm-svn: 235590
2015-04-23 12:57:29 +00:00
Dmitry Vyukov 3658f6fcc4 tsan: support setuid call
Currently the call hangs because the background thread
does not handle SIGSETXID signal.

llvm-svn: 235581
2015-04-23 09:33:27 +00:00
Alexey Samsonov 8c80e7420a [UBSan] Unify the way we report overflow in increment/decrement operator.
llvm-svn: 235569
2015-04-23 01:50:56 +00:00
Alexey Samsonov 434984ef58 [UBSan] Make sure proper error summary is printed for -fsanitize=float-cast-overflow.
float-cast-overflow handler doesn't have source location provided by the
compiler, but we still have *some* source location if we have a
symbolizer.

llvm-svn: 235567
2015-04-23 01:08:31 +00:00
Alexey Samsonov 9e463ba35d [ASan] Print global registration site in init-order-checker reports.
llvm-svn: 235540
2015-04-22 20:30:19 +00:00
Alexey Samsonov e74ec45b88 [ASan] Refactor functions searching/describing globals. NFC.
llvm-svn: 235539
2015-04-22 20:30:15 +00:00
Daniel Sanders 7ea4cfcf83 [ubsan] Stop cast-overflow.cpp test leaking undefined behaviour into the exit code.
Summary:
ubsan was correctly catching the undefined behaviour but lit's shell was
failing the test anyway because the exit code was non-zero as a result of the
undefined behaviour.

This fixes the test on a mips-linux-gnu target.

Reviewers: samsonov

Reviewed By: samsonov

Subscribers: samsonov, llvm-commits, rsmith, sagar

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

llvm-svn: 235518
2015-04-22 16:14:01 +00:00
Sergey Matveev f8d5251dad [sanitizer] Plug a memory leak in symbolization code.
llvm-svn: 235411
2015-04-21 20:05:10 +00:00
Daniel Sanders ffa272ebbb [mips] Support building compiler-rt with gcc.
Summary:
This will allow us to enable it on the buildbot (and then enable a
sanitizer buildbot).

The problem is that gcc for Mips does not accept -m32/-m64 like clang does.
We therefore need to use the nearest equivalent -mips32r2/-mips64r2. We must
also specify -mabi=64 in the -mips64r2 case since gcc's default ABI has
traditionally been N32 whereas clang's is N64.

Reviewers: sagar

Reviewed By: sagar

Subscribers: llvm-commits, samsonov, kcc, mohit.bhakkad, Anand.Takale, sagar

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

llvm-svn: 235299
2015-04-20 12:44:01 +00:00
Viktor Kutuzov aff5bb0518 [Asan] Link lit tests shared libraries with -Wl,z,origin on FreeBSD
Differential Revision: http://reviews.llvm.org/D8834

llvm-svn: 235297
2015-04-20 12:25:11 +00:00
Dmitry Vyukov 3ff1c381e0 tsan: deflake a test
llvm-svn: 235294
2015-04-20 10:35:21 +00:00
Dmitry Vyukov 8586e2352b tsan: fix handling of pthread_detach
Fixes https://llvm.org/bugs/show_bug.cgi?id=23235

If pthread_create is followed by pthread_detach,
the new thread may not acquire synchronize with
the parent thread.

llvm-svn: 235293
2015-04-20 10:35:10 +00:00
Hal Finkel 0423483bab Make ubsan respect log_path
As with the other sanitizers, it is desirable to allow ubsan's output to be
redirected to somewhere other than stderr (and into per-process log files).

llvm-svn: 235277
2015-04-19 20:16:13 +00:00
Bob Wilson a2f65bd047 Include __mulodi4 in the 32-bit ARM versions of libclang_rt.cc_kext.a.
This is needed when building the Darwin kernel with
-fsanitize=undefined-trap. rdar://problem/12783702

llvm-svn: 235270
2015-04-19 04:09:44 +00:00
Sagar Thakur bcc495abc8 test commit
llvm-svn: 235176
2015-04-17 10:14:16 +00:00
Dmitry Vyukov 57f2e64c06 tsan: fix parsing of second_deadlock_stack flag
It was broken during flag parsing refactoring.
Enable test for the flag.

llvm-svn: 234878
2015-04-14 10:32:33 +00:00
Timur Iskhodzhanov 3d6c6fbef2 Cast an argument to mprotect syscall to uptr to fix X32
llvm-svn: 234748
2015-04-13 12:13:03 +00:00
Dimitry Andric 66749021d4 Make check_custom_wrappers.sh work on FreeBSD
Summary:
When running the compiler-rt testsuite on FreeBSD (it didn't matter which version), I always got the same error result:

    FAILED: cd /home/dim/obj/llvm-234092-trunk-freebsd10-amd64-ninja-rel-1/projects/compiler-rt/lib && LLVM_CHECKOUT=/home/dim/src/llvm/trunk SILENT=1 TMPDIR= PYTHON_EXECUTABLE=/usr/local/bin/python2.7 COMPILER_RT=/home/dim/src/llvm/trunk/projects/compiler-rt /home/dim/src/llvm/trunk/projects/compiler-rt/lib/sanitizer_common/scripts/check_lint.sh
    The following differences between the implemented custom wrappers and the tests have been found:
    --- /tmp/tmp.vPFEefvclf 2015-04-04 17:11:44.996734563 +0200
    +++ /tmp/tmp.NbIuvjxKEe 2015-04-04 17:11:45.044734647 +0200
    @@ -1,52 +0,0 @@
    -calloc
    -clock_gettime
    -ctime_r
    -dfsan_set_write_callback
    -dl_iterate_phdr
    -dlopen
    -fgets
    -fstat
    -get_current_dir_name
    -getcwd
    -gethostname
    -getpwuid_r
    -getrlimit
    -getrusage
    -gettimeofday
    -inet_pton
    -localtime_r
    -memchr
    -memcmp
    -memcpy
    -memset
    -nanosleep
    -poll
    -pread
    -pthread_create
    -read
    -sched_getaffinity
    -select
    -sigaction
    -sigemptyset
    -snprintf
    -socketpair
    -sprintf
    -stat
    -strcasecmp
    -strchr
    -strcmp
    -strcpy
    -strdup
    -strlen
    -strncasecmp
    -strncmp
    -strncpy
    -strrchr
    -strstr
    -strtod
    -strtol
    -strtoll
    -strtoul
    -strtoull
    -time
    -write

After some investigation, it turns out to be due to the regex used for search test_ symbols in lib/dfsan/scripts/check_customer_wrappers.sh:

    grep -E "^\\s*test_.*\(\);" ${DFSAN_CUSTOM_TESTS}

This uses \s to search for whitespace at start of line, but support for \s was only introduced in GNU grep v2.5.4-112-gf979ca0, while both FreeBSD and OSX only have grep 2.5.1 (the last version released under GPLv2).

I propose to change \s into [[:space:]], which is the more portable notation.

Test Plan: Run regression tests, and see that they work now. :)

Reviewers: pcc, samsonov, emaste

Reviewed By: emaste

Subscribers: llvm-commits, emaste

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

llvm-svn: 234704
2015-04-12 10:54:46 +00:00
Kuba Brecka 93c6a668fc [Sanitizer] Merge POSIXSymbolizer and WinSymbolizer
The two subclasses of Symbolizer now only define two virtual functions, PlatformDemangle and PlatformPrepareForSandboxing. Let's make these non-virtual and directly defined by individual platforms.

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

llvm-svn: 234690
2015-04-11 17:16:25 +00:00
Alexander Kornienko d829812f65 Use 'override/final' instead of 'virtual' for overridden methods
The patch is generated using clang-tidy misc-use-override check.

This command was used:

  tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py \
    -checks='-*,misc-use-override' -header-filter='llvm|clang' -j=32 -fix \
    -format

llvm-svn: 234680
2015-04-11 02:44:24 +00:00
Lorenzo Martignoni 4879003022 Extend s{,n}printf custom wrappers to support '*' in the format specifiers
Differential Revision: http://reviews.llvm.org/D8966

llvm-svn: 234633
2015-04-10 20:58:28 +00:00
Timur Iskhodzhanov bd989e78f1 [ASan] Use a better name for a function parameter
llvm-svn: 234604
2015-04-10 15:31:16 +00:00
Timur Iskhodzhanov ea1f332b79 Split Mprotect into MmapNoAccess and MprotectNoAccess to be more portable
On Windows, we have to know if a memory to be protected is mapped or not.
On POSIX, Mprotect was semantically different from mprotect most people know.

llvm-svn: 234602
2015-04-10 15:02:19 +00:00
Dmitry Vyukov 4bf08947a1 [sanitizer][MIPS] Fix warnings on MIPS
Fixed:
- stack frame size warning.
- msse3 flag unused warning.
- GoTsanRuntimeCheck dependency warning reported by cmake.

Change by Sagar Thakur
Reviewed in http://reviews.llvm.org/D8963

llvm-svn: 234579
2015-04-10 09:45:22 +00:00
Peter Collingbourne 8f9a3f2d7e Revert r234477, "Differential Revision: http://reviews.llvm.org/D7249"
Should unbreak fuzzer buildbot.

llvm-svn: 234542
2015-04-09 22:42:01 +00:00
Timur Iskhodzhanov 8f40f03024 [ASan/Win] Add a test that makes sure coverage works at least in the simple cases
llvm-svn: 234496
2015-04-09 15:58:38 +00:00
Timur Iskhodzhanov 007435c1b7 [ASan/Win] Add more support for file operations
llvm-svn: 234494
2015-04-09 15:25:21 +00:00
Timur Iskhodzhanov 4eb084cda3 Use error_t rather than int in a couple of places where we handle files
llvm-svn: 234491
2015-04-09 14:49:53 +00:00
Timur Iskhodzhanov a6600a974a Use RenameFile instead of internal_rename in non-POSIX code
llvm-svn: 234490
2015-04-09 14:45:17 +00:00
Timur Iskhodzhanov e8a6fbbfd3 Use WriteToFile instead of internal_write in non-POSIX code
llvm-svn: 234487
2015-04-09 14:11:25 +00:00
Timur Iskhodzhanov 2b391694bf Use ReadFromFile instead of internal_read in non-POSIX code
llvm-svn: 234485
2015-04-09 13:38:14 +00:00
Timur Iskhodzhanov 5df4d0471f Move more POSIX-specific functions to sanitizer_posix.h
llvm-svn: 234482
2015-04-09 12:54:06 +00:00
Timur Iskhodzhanov 864308a78d Introduce CloseFile to be used instead of internal_close on non-POSIX
llvm-svn: 234481
2015-04-09 12:37:05 +00:00
Timur Iskhodzhanov 1b2ff68408 Replace a hard-coded constant with a named one
llvm-svn: 234479
2015-04-09 12:20:02 +00:00
Lorenzo Martignoni 59886f3c1a Differential Revision: http://reviews.llvm.org/D7249
llvm-svn: 234477
2015-04-09 11:42:33 +00:00
Kuba Brecka 2aa8c8fd17 [Sanitizer] Get rid of PlatformGetListOfModules
Moving the implementation of several functions from sanitizer_symbolizer.cc into sanitizer_symbolizer_libcdep.cc.

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

llvm-svn: 234472
2015-04-09 09:37:46 +00:00
Yury Gribov 8e49b47e0a [ASan] Only include rpc headers if they are available.
Reviewed at http://reviews.llvm.org/D8698

llvm-svn: 234470
2015-04-09 08:06:49 +00:00
Mohit K. Bhakkad 0eccfdc655 [Compiler-rt][MIPS] Fix for asan test suite build on mips64/mips64el
Patch by Sagar Thakur

Reviewers: dsanders
llvm-svn: 234468
2015-04-09 06:58:32 +00:00
Timur Iskhodzhanov c2c9ea5525 [Sanitizer RT] Get rid of internal_isatty
llvm-svn: 234423
2015-04-08 17:42:57 +00:00
Timur Iskhodzhanov 3745303c5b Move some POSIX-specific functions from sanitizer_libc.h to a new sanitizer_posix.h
llvm-svn: 234418
2015-04-08 17:08:24 +00:00
Timur Iskhodzhanov daa9e2d4e8 [Sanitizers] Make OpenFile more portable
llvm-svn: 234410
2015-04-08 16:03:22 +00:00
Dmitry Vyukov 8e39c404a0 tsan: handle async signals while blocked in pthread_cond_wait
Fixes https://code.google.com/p/thread-sanitizer/issues/detail?id=91

llvm-svn: 234394
2015-04-08 07:48:52 +00:00
Dmitry Vyukov 1e5b9f4131 sanitizer: new "strict_string_checks" run-time flag
This patch is related to Issue 346: moar string interceptors: strstr, strcasestr, strcspn, strpbrk
As was suggested in original review http://reviews.llvm.org/D6056 a new "strict_string_checks" run-time flag introduced.
The flag support applied for existing common, asan, msan and tsan interceptors. New asan tests added.

Change by Maria Guseva reviewed in http://reviews.llvm.org/D7123

llvm-svn: 234187
2015-04-06 18:00:26 +00:00
Timur Iskhodzhanov 1931b62632 Minor follow-up fix to r234150
llvm-svn: 234151
2015-04-06 12:54:06 +00:00
Timur Iskhodzhanov b97bcc4981 [ASan] Unify handling of loaded modules between POSIX and Windows
Reviewed at http://reviews.llvm.org/D8805

llvm-svn: 234150
2015-04-06 12:49:30 +00:00
Sergey Dmitrouk f3206d6278 Add hard float versions of FP to LL conversions
This adds hard-float implementation for the following builtins:

* __fixdfdi()
* __fixsfdi()
* __fixunsdfdi()
* __fixunssfdi()

The soft-float implementation does never raise floating point
exceptions, which doesn't allow clients to detect floating point
conversion errors.

I must mention that I had to refer to libgcc's implementation to
write these functions.

Related unit-tests of compiler-rt passed with these changes.

Patch was somewhat out-dated, so was updated locally without any
functional changes.

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

llvm-svn: 234148
2015-04-06 11:54:51 +00:00
Alexander Potapenko d403b29254 [ASan] Do not print thread IDs and stacks for unknown threads.
llvm-svn: 234147
2015-04-06 10:32:45 +00:00
Dmitry Vyukov 19300f856b tsan: fix munmap interceptor
MetaMap::ResetRange/FreeRange rounds the range up to at least kMetaShadowSize.
This is requried for e.g. free(malloc(0)). However, munmap returns EINVAL
and do not unmap any memory when length arguments is equal to 0.
So don't free meta shadow in this case as well.

llvm-svn: 234145
2015-04-06 07:57:32 +00:00
Justin Bogner 7759f1899e Add missing include
llvm-svn: 234037
2015-04-03 19:10:35 +00:00
Justin Bogner 8e1a2a3277 profile: Protect .gcda output with flock
This avoids crashing or corrupting data if multiple concurrent
processes write to the same .gcda file. This is hard to test, since
the previous behaviour was a data race that often worked out, and it
ignores errors in flock to fall back to the old racy behaviour so that
it won't degrade the behaviour on filesystems that don't support
flock.

llvm-svn: 234036
2015-04-03 18:55:44 +00:00
Evgeniy Stepanov e2a8241f84 [sancov] Shrink pc array on Android back to 2**24.
Address space is a lot more constrained on 32-bit Android compared to Linux.

llvm-svn: 234010
2015-04-03 12:59:39 +00:00
Timur Iskhodzhanov ad3ec82bb1 [ASan/Win] Minor improvements towards enabling coverage
llvm-svn: 233918
2015-04-02 14:48:08 +00:00
Alexey Samsonov d4273ebbf3 Add missing " at the end of the #error directive.
llvm-svn: 233879
2015-04-02 01:13:43 +00:00
Peter Collingbourne 7881648a4e Add tests for non-virtual call checking.
Differential Revision: http://reviews.llvm.org/D8792

llvm-svn: 233876
2015-04-02 00:33:36 +00:00
Alexey Samsonov 9c2116d912 [CMake] Fixup for r233861: don't build standalone UBSan on unsupported platforms.
llvm-svn: 233865
2015-04-01 23:00:02 +00:00
Alexey Samsonov 09dce3b7e5 [UBSan] Embed UBSan into ASan runtime (compiler-rt part).
Summary:
Change the way we use ASan and UBSan together. Instead of keeping two
separate runtimes (libclang_rt.asan and libclang_rt.ubsan), embed UBSan
into ASan and get rid of libclang_rt.ubsan. If UBSan is not supported on
a platform, all UBSan sources are just compiled into dummy empty object
files. UBSan initialization code (e.g. flag parsing) is directly called
from ASan initialization, so we are able to enforce correct
initialization order.

This mirrors the approach we already use for ASan+LSan. This change
doesn't modify the way we use standalone UBSan.

Test Plan: regression test suite

Reviewers: kubabrecka, zaks.anna, rsmith, kcc

Subscribers: llvm-commits

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

llvm-svn: 233861
2015-04-01 22:42:36 +00:00
Alexander Potapenko 0ae78444e7 [ASan] Make the remaining coverage tests pass on Darwin, move them to Posix/
This CL:
 - moves PrepareForSandboxing() to sanitizer_posix_libcdep.cc
 - fixes the coverage tests to use flag substitutions defined in r233802 and not rely on hardcoded shared library names
 - moves those tests to TestCases/Posix so that they can be executed on Darwin

llvm-svn: 233828
2015-04-01 17:56:29 +00:00
Bill Seurer f1b82e3ad1 Remove XFAILs from cast-overflow.cpp
My fix for power also fixed armv7l-unknown-linux-gnueabihf and aarch64

llvm-svn: 233827
2015-04-01 17:50:39 +00:00
Alexander Potapenko 9be2c6544b [ASan] Speculative fix for TestCases/Posix/interception-in-shared-lib-test.cc and TestCases/suppressions-library.cc on FreeBSD.
r233802 has moved the tests above to Posix/ and introduced %ld_flags_rpath_so and %ld_flags_rpath_exe,
which haven't been defined for FreeBSD.
We expect the flags to be the same on Linux and FreeBSD. If there's another reason for the tests to fail on FreeBSD,
they'll need to be disabled.

llvm-svn: 233822
2015-04-01 17:07:50 +00:00
Bill Seurer 4c41366510 [PPC64]This activates UBSan for the power architecture.
One test case is updated to allow for differences between power and other architectures in behavior when returning from main in certain instances

http://reviews.llvm.org/D8743

llvm-svn: 233813
2015-04-01 15:33:22 +00:00
Timur Iskhodzhanov 882bc56ff1 [Sanitizers Coverage] Make sancov.py work with wildcards from Windows CMD shell
Reviewed at http://reviews.llvm.org/D8724

llvm-svn: 233809
2015-04-01 14:46:10 +00:00
Alexander Potapenko 8db9e77ba7 [ASan] Deduplicate interception-in-shared-lib-test.cc by introducing platform-specific substitutions for rpath linker flags
Also make suppressions-library.cc use the same flags to avoid warnings about unused -rpath flags.
The same substitutions will be used to make coverage tests work on both Linux and Darwin without duplicating the code.

llvm-svn: 233802
2015-04-01 12:13:03 +00:00
Alexey Samsonov c4ed548b40 [Sanitizer] Be consistent about separating ==%PID== and logged data.
See https://code.google.com/p/address-sanitizer/issues/detail?id=385.

llvm-svn: 233720
2015-03-31 18:16:42 +00:00
Timur Iskhodzhanov 89608af26d [ASan/Win] UnmapOrDie should not fail on zero address / size
llvm-svn: 233707
2015-03-31 16:39:20 +00:00
Timur Iskhodzhanov 6c66ad0d75 [Sanitizer RT] Put the Symbolizer module name string ownership in order
Reviewed at http://reviews.llvm.org/D8666

llvm-svn: 233687
2015-03-31 12:50:05 +00:00
Nick Lewycky 816e0eabb7 Add another sanity check for swapcontext, which is currently unsupported. Patch by Alexey Samsonov!
llvm-svn: 233413
2015-03-27 20:40:23 +00:00
Viktor Kutuzov eff2d98ecc [Tsan] Do not sanitize memset() and other functions during initialization
Differential Revision: http://reviews.llvm.org/D8544

llvm-svn: 233378
2015-03-27 14:12:28 +00:00
Dmitry Vyukov 2034ce665a tsan: don't write to meta shadow unnecessarily
If user does malloc(1<<30), the write to meta shadow
can cause excessive memory consumption.

llvm-svn: 233373
2015-03-27 12:22:44 +00:00
Alexey Samsonov 0781e98cc7 [UBSan] Explicitly list all supported OS/arch pairs supported by UBSan.
llvm-svn: 233295
2015-03-26 17:26:04 +00:00
Timur Iskhodzhanov fd3241528d [Sanitizer] Plug a leak in POSIXSymbolizer::FindModuleForAddress
It was happening when we looked up a PC for a module that was dlopen'ed/dlclose'd
after the last time we fetched the list of modules

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

llvm-svn: 233257
2015-03-26 07:14:29 +00:00
Alexey Samsonov 1c1407395f [LSan] Don't explicitly exclude LSan from Windows build - it should just produce dummy object files. NFC.
llvm-svn: 233231
2015-03-25 23:26:49 +00:00
Kuba Brecka b47f4ef508 On OS X, explicitly use libc++
For OS X builds, both Make and CMake, let's be very explicit about using
libc++ and libc++abi with:

1) -stdlib=libc++ in CFLAGS and LDFLAGS for all platforms
2) -lc++ in LDFLAGS for all platforms
3) switch from -undefined dynamic_lookup to -lc++abi for UBSan in
   Makefile-based builds

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

llvm-svn: 233215
2015-03-25 21:07:20 +00:00
Timur Iskhodzhanov 3e8d392e9a [Sanitizers coverage] Minor cleanup: reduce scope and visibility of one method and one variable
llvm-svn: 233212
2015-03-25 20:19:51 +00:00
Bill Seurer 92760a3551 [PowerPC]Fix sancov.py to once again support big endian
Some recent changes to sancov.py broke ASAN for big endian.  This fixes it.

http://reviews.llvm.org/D8594

llvm-svn: 233189
2015-03-25 14:56:02 +00:00
Alexander Potapenko 2dee295a89 [ASan] Suppress the deprecation warning from atos that breaks AtosSymbolizer on OSX 10.9
On OS X 10.9 /usr/bin/atos prints the following warning upon invocation:

 --
Warning: /usr/bin/atos is moving and will be removed from a future OS X release.
It is now available in the Xcode developer tools to be invoked via: `xcrun atos`
To silence this warning, pass the '-d' command-line flag to this tool.
 --

AtosSymbolizer treats the warning as the symbolization result for the first PC passed to the symbolizer. As a result, for each of the following PCs the file:line info for the previous PC is printed, e.g.:

==97926==ERROR: AddressSanitizer: attempting double-free on 0x60200000dfb0 in thread T0:
==97926==Using atos at user-specified path: /usr/bin/atos
==97926==Using dladdr symbolizer.
   #0 0x1007407e0 in  --  (+0x427e0)
   #1 0x1006f6f25 in wrap_free asan_malloc_mac.cc:114
   #2 0x7fff916e05fc in main atos-symbolizer.cc:17
   #3 0x0  (<unknown module>)

Unfortunately atos doesn't accept the -d switch on OSX versions other than 10.9, thus we have to check for the OSX version.

llvm-svn: 233180
2015-03-25 11:01:33 +00:00
Alexey Samsonov ee449b68d0 Revert "Revert "[UBSan] Use shared library for UBSan on OS X" and its followup"
Fix the build/tests by providing -lc++abi for UBSan runtime only.

llvm-svn: 233122
2015-03-24 21:57:07 +00:00
Justin Bogner cc7e7cabd5 Revert "[UBSan] Use shared library for UBSan on OS X" and its followup
This change caused test failures on darwin, and the followup which was
meant to fix those caused compiler-rt to start failing to link.
Reverting to get the build working again.

This reverts r233071 and r233036.

llvm-svn: 233097
2015-03-24 17:43:31 +00:00
Alexander Potapenko f7d32ccc00 [ASan] Do not link ASan OSX runtime with -lc++abi (which was added in r233036)
This should fix the OSX Jenkins build at http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA_check/

llvm-svn: 233071
2015-03-24 13:10:55 +00:00
Alexey Samsonov 6279a07eaa [TSan] Disable -Wno-maybe-uninitialized in yet another place.
llvm-svn: 233044
2015-03-24 00:38:43 +00:00
Alexey Samsonov 58e4835779 [TSan] Fixup for r233038: restrict the -Wno-maybe-uninitialized flag to GCC only.
llvm-svn: 233042
2015-03-23 23:44:38 +00:00
Alexey Samsonov 705c449af5 [ASan] Remove XFAIL from now passing test.
llvm-svn: 233040
2015-03-23 23:37:39 +00:00
Alexey Samsonov 543e966142 [TSan] Disable noisy GCC warning.
llvm-svn: 233038
2015-03-23 23:29:39 +00:00
Kostya Serebryany cd019f3655 [sanitizer] instead of comparing pointers to module_names while initializing coverage do a proper strcmp and strdup. NFC
llvm-svn: 233037
2015-03-23 23:19:13 +00:00
Alexey Samsonov c4eb977b0f [UBSan] Use shared library for UBSan on OS X (compiler-rt part).
Summary:
Switch to shared library for UBSan. Add support for building
UBSan on OSX and iossim by cargo-culting ASan build rules.

Test Plan: regression test suite

Reviewers: zaks.anna, kubabrecka

Subscribers: llvm-commits

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

llvm-svn: 233036
2015-03-23 23:14:16 +00:00
Alexey Samsonov 6a7ee6f460 [UBSan] Introduce "ubsan_standalone" library (compiler-rt part).
Get rid of "libclang_rt.san" library that used to contain
sanitizer_common pieces required by UBSan if it's used in a standalone
mode. Instead, build two variants of UBSan runtime: "ubsan" and
"ubsan_standalone" (same for "ubsan_cxx" and "ubsan_standalone_cxx").

Later "ubsan" and "ubsan_cxx" libraries will go away, as they will
embedded it into corresponding ASan runtimes.

llvm-svn: 233011
2015-03-23 20:05:53 +00:00