Commit Graph

1640 Commits

Author SHA1 Message Date
Saleem Abdulrasool bcb8190f99 test: Use %clangxx in objc++ test files
These test in this change are objc++, but are built using %clang, not %clangxx.
The reason this works is the driver has been adding -lc++ for sanitizer enabled
builds. By making these tests use %clangxx, they no longer depend on the driver
linking to c++.  Doing so will allow us to prevent overlinking of libc++ for
applications.

llvm-svn: 274989
2016-07-09 21:14:36 +00:00
Derek Bruening dec4bd0838 [esan] Add __esan_report for mid-run data
Summary:
Adds a new public interface routine __esan_report() which can be used to
request profiling results prior to abnormal termination (e.g., for a server
process killed by its parent where the normal exit does not allow for
normal result reporting).

Implements this for the working-set tool.  The cache frag tool is left
unimplemented as it requires missing iteration capabilities.

Adds a new test.

Reviewers: aizatsky

Subscribers: vitalybuka, zhaoqin, kcc, eugenis, llvm-commits, kubabrecka

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

llvm-svn: 274964
2016-07-09 04:13:25 +00:00
Alina Sbirlea 0efdda0956 Revert "Add runtime support for __cpu_model (__builtin_cpu_supports)"
This reverts commit r274873 until additional fixes are resolved.

llvm-svn: 274944
2016-07-08 22:22:43 +00:00
Alina Sbirlea 9ebebce2df Add runtime support for __cpu_model (__builtin_cpu_supports)
Summary:
This aims to add support for __cpu_model and address Bug 25510. It uses
the code from lib/Support/Host.cpp for cpu detection, and creates
__cpu_model with that info.

Tested on OSX, it builts successfully, but the current version does
*not* resolve Bug 25510. The __cpu_model symbol is present in the
library but it only gets loaded with -all_load. This patch will not land
until this issue is clarified.

Built on Linux as well (though libgcc is the default). The use of "asm"
required -std=gnu99, hence the cmake change. Corrections on better
addressing this are welcome.

Note: See additional comments on D20988 (committed as r271921).

Reviewers: llvm-commits, joerg, echristo, mehdi_amini

Subscribers: mehdi_amini

Differential revision: http://reviews.llvm.org/D21033

llvm-svn: 274873
2016-07-08 16:28:54 +00:00
Alina Sbirlea fb11f27253 Revert r274865-r274870
llvm-svn: 274872
2016-07-08 16:28:52 +00:00
Alina Sbirlea 7847598113 Add default initialization. Add unit test.
llvm-svn: 274867
2016-07-08 16:18:38 +00:00
Kuba Brecka 4446c216f5 [tsan] Avoid false positives with GCD data callbacks
This patch adds synchronization between the creation of the GCD data object and destructor’s execution. It’s far from perfect, because ideally we’d want to synchronize the destruction of the last reference (via dispatch_release) and the destructor’s execution, but intercepting objc_release is problematic.

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

llvm-svn: 274749
2016-07-07 12:38:37 +00:00
Qin Zhao 7f92eab5af [esan|cfrag] Handle binaries built with -esan-aux-field-info=false
Summary:
Handles binaries built with -esan-aux-field-info=false and print less
information.

Updates test struct-simple.cpp.

Reviewers: aizatsky

Subscribers: llvm-commits, bruening, eugenis, kcc, zhaoqin, kubabrecka, vitalybuka

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

llvm-svn: 274727
2016-07-07 03:20:24 +00:00
Derek Bruening 34913f3beb [esan|wset] Ensure SIGSEGV is not blocked
Summary:
Adds interception of sigprocmask and pthread_sigmask to esan so that the
working set tool can prevent SIGSEGV from being blocked.  A blocked SIGSEGV
results in crashes due to our lazy shadow page allocation scheme.

Adds new sanitizer helper functions internal_sigemptyset and
internal_sigismember.

Adds a test to workingset-signal-posix.cpp.

Reviewers: aizatsky

Subscribers: vitalybuka, zhaoqin, kcc, eugenis, llvm-commits, kubabrecka

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

llvm-svn: 274672
2016-07-06 21:04:48 +00:00
Derek Bruening 24fe829825 [esan|wset] Further reduce flakiness of sampling test
Enhances the sampling test to try and reduce flakiness further by
increasing the workload to ensure a few samples are gathered.

