Commit Graph

177 Commits

Author SHA1 Message Date
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
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
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
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
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
Evgeniy Stepanov 8e27f59a1b [tsan] Disable a flaky test.
llvm-svn: 239063
2015-06-04 18:28:35 +00:00
Kostya Serebryany 7747762df9 [tsan] deflakify one more tsan test
llvm-svn: 237387
2015-05-14 20:27:12 +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
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
Dmitry Vyukov 7d6d737693 tsan: add another test for setuid
llvm-svn: 236130
2015-04-29 17:22:43 +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
Alexey Samsonov f430205b82 [TSan] Prepare TSan tests for splitting tsan_cxx library.
llvm-svn: 235927
2015-04-27 22:08:08 +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
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
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
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
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
Viktor Kutuzov 838ea617d6 [Tsan] Fix the mmap_large.cc test to build on FreeBSD
Differential Revision: http://reviews.llvm.org/D8545

llvm-svn: 233001
2015-03-23 19:40:59 +00:00
Viktor Kutuzov 281347aa59 [Tsan] Fix test.h to work on FreeBSD
Differential Revision: http://reviews.llvm.org/D8303

llvm-svn: 232167
2015-03-13 14:08:55 +00:00
Dmitry Vyukov b75212878f tsan: fix a bug in MetaMap::ResetRange
The bug was uncovered by NegativeTests.MmapTest from
data-race-test suite, so port it as well.

llvm-svn: 232032
2015-03-12 12:48:19 +00:00
Dmitry Vyukov a60829a1b6 tsan: fix crash during __tsan_java_move
Munmap interceptor did not reset meta shadow for the range,
and __tsan_java_move crashed because it encountered
non-zero meta shadow for the destination.

llvm-svn: 232029
2015-03-12 11:24:16 +00:00
Hans Wennborg 521a941074 Revert r229678 "tsan: fix signal handling during stop-the-world"
This was causing Chromium's browser_tests to flakily segfault during
leak check.

llvm-svn: 230874
2015-02-28 22:18:11 +00:00
Mohit K. Bhakkad 846de99fbd [TSan][MIPS64] Fix few more test cases for MIPS64
Patch by Sagar Thakur

Reviewers: dvyukov, samsonov, kcc.

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

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

llvm-svn: 230002
2015-02-20 09:32:45 +00:00
Dmitry Vyukov c0e912dd7b tsan: fix PTRACE_ATTACH handling during stop-the-world
If the thread receives a signal concurrently with PTRACE_ATTACH,
we can get notification about the signal before notification about stop.
In such case we need to forward the signal to the thread, otherwise
the signal will be missed (as we do PTRACE_DETACH with arg=0) and
any logic relying on signals will break. After forwarding we need to
continue to wait for stopping, because the thread is not stopped yet.
We do ignore delivery of SIGSTOP, because we want to make stop-the-world
as invisible as possible.

http://reviews.llvm.org/D7723

 --This line, and those below, will be ignored--
M    lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
M    test/tsan/signal_segv_handler.cc

llvm-svn: 229832
2015-02-19 09:02:29 +00:00
Dmitry Vyukov 8870ee7755 tsan: fix signal handling during stop-the-world
Long story short: stop-the-world briefly resets SIGSEGV handler to SIG_DFL.
This breaks programs that handle and continue after SIGSEGV (namely JVM).
See the test and comments for details.

http://reviews.llvm.org/D7722

llvm-svn: 229678
2015-02-18 15:13:29 +00:00
Alexey Samsonov 46fe4a640d [TSan] Add Go runtime sanity check to CMake build.
llvm-svn: 227852
2015-02-02 20:37:28 +00:00
Dmitry Vyukov 312ad250ff tsan: properly instrument unaligned accesses
If a memory access is unaligned, emit __tsan_unaligned_read/write
callbacks instead of __tsan_read/write.
Required to change semantics of __tsan_unaligned_read/write to not do the user memory.
But since they were unused (other than through __sanitizer_unaligned_load/store) this is fine.
Fixes long standing issue 17:
https://code.google.com/p/thread-sanitizer/issues/detail?id=17

llvm-svn: 227230
2015-01-27 20:19:12 +00:00
Dmitry Vyukov d6e0f8b6ca tsan: add test for ANNOTATE_HAPPENS_BEFORE/AFTER annotations
llvm-svn: 227190
2015-01-27 13:03:18 +00:00
David Blaikie b26513950d Fix up test cases to account for improved column fidelity provided by clang
llvm-svn: 227033
2015-01-25 04:39:06 +00:00
Dmitry Vyukov 3ab6b2347e tsan: remove sleeps from tests
Even sleep(1) lead to episodical flakes on some machines.
Use an invisible by tsan barrier to enforce required execution order instead.
This makes the tests deterministic and faster.

llvm-svn: 226659
2015-01-21 13:50:02 +00:00
David Blaikie baaaa67819 Reapply debug info changes now that more precise column information is available.
llvm-svn: 225959
2015-01-14 07:59:48 +00:00
David Blaikie 9098487213 Revert "Reapply debug info changes now that more precise column information is available."
While the clang patch is reverted pending investigation/fixes.

