Commit Graph

47 Commits

Author SHA1 Message Date
Mohit K. Bhakkad a46d5a7438 [TSan][MIPS] Adding support for MIPS64
Patch by Sagar Thakur

Reviewers: dvyukov, samsonov, petarj, kcc, dsanders.

Subscribers:  mohit.bhakkad, Anand.Takale, llvm-commits.

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

llvm-svn: 229972
2015-02-20 06:42:41 +00:00
Kostya Serebryany 83ed889bbd [tsan] remove TSAN_GO in favor of SANITIZER_GO
llvm-svn: 223732
2014-12-09 01:31:14 +00:00
Alexey Samsonov 4925fd4b05 Fix -Wcast-qual warnings in sanitizers
llvm-svn: 221936
2014-11-13 22:40:59 +00:00
Alexey Samsonov 40733a8024 [TSan] Use StackTrace from sanitizer_common where applicable
Summary:
This change removes `__tsan::StackTrace` class. There are
now three alternatives:
  # Lightweight `__sanitizer::StackTrace`, which doesn't own a buffer
  of PCs. It is used in functions that need stack traces in read-only
  mode, and helps to prevent unnecessary allocations/copies (e.g.
  for StackTraces fetched from StackDepot).
  # `__sanitizer::BufferedStackTrace`, which stores buffer of PCs in
  a constant array. It is used in TraceHeader (non-Go version)
  # `__tsan::VarSizeStackTrace`, which owns buffer of PCs, dynamically
  allocated via TSan internal allocator.

Test Plan: compiler-rt test suite

Reviewers: dvyukov, kcc

Reviewed By: kcc

Subscribers: llvm-commits, kcc

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