llvm-svn: 274669
2016-07-06 20:27:44 +00:00
Kuba Brecka fd995fe654 [tsan] Fix false positives with GCD dispatch_source_*
We already have interceptors for dispatch_source API (e.g. dispatch_source_set_event_handler), but they currently only handle submission synchronization. We also need to synchronize based on the target queue (serial, concurrent), in other words, we need to use dispatch_callback_wrap. This patch implements that.

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

llvm-svn: 274619
2016-07-06 11:02:49 +00:00
David Majnemer 69898e6bc5 Attempt to reduce flakiness in workingset-samples.cpp
The test is matching against 'KB' but it looks like the output can be
'MB'.

llvm-svn: 274587
2016-07-06 00:12:43 +00:00
Ryan Govostes b395d7271d [asan] Update tests according to r274578
llvm-svn: 274579
2016-07-05 21:53:23 +00:00
Kuba Brecka c54b108cf8 [tsan] Synchronize leaving a GCD group with notifications
In the patch that introduced support for GCD barrier blocks, I removed releasing a group when leaving it (in dispatch_group_leave). However, this is necessary to synchronize leaving a group and a notification callback (dispatch_group_notify). Adding this back, simplifying dispatch_group_notify_f and adding a test case.

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

llvm-svn: 274549
2016-07-05 13:48:54 +00:00
Kuba Brecka 09d3e53a93 [tsan] dispatch_once interceptor will cause a crash/deadlock when the original dispatch_once is used
Because we use SCOPED_TSAN_INTERCEPTOR in the dispatch_once interceptor, the original dispatch_once can also be sometimes called (when ignores are enabled or when thr->is_inited is false). However the original dispatch_once function doesn’t expect to find “2” in the storage and it will spin forever (but we use “2” to indicate that the initialization is already done, so no waiting is necessary). This patch makes sure we never call the original dispatch_once.

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

llvm-svn: 274548
2016-07-05 13:39:54 +00:00
Qin Zhao 91ea3fb698 [esan|cfrag] Add struct array access report
Summary:
Adds struct array access counter report.

Updates test struct-simple.cpp.

Reviewers: aizatsky

Subscribers: vitalybuka, zhaoqin, kcc, eugenis, bruening, llvm-commits, kubabrecka

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

llvm-svn: 274421
2016-07-02 03:25:55 +00:00
Kuba Brecka 4357f021e3 [tsan] Relax the "ignored-interceptors.mm" testcase. The test has been flaky because it's detecting a false positive race (coming from a system library) and sometimes that race is detected after we're printing "Done".
llvm-svn: 274346
2016-07-01 12:55:36 +00:00
Etienne Bergeron e6f424460a [compiler-rt] Fix broken unittest using alloca on MSVC.
Summary:
The alloca header is not present on windows.

This test was committed recently:
  http://reviews.llvm.org/D21509
  http://reviews.llvm.org/rL273889

Reviewers: rnk

Subscribers: llvm-commits, wang0109, chrisha, kubabrecka

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

llvm-svn: 274230
2016-06-30 14:37:02 +00:00
Kuba Brecka 4d81bbdf53 [tsan] Stop extending the block’s lifetime in dispatch_group_async
The dispatch_group_async interceptor actually extends the lifetime of the executed block. This means the destructor of the block (and captured variables) is called *after* dispatch_group_leave, which changes the semantics of dispatch_group_async.  This patch fixes that.

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

llvm-svn: 274117
2016-06-29 10:30:50 +00:00
Evgeniy Stepanov 465651fe3d [msan] Fix handling of padding in sendmsg control data.
llvm-svn: 274074
2016-06-28 22:42:31 +00:00
Kuba Brecka f7b9075e52 Adapt the "objc-race.mm" test to use ignore_interceptors_accesses=1. All Obj-C/Darwin tests currently need this to avoid false positives.
llvm-svn: 274014
2016-06-28 13:56:09 +00:00
Kuba Brecka 2621dea6eb [tsan] Add HB edges for GCD barrier blocks
Adding support for GCD barrier blocks in concurrent queues.  This uses two sync object in the same way as read-write locks do.  This also simplifies the use of dispatch groups (the notifications act as barrier blocks).

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

llvm-svn: 273893
2016-06-27 16:49:23 +00:00
Kuba Brecka 7d1ebed0c5 [asan] fix false dynamic-stack-buffer-overflow report with constantly-sized dynamic allocas, compiler-rt part
See the bug report at https://github.com/google/sanitizers/issues/691. When a dynamic alloca has a constant size, ASan instrumentation will treat it as a regular dynamic alloca (insert calls to poison and unpoison), but the backend will turn it into a regular stack variable. The poisoning/unpoisoning is then broken. This patch will treat such allocas as static.

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

