Age | Commit message (Collapse) | Author |
|
Building with a new clang produces a bunch of warnings about dropped 'const' and 'volatile' qualifiers on pointers. Let's fix them.
Differential Revision: https://reviews.llvm.org/D39861
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@317929 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
This commit annotates the block parameters of the following functions
declared in compiler-rt with 'noescape':
- dispatch_sync
- dispatch_barrier_sync
- dispatch_once
- dispatch_apply
This is needed to commit the patch that adds support for 'noescape' in
clang (see https://reviews.llvm.org/D32210) since these functions are
annotated with 'noescape' in the SDK header files.
Differential Revision: https://reviews.llvm.org/D32210
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@313929 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Summary:
Set proper errno code on allocation failures and change realloc, pvalloc,
aligned_alloc, memalign and posix_memalign implementation to satisfy
their man-specified requirements.
Modify allocator API implementation to bring it closer to other
sanitizers allocators.
Reviewers: dvyukov
Subscribers: llvm-commits, kubamracek
Differential Revision: https://reviews.llvm.org/D35690
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308929 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
While it's usually a bug to call GCD APIs, such as dispatch_after, with NULL as a queue, this often "somehow" works and TSan should maintain binary compatibility with existing code. This patch makes sure we don't try to call Acquire and Release on NULL queues, and add one such testcase for dispatch_after.
Differential Revision: https://reviews.llvm.org/D31355
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298820 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298741 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
tsan_libdispatch_mac.cc.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298738 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
GCD queues can be suspended and resumed with dispatch_suspend and dispatch_resume. We need to add synchronization between the call to dispatch_resume and any subsequent executions of blocks in the queue that was resumed. We already have an Acquire(q) before the block executes, so this patch just adds the Release(q) in an interceptor of dispatch_resume.
Differential Revision: https://reviews.llvm.org/D27112
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@287902 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
GCD (libdispatch) has a concept of “target queues”: Each queue has either an implicit or explicit target queue, where the task is handed over to when it’s time to execute it. For example, a concurrent queue can have a serial target queue (effectively making the first queue serial), or multiple queues can have the same serial target queue (which means tasks in all the queues are mutually excluded). Thus we need to acquire-release semantics on the full “chain” of target queues.
This patch changes the way we Acquire() and Release() when executing tasks in queues. Now we’ll walk the chain of target queues and synchronize on each queue that is serial (or when dealing with a barrier block). This should avoid false positives when using dispatch_set_target_queue().
Differential Revision: https://reviews.llvm.org/D25835
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@285613 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
This patch adds interceptors for dispatch_io_*, dispatch_read and dispatch_write functions. This avoids false positives when using GCD IO. Adding several test cases.
Differential Revision: http://reviews.llvm.org/D21889
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275071 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
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
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@274749 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
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
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@274619 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
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
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@274549 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
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
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@274548 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
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
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@274117 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
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
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@273893 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
We're missing interceptors for dispatch_after and dispatch_after_f. Let's add them to avoid false positives. Added a test case.
Differential Revision: http://reviews.llvm.org/D20426
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@270071 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
We need to handle the case when handler is NULL in dispatch_source_set_cancel_handler and similar interceptors.
Differential Revision: http://reviews.llvm.org/D18968
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@266080 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Adding an interceptor with two more release+acquire pairs to avoid false positives with dispatch_apply.
Differential Revision: http://reviews.llvm.org/D18722
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@265662 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
GCD has APIs for event sources, we need some more release-acquire pairs to avoid false positives in TSan.
Differential Revision: http://reviews.llvm.org/D18515
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@265660 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
In the interceptor for dispatch_sync, we're currently missing synchronization between the callback and the code *after* the call to dispatch_sync. This patch fixes this by adding an extra release+acquire pair to dispatch_sync() and similar APIs. Added a testcase.
Differential Revision: http://reviews.llvm.org/D18502
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@265659 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Some interceptors in tsan_libdispatch_mac.cc currently wrongly use TSAN_SCOPED_INTERCEPTOR/ScopedInterceptor. Its constructor can start ignoring memory accesses, and the destructor the stops this -- however, e.g. dispatch_sync can call user's code, so the ignoring will extend to user's code as well. This is not expected and we should only limit the scope of ScopedInterceptor to TSan code. This patch introduces annotations that mark the beginning and ending of a callback into user's code.
Differential Revision: http://reviews.llvm.org/D15419
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@255995 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
We're using the dispatch group itself to synchronize (to call Release() and Acquire() on it), but in dispatch group notifications, the group can already be disposed/deallocated. This causes a later assertion failure at `DCHECK_EQ(*meta, 0);` in `MetaMap::AllocBlock` when the same memory is reused (note that the failure only happens in debug builds).
Fixing this by retaining the group and releasing it in the notification. Adding a stress test case that reproduces this.
Differential Revision: http://reviews.llvm.org/D15380
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@255494 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
This patch adds release and acquire semantics for dispatch groups, plus a test case.
Differential Revision: http://reviews.llvm.org/D15048
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@255020 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
This patch adds release and acquire semantics for libdispatch semaphores and a test case.
Differential Revision: http://reviews.llvm.org/D14992
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@254412 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Serial queues need extra happens-before between individual tasks executed in the same queue. This patch adds `Acquire(queue)` before the executed task and `Release(queue)` just after it (for serial queues only). Added a test case.
Differential Revision: http://reviews.llvm.org/D15011
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@254229 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
We need to intercept libdispatch APIs (dispatch_sync, dispatch_async, etc.) to add synchronization between the code that submits the task and the code that gets executed (possibly on a different thread). This patch adds release+acquire semantics for dispatch_sync, and dispatch_async (plus their "_f" and barrier variants). The synchronization is done on malloc'd contexts (separate for each submitted block/callback). Added tests to show usage of dispatch_sync and dispatch_async, for cases where we expect no warnings and for cases where TSan finds races.
Differential Revision: http://reviews.llvm.org/D14745
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@253982 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Reimplement dispatch_once in an interceptor to solve these issues that may produce false positives with TSan on OS X:
1) there is a racy load inside an inlined part of dispatch_once,
2) the fast path in dispatch_once doesn't perform an acquire load, so we don't properly synchronize the initialization and subsequent uses of whatever is initialized,
3) dispatch_once is already used in a lot of already-compiled code, so TSan doesn't see the inlined fast-path.
This patch uses a trick to avoid ever taking the fast path (by never storing ~0 into the predicate), which means the interceptor will always be called even from already-compiled code. Within the interceptor, our own atomic reads and writes are not written into shadow cells, so the race in the inlined part is not reported (because the accesses are only loads).
Differential Revision: http://reviews.llvm.org/D14811
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@253552 91177308-0d34-0410-b5e6-96231b3b80d8
|