llvm-svn: 221194
2014-11-03 22:23:44 +00:00
Dmitry Vyukov 9cf7ac7589 tsan: fix Go runtime build with clang
llvm-svn: 213384
2014-07-18 15:32:22 +00:00
Dmitry Vyukov a8df247f5a tsan: expose atomic operations in Go runtime
llvm-svn: 213382
2014-07-18 14:54:02 +00:00
Dmitry Vyukov bde4c9c773 tsan: refactor storage of meta information for heap blocks and sync objects
The new storage (MetaMap) is based on direct shadow (instead of a hashmap + per-block lists).
This solves a number of problems:
 - eliminates quadratic behaviour in SyncTab::GetAndLock (https://code.google.com/p/thread-sanitizer/issues/detail?id=26)
 - eliminates contention in SyncTab
 - eliminates contention in internal allocator during allocation of sync objects
 - removes a bunch of ad-hoc code in java interface
 - reduces java shadow from 2x to 1/2x
 - allows to memorize heap block meta info for Java and Go
 - allows to cleanup sync object meta info for Go
 - which in turn enabled deadlock detector for Go

llvm-svn: 209810
2014-05-29 13:50:54 +00:00
Alexey Samsonov 958a59b777 [TSan] ifdef out certain functions if 128-bit ints are not supported.
llvm-svn: 209476
2014-05-22 22:02:38 +00:00
Alp Toker 1ee7fc7a1a Fix typos
llvm-svn: 208841
2014-05-15 02:22:34 +00:00
Dmitry Vyukov 781eca5f71 tsan: use read lock instead of write in atomic operations when possible
llvm-svn: 204654
2014-03-24 18:51:13 +00:00
Dmitry Vyukov c9e12aa323 tsan: deobfuscate global ctx variable
llvm-svn: 204327
2014-03-20 10:36:20 +00:00
Joerg Sonnenberger 9d09e2fe90 Reapply r201910. MSVC gets __func__ defined explicitly, even though it
can't build anything here.

llvm-svn: 202297
2014-02-26 20:33:22 +00:00
Reid Kleckner 324eee45a7 Revert "Replace __FUNCTION__ with __func__, the latter being standard C99/C++11."
This reverts commit r201910.

While __func__ may be standard in C++11, it was only recently added to
MSVC in 2013 CTP, and LLVM supports MSVC 2012.  __FUNCTION__ may not be
standard, but it's *very* portable.

llvm-svn: 201916
2014-02-22 00:37:45 +00:00
Joerg Sonnenberger b15779f307 Replace __FUNCTION__ with __func__, the latter being standard C99/C++11.
llvm-svn: 201910
2014-02-21 23:55:15 +00:00
Dmitry Vyukov 7c9621c0be tsan: relax checking of errno spoiling in signal handlers
allow SIGABRT to spoil errno, because some real programs
reset SIGABRT handler in the handler, re-raise SIGABRT and return from the handler

llvm-svn: 200304
2014-01-28 09:49:48 +00:00
Dmitry Vyukov 16e7a758b0 tsan: do not deadlock on fork
Currently correct programs can deadlock after fork, because atomic operations and async-signal-safe calls are not async-signal-safe under tsan.
With this change:
- if a single-threaded program forks, the child continues running with verification enabled (the tsan background thread is recreated as well)
- if a multi-threaded program forks, then the child runs with verification disabled (memory accesses, atomic operations and interceptors are disabled); it's expected that it will exec soon anyway
- if the child tries to create more threads after multi-threaded fork, the program aborts with error message
- die_after_fork flag is added that allows to continue running, but all bets are off

http://llvm-reviews.chandlerc.com/D2614

llvm-svn: 199993
2014-01-24 12:33:35 +00:00
Dmitry Vyukov ce3721057d tsan: remove in_rtl counter
This is intended to address the following problem.
Episodically we see CHECK-failures when recursive interceptors call back into user code. Effectively we are not "in_rtl" at this point, but it's very complicated and fragile to properly maintain in_rtl property. Instead get rid of it. It was used mostly for sanity CHECKs, which basically never uncover real problems.
Instead introduce ignore_interceptors flag, which is used in very few narrow places to disable recursive interceptors (e.g. during runtime initialization).

llvm-svn: 197979
2013-12-24 12:55:56 +00:00
Alexey Samsonov 4fc8098979 [TSan] Move declarations of __tsan_atomic functions to a public header
llvm-svn: 197015
2013-12-11 08:18:50 +00:00
Dmitry Vyukov fbb194ff34 tsan: add annotations to ignore synchronization operations
The annotations are AnnotateIgnoreSyncBegin/End,
may be useful to ignore some infrastructure synchronization
that introduces lots of false negatives.

llvm-svn: 192355
2013-10-10 15:58:12 +00:00
Richard Smith 079fe209f5 Fix typo found by Clang fix for extern "C" function handling.
llvm-svn: 185234
2013-06-28 22:28:37 +00:00
Dmitry Vyukov 5cf581a8d4 tsan: consistently use return pc as top frame pc
always substract 1 from the top pc
this allows to get correct stacks with -O2

llvm-svn: 184112
2013-06-17 19:57:03 +00:00
Dmitry Vyukov 8794772337 tsan: more detailed trace for atomic operations (include address and memory ordering)
llvm-svn: 183643
2013-06-10 10:01:31 +00:00
Dmitry Vyukov b59fa875ad tsan: do not allocate sync vars on relaxed atomic operations
helps to reduce memory consumption if an atomic is used only with relaxed ops (stats)

llvm-svn: 177381
2013-03-19 09:15:31 +00:00
Dmitry Vyukov 87c6bb9716 tsan: even if races between atomic and plain memory accesses are turned off (report_atomic_races=0),
still report races between atomic accesses and free().

llvm-svn: 174175
2013-02-01 14:41:58 +00:00
Dmitry Vyukov 628df38e95 tsan: say that the memory access is atomic in reports
llvm-svn: 174168
2013-02-01 11:10:53 +00:00
Dmitry Vyukov aa6af4ddd1 tsan: remember 2 stack frames for atomics (caller and atomic itself)
llvm-svn: 174167
2013-02-01 11:01:17 +00:00
Dmitry Vyukov 52f0e4e1a0 tsan: add flag to not report races between atomic and plain memory accesses
llvm-svn: 174165
2013-02-01 10:06:56 +00:00
Dmitry Vyukov ba4291480d tsan: detect races between plain and atomic memory accesses
llvm-svn: 174163
2013-02-01 09:42:06 +00:00
Dmitry Vyukov fd5ebcd1b0 tsan: add mutexsets to reports
With this change reports say what mutexes the threads hold around the racy memory accesses.

llvm-svn: 169493
2012-12-06 12:16:15 +00:00
Dmitry Vyukov d413d8cfa9 tsan: fix memory barriers in atomics
llvm-svn: 169379
2012-12-05 13:14:55 +00:00
Dmitry Vyukov 4b82b2bb6e tsan: make atomic operations atomic again
llvm-svn: 169273
2012-12-04 14:50:10 +00:00
Dmitry Vyukov 4ef6b2bd03 tsan: fix nand operation
llvm-svn: 169266
2012-12-04 14:08:39 +00:00
Dmitry Vyukov 69a071d5a6 tsan: fix compilation for dead old compilers (why we are supporting them at all?..)
llvm-svn: 168693
2012-11-27 09:35:44 +00:00
Dmitry Vyukov 59d58665ee tsan: add 128-bit atomic operations
llvm-svn: 168683
2012-11-27 07:41:27 +00:00
Dmitry Vyukov 10362c46f1 tsan: refactor atomic operations implementation
do the atomic operation under the sync object mutex
make acquire/release sync atomic with the operation itself
combine acquire and release into a single acq_rel operation

llvm-svn: 168682
2012-11-27 07:25:50 +00:00
Dmitry Vyukov 3b4501254f tsan: add atomic nand operation
llvm-svn: 168584
2012-11-26 09:42:56 +00:00
Dmitry Vyukov 195eda9922 tsan: add failure memory order to atomic compare exchange functions
llvm-svn: 168518
2012-11-23 15:51:45 +00:00
Dmitry Vyukov 262465c126 tsan: eevn better handling of signals
add interceptor for poll()
in addition process signals in every atomic op
in addition process signals in blocking libc functions

llvm-svn: 168050
2012-11-15 17:40:49 +00:00
Dmitry Vyukov 805006b0ab tsan: switch to new memory_order constants (ABI compatible)
llvm-svn: 167614
2012-11-09 14:11:51 +00:00
Dmitry Vyukov 4e5f72d380 tsan: add __tsan_atomicX_compare_exchange_val() function
It's easier to call from compiler module.

llvm-svn: 167611
2012-11-09 12:54:37 +00:00
Dmitry Vyukov b96a7b5aa5 tsan: add atomic_fetch_sub() and atomic_signal_fence() functions
llvm-svn: 165218
2012-10-04 10:08:23 +00:00
Dmitry Vyukov be6878365d tsan: prepare for migration to new memory_order enum values (ABI compatible)
llvm-svn: 165106
2012-10-03 13:00:13 +00:00
Dmitry Vyukov 6f6ba43271 tsan: more precise handling of atomic_store(memory_order_release)
llvm-svn: 162994
2012-08-31 13:22:13 +00:00
Alexey Samsonov 8bd9098b32 [Sanitizer] move placement_new definiton from TSan to common runtime
llvm-svn: 158145
2012-06-07 09:50:16 +00:00
Alexey Samsonov 3b2f9f4c98 Remove file-type tags in .cc files in tsan/ and sanitizer_common/
llvm-svn: 157928
2012-06-04 13:55:19 +00:00
Dmitry Vyukov 572c5b2a44 tsan: add more atomics to public interface (fetch_or/and/xor + 1-,2-byte versions)
llvm-svn: 156766
2012-05-14 15:33:00 +00:00
Kostya Serebryany 4ad375f0a9 [tsan] First commit of ThreadSanitizer (TSan) run-time library.
Algorithm description: http://code.google.com/p/thread-sanitizer/wiki/ThreadSanitizerAlgorithm

Status:
The tool is known to work on large real-life applications, but still has quite a few rough edges.
Nothing is guaranteed yet.

The tool works on x86_64 Linux.
Support for 64-bit MacOS 10.7+ is planned for late 2012.
Support for 32-bit OSes is doable, but problematic and not yet planed.

Further commits coming:
  - tests
  - makefiles
  - documentation
  - clang driver patch

The code was previously developed at http://code.google.com/p/data-race-test/source/browse/trunk/v2/
by Dmitry Vyukov and Kostya Serebryany with contributions from
Timur Iskhodzhanov, Alexander Potapenko, Alexey Samsonov and Evgeniy Stepanov.

llvm-svn: 156542
2012-05-10 13:48:04 +00:00