llvm-svn: 273889
2016-06-27 15:57:53 +00:00
Ryan Govostes d4492ee159 Move -ldl to the correct compiler invocation
llvm-svn: 273844
2016-06-27 05:44:47 +00:00
Kuba Brecka 30ad0c941a [tsan] Intercept libcxx __release_shared to avoid false positive with weak_ptrs and destructors in C++
There is a "well-known" TSan false positive when using C++ weak_ptr/shared_ptr and code in destructors, e.g. described at <https://llvm.org/bugs/show_bug.cgi?id=22324>. The "standard" solution is to build and use a TSan-instrumented version of libcxx, which is not trivial for end-users. This patch tries a different approach (on OS X): It adds an interceptor for the specific function in libc++.dylib, which implements the atomic operation that needs to be visible to TSan.

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

llvm-svn: 273806
2016-06-26 08:14:01 +00:00
Peter Collingbourne c79ad577fb cfi: Start testing CFI in both standalone and devirtualization modes.
Differential Revision: http://reviews.llvm.org/D21123

llvm-svn: 273758
2016-06-25 00:24:22 +00:00
Evgeniy Stepanov dd9e03ed87 [msan] Intercept eventfd_read, eventfd_write.
llvm-svn: 273748
2016-06-24 23:32:30 +00:00
Evgeniy Stepanov c8679985ed [sanitizer] Add syscall handlers for sigaction and rt_sigaction.
llvm-svn: 273746
2016-06-24 23:09:44 +00:00
Ryan Govostes 6f92bd38d8 [asan] Improve global-registration.c test
Removes use of GNU language extensions from the test, and hopefully fixes the
link order on Linux.

llvm-svn: 273741
2016-06-24 22:39:23 +00:00
Peter Collingbourne cf55f217ba cfi: Apply pass rename to tests.
Differential Revision: http://reviews.llvm.org/D21055

llvm-svn: 273731
2016-06-24 21:22:02 +00:00
Evgeniy Stepanov c7509de7cc [msan] Fix syscall handlers for pipe, pipe2, socketpair.
These syscalls write two file descriptors into the output buffer, not one.

llvm-svn: 273728
2016-06-24 21:15:53 +00:00
Xinliang David Li 3e9bbddcbb fix a test bug when executed remotedly
llvm-svn: 273693
2016-06-24 17:42:51 +00:00
Ryan Govostes 00f607eef0 Change shared library load path to appease Android bot
llvm-svn: 273654
2016-06-24 06:49:01 +00:00
Ryan Govostes 0ec8ab680f [asan] Add failure logging to global-registration.c test case
llvm-svn: 273629
2016-06-23 23:26:25 +00:00
Ryan Govostes 3c0f63c98b [asan] Fix global-registration.c on Linux
llvm-svn: 273476
2016-06-22 20:52:34 +00:00
Anna Zaks 0a494bd4d4 [asan] Relax a flaky invalid-pointer-pairs test
This test is flaky. Specifically, on some Mac configurations we see the
__sanitizer_ptr_cmp as the 0th frame. Let's relax it to not require that
f is in frame #0.

61396==ERROR: AddressSanitizer: invalid-pointer-pair: 0x01e00510 0x01e004d0
0 0x18f5a3 in __sanitizer_ptr_cmp ... libclang_rt.asan_osx_dynamic.dylib+0xaf5a3)
1 0xdd924 in f(char, char*, char*) ... invalid-pointer-pairs.cc:14:14

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

llvm-svn: 273475
2016-06-22 20:52:21 +00:00
Ryan Govostes f66146914b [asan] Add a test case for global registration
This test case checks that globals from all object files are being registered
after they've been linked together. It also checks that globals from libraries
loaded at runtime are registered.

llvm-svn: 273464
2016-06-22 19:59:10 +00:00
Dmitry Vyukov 47b7c5c912 [asan] add primitives that allow coroutine implementations
This patch adds the __sanitizer_start_switch_fiber and
__sanitizer_finish_switch_fiber methods inspired from what can be found here
2ea64dd249 .

These methods are needed when the compiled software needs to implement
coroutines, fibers or the like. Without a way to annotate them, when the program
jumps to a stack that is not the thread stack, __asan_handle_no_return shows a
warning about that, and the fake stack mechanism may free fake frames that are
still in use.