This reverts commit r225001.

llvm-svn: 225560
2015-01-09 23:27:12 +00:00
David Blaikie 63ac92ca28 Reapply debug info changes now that more precise column information is available.
(recommitting as the Clang patch is back in with the latest fix -
hopefully it sticks)

llvm-svn: 225001
2014-12-30 19:54:25 +00:00
David Blaikie b7373cd639 Revert "Reapply debug info changes now that r224385 has been recommitted to clang (in r224941)"
Asserting when building compiler-rt when using a gcc host compiler.
Reverting while I investigate.

This reverts commit r224942.

llvm-svn: 224969
2014-12-29 23:48:46 +00:00
David Blaikie 90b6344c56 Reapply debug info changes now that r224385 has been recommitted to clang (in r224941)
llvm-svn: 224942
2014-12-29 18:19:36 +00:00
Dmitry Vyukov c1a04162ba tsan: reset stack0 in the first partition of thread trace
stack0/mset0 contained bogus values from the previous thread
that used the same id

llvm-svn: 224702
2014-12-22 12:32:52 +00:00
Dmitry Vyukov 732b128129 tsan: add acquire/release functions to java interface
they are required to handle synchronization on volatile/final fields

llvm-svn: 224697
2014-12-22 09:44:56 +00:00
Dmitry Vyukov 76d629744b tsan: add an additional test for signal handlers
the test passes now, but signal handling during thread creation
and shutdown is tricky

llvm-svn: 224532
2014-12-18 18:40:52 +00:00
Dmitry Vyukov f7790012a5 tsan: fix data races between signal handler and sigaction
signal handler reads sa_sigaction when a concurrent sigaction call can modify it
as the result in could try to call SIG_DFL or a partially overwritten function pointer

llvm-svn: 224530
2014-12-18 18:31:47 +00:00
Filipe Cabecinhas 9fd326d4d6 Fix suppressions file usage
Summary:
Always quote suppressions files given to *_OPTIONS.
This will make it not break when given full Windows paths (otherwise,
parsing would stop after the drive's letter + ':').

Also fix one or two cases where the suppression files' extensions were
not *.supp.

Reviewers: samsonov, kcc

Subscribers: llvm-commits

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

llvm-svn: 224529
2014-12-18 18:25:18 +00:00
Dmitry Vyukov a8def72dd6 tsan: fix failing CHECK In deadlock detector
and re-enable the test

llvm-svn: 224518
2014-12-18 14:02:28 +00:00
Dmitry Vyukov 794771b08b tsan: disable the test even harder
currently it fails in cmake build with weird errors:

/tmp/real_deadlock_detector_stress_test-68a5ae.o: In function `__clang_call_terminate':
/ssd/src/llvm/projects/compiler-rt/test/tsan/real_deadlock_detector_stress_test.cc:(.text.__clang_call_terminate[__clang_call_terminate]+0x12): undefined reference to `__cxa_begin_catch'
/ssd/src/llvm/projects/compiler-rt/test/tsan/real_deadlock_detector_stress_test.cc:(.text.__clang_call_terminate[__clang_call_terminate]+0x17): undefined reference to `std::terminate()'
/tmp/real_deadlock_detector_stress_test-68a5ae.o: In function `std::vector<int, std::allocator<int> >::_M_check_len(unsigned long, char const*) const':
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_vector.h:1339: undefined reference to `std::__throw_length_error(char const*)'
/tmp/real_deadlock_detector_stress_test-68a5ae.o: In function `__gnu_cxx::new_allocator<int>::allocate(unsigned long, void const*)':
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ext/new_allocator.h:102: undefined reference to `std::__throw_bad_alloc()'
/tmp/real_deadlock_detector_stress_test-68a5ae.o:(.eh_frame+0x63): undefined reference to `__gxx_personality_v0'
clang-3.5: error: linker command failed with exit code 1 (use -v to see invocation)

llvm-svn: 224511
2014-12-18 10:55:41 +00:00
Dmitry Vyukov 8c7baa4abc tsan: add a stress test for deadlock detector
currently disabled because fails

llvm-svn: 224509
2014-12-18 10:32:48 +00:00
David Blaikie c2e03a9c0d Revert "Fix test cases given Clang's improved location information."
The Clang improevments were reverted due to failures created in an asan
bootstrap.

This reverts commit r224387.

llvm-svn: 224446
2014-12-17 19:11:27 +00:00
Dmitry Vyukov 508dd9b94c tsan: add disabled test case for issue 87
llvm-svn: 224422
2014-12-17 10:19:20 +00:00
David Blaikie 5413abf88f Fix test cases given Clang's improved location information.
llvm-svn: 224387
2014-12-16 23:07:55 +00:00
Viktor Kutuzov bf3d446528 [Tsan] Fix the signal_recursive.cc test to pass on systems with high loads
Differential Revision: http://reviews.llvm.org/D6504

llvm-svn: 224030
2014-12-11 17:42:29 +00:00