Kostya Serebryany
3df5d87da4
[sanitizer] print threads in deadlock report
...
llvm-svn: 204461
2014-03-21 13:00:18 +00:00
Dmitry Vyukov
c9e12aa323
tsan: deobfuscate global ctx variable
...
llvm-svn: 204327
2014-03-20 10:36:20 +00:00
Dmitry Vyukov
6e2557769c
tsan: use stack depot for goroutine creation stacks (as C++ threads do)
...
llvm-svn: 204326
2014-03-20 10:19:02 +00:00
Dmitry Vyukov
6cfab724ec
tsan: refactor deadlock detector
...
Introduce DDetector interface between the tool and the DD itself.
It will help to experiment with other DD implementation,
as well as reuse DD in other tools.
llvm-svn: 202485
2014-02-28 10:48:13 +00:00
Kostya Serebryany
01be296dbb
[sanitizer] support pthread_rwlock_rd* in deadlock detector
...
llvm-svn: 202132
2014-02-25 10:33:37 +00:00
Kostya Serebryany
11f4f30fa7
[sanitizer] add support for try_lock in deadlock detector
...
llvm-svn: 202120
2014-02-25 08:24:15 +00:00
Kostya Serebryany
0548c79859
[tsan] add coarse-grained lock around the DeadlockDetector. We can do better than that, but that's a start.
...
llvm-svn: 201861
2014-02-21 15:07:18 +00:00
Kostya Serebryany
ec68429c5d
[sanitizer] simplify DeadlockDetectorTLS
...
llvm-svn: 201505
2014-02-17 08:47:48 +00:00
Kostya Serebryany
a63632a5c6
[tsan] rudimentary support for deadlock detector in tsan (nothing really works yet except for a single tiny test). Also rename tsan's DeadlockDetector to InternalDeadlockDetector
...
llvm-svn: 201407
2014-02-14 12:20:42 +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
Kostya Serebryany
14e92c2c62
[sanitizer] support toolchains that don't understand CFI directives
...
Summary: Support toolchains that don't understand CFI directives.
Reviewers: dvyukov
Reviewed By: dvyukov
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D2336
llvm-svn: 196480
2013-12-05 07:44:35 +00:00
Dmitry Vyukov
3238e1c913
tsan: better diagnostics if thread finishes with ignores enabled
...
print thread creation stack
and stacks where ignores were enabled.
llvm-svn: 195836
2013-11-27 11:30:28 +00:00
Dmitry Vyukov
4bbe6dc8a9
tsan: add support for robust mutexes
...
llvm-svn: 194823
2013-11-15 16:58:12 +00:00
Dmitry Vyukov
0b76e408b4
tsan: add proper cfi directives to assembly code
...
this allows gdb to unwind through our hacky call
llvm-svn: 194803
2013-11-15 10:25:53 +00:00
Dmitry Vyukov
464ebbd67b
tsan: move shadow stack from thread descriptors to fixed addresses
...
This allows to increase max shadow stack size to 64K,
and reliably catch shadow stack overflows instead of silently
corrupting memory.
llvm-svn: 192797
2013-10-16 15:35:12 +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
Dmitry Vyukov
5ba736457c
tsan: ignore interceptors coming from specified libraries
...
LibIgnore allows to ignore all interceptors called from a particular set
of dynamic libraries. LibIgnore remembers all "called_from_lib" suppressions
from the provided SuppressionContext; finds code ranges for the libraries;
and checks whether the provided PC value belongs to the code ranges.
Also make malloc and friends interceptors use SCOPED_INTERCEPTOR_RAW instead of
SCOPED_TSAN_INTERCEPTOR, because if they are called from an ignored lib,
then must call our internal allocator instead of libc malloc.
llvm-svn: 191897
2013-10-03 13:37:17 +00:00
Dmitry Vyukov
1a7ca92006
tsan: refactor internal IgnoreCtl interface
...
llvm-svn: 190987
2013-09-19 04:39:04 +00:00
Sergey Matveev
d109eb052b
[tsan] Move some suppressions-related code to common.
...
Factor out code to be reused in LSan. Also switch from linked list to vector.
llvm-svn: 184957
2013-06-26 15:37:14 +00:00
Alexey Samsonov
0d7012debb
[TSan] use InternalMmapVector to store fired suppressions
...
llvm-svn: 183974
2013-06-14 11:18:58 +00:00
Dmitry Vyukov
315bb0e687
tsan: allows to suppress races on global variables
...
llvm-svn: 183672
2013-06-10 15:38:44 +00:00
Alexey Samsonov
c30e2d6b3a
Make InternalAlloc/InternalFree in sanitizer runtimes libc-free by switching to a custom allocator.
...
llvm-svn: 182836
2013-05-29 09:15:39 +00:00
Dmitry Vyukov
c9af818515
tsan: introduce recursive mutex lock/unlock java interface
...
this is required to handle Object.Wait()
llvm-svn: 182088
2013-05-17 12:03:46 +00:00
Dmitry Vyukov
3f7bf08b12
tsan: add interface functions for unaligned access, e.g. __sanitizer_unaligned_load16
...
llvm-svn: 180780
2013-04-30 11:56:56 +00:00
Timur Iskhodzhanov
a6788325cf
Make all the ALWAYS_INLINE users Windows-friendly; also, avoid ALWAYS_INLINE INLINE combinations
...
llvm-svn: 178266
2013-03-28 18:52:40 +00:00
Dmitry Vyukov
f2cbda4082
tsan: print statistics about benign race annotations
...
(total count, unique, matched) if requested with print_benign=1
flag.
llvm-svn: 178245
2013-03-28 16:21:19 +00:00
Dmitry Vyukov
b365d40415
tsan: print matched suppressions if print_suppressions=1 flag is provided
...
llvm-svn: 178159
2013-03-27 17:59:57 +00:00
Dmitry Vyukov
4adf49d253
tsan: intercept setjmp/longjmp
...
llvm-svn: 177858
2013-03-25 10:10:44 +00:00
Dmitry Vyukov
ebf63d0095
tsan: better reporting of thread leaks
...
1. do not report running threads as leaks
2. aggregate leaked threads by creation stack
llvm-svn: 177647
2013-03-21 16:55:17 +00:00
Dmitry Vyukov
0851fa8819
tsan: better reporting for races on vptr
...
explicitly say "ctor/dtor vs virtual call"
llvm-svn: 177640
2013-03-21 15:37:39 +00:00
Dmitry Vyukov
48e5d4a2d3
tsan: flush symbolizer cache if not symbolized for more than 5 seconds
...
llvm-svn: 177629
2013-03-21 07:02:36 +00:00
Dmitry Vyukov
79915de6af
tsan: move trace header into 0x600000000000 range
...
eliminat thread "dead info" altogether
llvm-svn: 177512
2013-03-20 10:31:53 +00:00
Dmitry Vyukov
4ecfa696e0
tsan: flush dead thread info earlier (when another thread is finished rather than new thread is created)
...
llvm-svn: 177394
2013-03-19 12:25:48 +00:00
Dmitry Vyukov
4ddd37ba5b
tsan: smaller memory block headers (32b->16b)
...
llvm-svn: 177312
2013-03-18 19:47:36 +00:00
Dmitry Vyukov
2e7f29f042
tsan: mark shadow for thread stack as "don't need" when thread exits
...
llvm-svn: 177288
2013-03-18 15:49:07 +00:00
Dmitry Vyukov
20bf8c7778
tsan: move implementation out of h file
...
llvm-svn: 177269
2013-03-18 10:32:21 +00:00
Dmitry Vyukov
49e462fab2
tsan: fix clang -Wall build
...
Clang does not like classes with virtual functions but w/o virtual dtor.
Go does not like libstdc++ (operator delete).
llvm-svn: 177267
2013-03-18 10:10:15 +00:00
Dmitry Vyukov
7cd2025c4d
tsan: use StackDepot for thread creation stacks
...
llvm-svn: 177261
2013-03-18 09:02:27 +00:00
Alexey Samsonov
9aecdfe34d
[TSan] Switch TSan runtime to use ThreadRegistry class from sanitizer_common
...
llvm-svn: 177154
2013-03-15 13:48:44 +00:00
Dmitry Vyukov
3c2489e2c3
tsan: do not imitate memory write on malloc() (Go)
...
better memory range access functions (put only 1 event to trace) (Go)
llvm-svn: 175056
2013-02-13 13:05:36 +00:00
Alexey Samsonov
85cc9b655d
[TSan] skip multiple internal frames, if necessary
...
llvm-svn: 174516
2013-02-06 16:28:05 +00:00
Kostya Serebryany
4fb340d972
[tsan] print error summary line
...
llvm-svn: 174505
2013-02-06 14:24:00 +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
71242b064e
tsan: flip is_write bit in shadow to is_read
...
this makes calculation of interesting predicates faster
llvm-svn: 174164
2013-02-01 10:02:55 +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
019ef67a97
tsan: dump stack on internal assert failure
...
llvm-svn: 173799
2013-01-29 14:20:12 +00:00
Dmitry Vyukov
b46930befa
tsan: remember when we are inside of symbolizer code (required for inprocess symbolizer)
...
llvm-svn: 173796
2013-01-29 13:03:07 +00:00
Dmitry Vyukov
f4f76b1c10
tsan: suppress reports using both stacks
...
llvm-svn: 173346
2013-01-24 13:50:32 +00:00
Kostya Serebryany
6f604b5007
[asan/tsan] when unmapping a chunk of user memory, apply madvise(MADV_DONTNEED) to the corresponding chunk of shadow memory. Also update sanitizer_allocator64_testlib.cc
...
llvm-svn: 171144
2012-12-27 07:37:24 +00:00
Dmitry Vyukov
2547ac65eb
tsan: java interface implementation skeleton
...
llvm-svn: 170707
2012-12-20 17:29:34 +00:00
Dmitry Vyukov
09b0dbfaf9
tsan: say what thread had created a thread in reports
...
llvm-svn: 170346
2012-12-17 16:28:15 +00:00
Dmitry Vyukov
3e7ede230f
tsan: support MapThreadTrace() on all platforms
...
llvm-svn: 170113
2012-12-13 08:14:02 +00:00
Kostya Serebryany
e29883c10a
[sanitizer] add OnMap/OnUmap callbacks to the allocator interface
...
llvm-svn: 169985
2012-12-12 14:32:18 +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
Kostya Serebryany
571232b8cf
[tsan] get rid of *allocator64* files, moving everything to *allocator* files. This will help with the 32-bit allocator implementation and testing
...
llvm-svn: 169368
2012-12-05 10:09:15 +00:00
Dmitry Vyukov
1b46993598
tsan: output thread names
...
llvm-svn: 169279
2012-12-04 15:46:05 +00:00
Kostya Serebryany
242b6305f0
[tsan] add a compile-time error for 64-bit-only support
...
llvm-svn: 169275
2012-12-04 15:13:30 +00:00
Kostya Serebryany
f299288f55
[tsan] minor interface refactoring
...
llvm-svn: 169267
2012-12-04 14:15:17 +00:00
Dmitry Vyukov
55b47cad33
tsan: fix trace handling when trace is reused between threads
...
llvm-svn: 169259
2012-12-04 12:19:53 +00:00
Dmitry Vyukov
e993dac233
tsan: fix int overflow and several instances where tid is used with ignore
...
llvm-svn: 169029
2012-11-30 20:02:11 +00:00
Dmitry Vyukov
eb3d36e649
tsan: address several review comments
...
llvm-svn: 168789
2012-11-28 13:01:32 +00:00
Dmitry Vyukov
e1a7f338a3
tsan: dynamic history size
...
introduces history_size parameter that can be used to control trace size at startup
llvm-svn: 168786
2012-11-28 12:19:50 +00:00
Dmitry Vyukov
00e4604d6b
tsan: change fast state layout in preparation to dynamic traces
...
llvm-svn: 168784
2012-11-28 10:49:27 +00:00
Dmitry Vyukov
2429b02770
tsan: move traces from tls into dedicated storage at fixed address
...
helps to reduce tls size (it's weird to have multi-MB tls)
will help with dynamically adjustable trace size
llvm-svn: 168783
2012-11-28 10:35:31 +00:00
Dmitry Vyukov
20678e2b68
tsan: explicitly mark symbols referenced from assembly as hidden
...
this allows to build tsan runtime as dynamic library
llvm-svn: 168589
2012-11-26 14:20:26 +00:00
Dmitry Vyukov
933c9889aa
tsan: remove unused parameter
...
llvm-svn: 168060
2012-11-15 18:49:08 +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
6d67d3b0ee
tsan: remove unused const
...
llvm-svn: 167835
2012-11-13 14:13:21 +00:00
Dmitry Vyukov
67dc5702f8
tsan: do not sleep at exit if there are no other threads
...
llvm-svn: 167533
2012-11-07 16:41:57 +00:00
Dmitry Vyukov
e11f2920c9
tsan: more precise handling of finalizers
...
llvm-svn: 167530
2012-11-07 15:08:20 +00:00
Dmitry Vyukov
c015712992
tsan: lazily allocate shadow for Go
...
llvm-svn: 167464
2012-11-06 16:00:16 +00:00
Alexey Samsonov
ad9d65feb8
[TSan] finally remove TsanPrintf in favor of Printf from sanitizer_common
...
llvm-svn: 167294
2012-11-02 12:17:51 +00:00
Dmitry Vyukov
90c9cbfed4
tsan: cache pc's that cause suppressions (this way we do not need to symbolize the reports)
...
llvm-svn: 165317
2012-10-05 15:51:32 +00:00
Dmitry Vyukov
56faa551b9
tsan: fix mac build
...
llvm-svn: 165004
2012-10-02 12:58:14 +00:00
Dmitry Vyukov
27d5b37c38
tsan: output tid's in reports
...
llvm-svn: 164998
2012-10-02 11:52:05 +00:00
Alexey Samsonov
b6879ce94c
[TSan] move replacement for new/delete back into tsan_interceptors
...
llvm-svn: 164764
2012-09-27 09:50:19 +00:00
Alexey Samsonov
313014694f
[TSan] Provide replacements for operators new/delete instead of declaring extern C functions with weirdly mangled names (same strategy is used in ASan).
...
llvm-svn: 164487
2012-09-24 13:19:47 +00:00
Alexey Samsonov
046248c509
[TSan] fix a bunch of warnings reported by pedantic gcc
...
llvm-svn: 163788
2012-09-13 11:54:41 +00:00
Alexey Samsonov
5c6b93bc33
[Sanitizer] Get rid of dependency between sanitizer_common and asan/tsan runtimes: implement tool-specific Die and CheckFailed functions via callbacks
...
llvm-svn: 163603
2012-09-11 09:44:48 +00:00
Dmitry Vyukov
b7f1852140
tsan: insert cfi directives into assembly (not fully working for now, though)
...
llvm-svn: 163090
2012-09-02 11:24:07 +00:00
Dmitry Vyukov
46ca1fb404
tsan: better diagnostics for mutex misuse
...
llvm-svn: 163060
2012-09-01 12:13:18 +00:00
Dmitry Vyukov
318f77749e
tsan: add "as if synchronized via sleep" feature
...
llvm-svn: 163006
2012-08-31 17:27:49 +00:00
Dmitry Vyukov
191f2f7cdb
tsan: use stack depot to describe heap blocks
...
llvm-svn: 162902
2012-08-30 13:02:30 +00:00
Dmitry Vyukov
3482ec3bc8
tsan: better diagnostics for destroy of a locked mutex + a test
...
llvm-svn: 162022
2012-08-16 15:08:49 +00:00
Dmitry Vyukov
4723e6b1e5
tsan: implement RWLOCK annotations
...
llvm-svn: 162019
2012-08-16 13:29:41 +00:00
Dmitry Vyukov
f77c6ea7ea
tsan: fix COMPAT shadow mapping for new memory allocator
...
llvm-svn: 162018
2012-08-16 13:27:25 +00:00
Dmitry Vyukov
9f1509fe44
tsan: provide function that imitates write to a region but does not detect races
...
llvm-svn: 161957
2012-08-15 16:52:19 +00:00
Dmitry Vyukov
954fc8c3e4
tsan: switch to new allocator
...
llvm-svn: 161953
2012-08-15 15:35:15 +00:00
Dmitry Vyukov
904d3f9c06
tsan: add ReleaseStore() function that merely copies vector clock rather than combines two clocks
...
fix clock setup for finalizer goroutine (Go runtime)
llvm-svn: 160918
2012-07-28 15:27:41 +00:00
Dmitry Vyukov
dfc8e52400
tsan: suport for Go finalizers
...
llvm-svn: 160723
2012-07-25 13:16:35 +00:00
Dmitry Vyukov
5bfac97ff9
tsan: use dynamic shadow stack for Go
...
llvm-svn: 160288
2012-07-16 16:44:47 +00:00
Dmitry Vyukov
03d32ecd4f
tsan: Go language support
...
llvm-svn: 159754
2012-07-05 16:18:28 +00:00
Dmitry Vyukov
fa985a02ef
tsan: fix crashes if signal is caught during thread bootstrap or shutdown
...
llvm-svn: 159361
2012-06-28 18:07:46 +00:00
Dmitry Vyukov
97c26bdaea
tsan: refactor signal handling code (move some definitions out of common header)
...
llvm-svn: 159266
2012-06-27 16:05:06 +00:00
Dmitry Vyukov
de1fd1c83b
tsan: do not call malloc/free in memory access handling routine.
...
This improves signal-/fork-safety of instrumented programs.
llvm-svn: 158988
2012-06-22 11:08:55 +00:00
Alexey Samsonov
d323f4e78e
[Sanitizer] Remove __attribute__((format))
...
llvm-svn: 158070
2012-06-06 13:58:39 +00:00
Alexey Samsonov
51ae983718
[Sanitizer]: Introduce a common internal printf function. For now, also use tool-specific wrappers TsanPrintf (its output is controlled by TSan flags) and AsanPrintf (which copies its results to the ASan-private buffer). Supported formats: %[z]{d,u,x}, %s, %p. Re-write all format strings in TSan according to this format (this should have no effect on 64-bit platforms).
...
llvm-svn: 158065
2012-06-06 13:11:29 +00:00
Alexey Samsonov
ac4c290d02
[TSan] run some renaming as a preparation for factoring out Printf implementation.
...
llvm-svn: 158058
2012-06-06 10:13:27 +00:00
Alexey Samsonov
bc3a7e3fe2
[Sanitizer] add sanitizer_common.h for routines shared between TSan and ASan runtimes. Use __sanitizer::Die() in TSan.
...
llvm-svn: 158050
2012-06-06 06:47:26 +00:00
Dmitry Vyukov
30c32a8819
tsan: fix compilation with newest clang
...
llvm-svn: 157391
2012-05-24 14:50:33 +00:00
Dmitry Vyukov
302cebb8f1
tsan: add shadow memory flush + fix few bugs
...
llvm-svn: 157270
2012-05-22 18:07:45 +00:00
Dmitry Vyukov
f6985e3ab9
tsan: reduce per-thread memory usage
...
llvm-svn: 157252
2012-05-22 14:34:43 +00:00
Dmitry Vyukov
163a8338be
tsan: replace CHECK with CHECK_EQ for better diagnostics
...
llvm-svn: 157181
2012-05-21 10:20:53 +00:00
Dmitry Vyukov
98953b7a6d
tsan: better, more realistic handling of signals
...
llvm-svn: 157178
2012-05-21 08:26:51 +00:00
Dmitry Vyukov
19b855fe3e
tsan: remove shutdown code
...
tsan runtime shutdown is problematic for 2 reasons:
1. others crash during shutdown
2. we have to override user exit status (don't know it and can't return from atexit handler)
llvm-svn: 156991
2012-05-17 15:00:27 +00:00
Dmitry Vyukov
fee5b7d2e0
tsan: detect accesses to freed memory
...
http://codereview.appspot.com/6214052
llvm-svn: 156990
2012-05-17 14:17:51 +00:00
Dmitry Vyukov
665ce2a2f4
tsan: enabled report suppression for signal-unsafe reports
...
llvm-svn: 156765
2012-05-14 15:28:03 +00:00
Kostya Serebryany
07c4805175
[tsan] run more kinds of builds as presubmit test (and fix gcc debug build)
...
llvm-svn: 156616
2012-05-11 14:42:24 +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