Author: blastrock (Philippe Daouadi)
Reviewed in http://reviews.llvm.org/D20913

llvm-svn: 273260
2016-06-21 12:29:18 +00:00
Evgeniy Stepanov ecfcc07a48 [msan] Don't check dstaddr in sendto() interceptor.
Dstaddr may contain uninitialized padding at the end (common
implementations accept larger addrlen and ignore the extra bytes).
Also, depending on the socket state, dstaddr argument may be ignored.

llvm-svn: 273205
2016-06-20 22:05:33 +00:00
Evgeniy Stepanov 843b651398 [msan] Allow uninitialized padding in struct msghdr.
llvm-svn: 273204
2016-06-20 21:44:14 +00:00
Evgeniy Stepanov 352289b679 Hide send/sendto/sendmsg interptors under a flag.
A runtime flag to enable checking in send* interceptors.
Checking is enabled by default.

llvm-svn: 273174
2016-06-20 17:57:51 +00:00
Qin Zhao e24bc365e8 [esan|cfrag] Add the struct field size array in StructInfo
Summary:
Adds the struct field size array in the struct StructInfo.

Prints struct field size info in the report.

Reviewers: aizatsky

Subscribers: vitalybuka, zhaoqin, kcc, eugenis, bruening, llvm-commits, kubabrecka

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

llvm-svn: 272988
2016-06-17 04:50:11 +00:00
Evgeniy Stepanov 3c17c73924 [msan] Intercept send/sendto/sendmsg.
send/sendmsg moved from tsan to sanitizer_common; sendto is new.

llvm-svn: 272980
2016-06-17 00:43:11 +00:00
Kostya Serebryany bf6a04fde8 [sanitizers] introduce yet another API function: __sanitizer_install_malloc_and_free_hooks
llvm-svn: 272943
2016-06-16 20:06:06 +00:00
Evgeniy Stepanov 062c26f1f0 Merge two coverage tests undef UBSan into one.
Also replace mkdir -p with rm -rf && mkdir.

llvm-svn: 272839
2016-06-15 21:18:17 +00:00
Evgeniy Stepanov 9ea0833b6e Fix ubsan/coverage test to put coverage file in a subdirectory.
By default coverage is dumped to the current directory, which may not
always be writable.

llvm-svn: 272732
2016-06-14 22:53:29 +00:00
Evgeniy Stepanov c565cfaac9 Compiler-rt test for sanitizer coverage w/o sanitizers.
llvm-svn: 272718
2016-06-14 21:33:59 +00:00
Derek Bruening f6f149da29 [sanitizer][esan] Add internal_sigaction_syscall
Summary:
Adds a version of sigaction that uses a raw system call, to avoid circular
dependencies and support calling sigaction prior to setting up
interceptors.  The new sigaction relies on an assembly sigreturn routine
for its restorer, which is Linux x86_64-only for now.

Uses the new sigaction to initialize the working set tool's shadow fault
handler prior to libc interceptor being set up.  This is required to
support instrumentation invoked during interceptor setup, which happens
with an instrumented tcmalloc or other allocator compiled with esan.

Adds a test that emulates an instrumented allocator.

Reviewers: aizatsky

Subscribers: vitalybuka, tberghammer, zhaoqin, danalbert, kcc, srhines, eugenis, llvm-commits, kubabrecka

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

llvm-svn: 272676
2016-06-14 15:15:38 +00:00
Nico Weber be7aa544f0 Revert r272591, http://lab.llvm.org:8011/builders/clang-x64-ninja-win7 has been broken since this landed.
llvm-svn: 272659
2016-06-14 12:39:22 +00:00
Derek Bruening c4c649e25a [sanitizer][esan] Add internal_sigaction_syscall
Summary:
Adds a version of sigaction that uses a raw system call, to avoid circular
dependencies and support calling sigaction prior to setting up
interceptors.  The new sigaction relies on an assembly sigreturn routine
for its restorer, which is Linux x86_64-only for now.

Uses the new sigaction to initialize the working set tool's shadow fault
handler prior to libc interceptor being set up.  This is required to
support instrumentation invoked during interceptor setup, which happens
with an instrumented tcmalloc or other allocator compiled with esan.

Adds a test that emulates an instrumented allocator.

Reviewers: aizatsky

Subscribers: vitalybuka, tberghammer, zhaoqin, danalbert, kcc, srhines, eugenis, llvm-commits, kubabrecka

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

llvm-svn: 272591
2016-06-13 21:50:00 +00:00