Commit Graph

4513 Commits

Author SHA1 Message Date
Alexey Samsonov d2c20c49f8 [Sanitizer] Move TemplateMatch() to sanitizer_common.cc. NFC.
llvm-svn: 229923
2015-02-19 22:56:47 +00:00
Timur Iskhodzhanov 2462a2f404 [ASan/Win] Thread sanitizer common interface through asan_win_dll_thunk.cc
llvm-svn: 229860
2015-02-19 15:25:26 +00:00
Timur Iskhodzhanov 7a010dc5e7 [Sanitizers] Move the common sanitizer interface from sanitizer_internal_defs.h to a new sanitizer_interface_internal.h file
Reviewed at http://reviews.llvm.org/D7758

llvm-svn: 229858
2015-02-19 15:15:33 +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
Mohit K. Bhakkad 36f974d76b [LSan] [MIPS] adding support of LSan for mips64/mips64el arch
Patch by Sagar Thakur

Reviewers: petarj, earthdok, kcc.

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

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

llvm-svn: 229830
2015-02-19 07:30:39 +00:00
Alexey Samsonov d311566e1a Remove support for building sanitizers from Makefile/autoconf build on Linux.
This is a re-application of r229554 restricted to Linux build only.
Apple still uses Makefile/autoconf to build Clang and sanitizers.

llvm-svn: 229756
2015-02-18 22:26:49 +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
Dmitry Vyukov 2a80437038 tsan: add -Wno-maybe-uninitialized to mingw gcc build flags
As per discussion with David Blaikie here:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20150216/260289.html

llvm-svn: 229657
2015-02-18 09:37:31 +00:00
Mohit K. Bhakkad b40fed04e7 [MSan][MIPS] Fix for some failing tests on MIPS64
Enabling internal ptrace for mips, which fixes some
ptrace related tests. Along with this fixing some
other failures.

Reviewers: Reviewers: eugenis, kcc, samsonov

Subscribers: dsanders, sagar, lldb-commits

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

llvm-svn: 229656
2015-02-18 09:24:19 +00:00
Matthias Braun c0a2279099 Revert "Remove support for building sanitizers from Makefile/autoconf build."
This reverts commit r229556.

Reverting this for now as internal apple builds rely on this
functionality.

llvm-svn: 229585
2015-02-17 23:30:51 +00:00
Alexey Samsonov e194dfa6be [TSan] Provide default values for compile definitions.
Provide defaults for TSAN_COLLECT_STATS and TSAN_NO_HISTORY.
Replace #ifdef directives with #if. This fixes a bug introduced
in r229112, where building TSan runtime with -DTSAN_COLLECT_STATS=0
would still enable stats collection and reporting.

llvm-svn: 229581
2015-02-17 23:23:10 +00:00
Reid Kleckner 6fec509ac7 Silence an MSVC warning about testing a function for truth without calling it
In general, this is a reasonable warning, except real_pthread_create is
weak and can be null.  The existing usage is correct as it the function
is declared with SANITIZER_WEAK, but MSVC can't know that because it is
defined to nothing on Windows.

llvm-svn: 229562
2015-02-17 21:57:42 +00:00
Alexey Samsonov d907016dd0 Remove support for building sanitizers from Makefile/autoconf build.
They autotools build has a number of missing features, supports less
OS, architectures, build configurations, doesn't have any tests and
is hard to support in sync with CMake build.

llvm-svn: 229556
2015-02-17 21:53:45 +00:00
Alexey Samsonov 79df187034 [LSan] Make parent tool responsible for initializing LSan flags.
Summary:
LSan can be combined with a parent tool (for now it's only ASan).
Also, we allow LSAN_OPTIONS to override certain common flags. It means
we have to parse LSAN_OPTIONS early enough, before the rest of the
parent tool (including chunks of sanitizer_common) is initialized.

In future, we can use the same approach for UBSan, after we embed it
into ASan runtime in a similar way.

Test Plan: regression test suite

Reviewers: earthdok, eugenis

Subscribers: llvm-commits

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

llvm-svn: 229519
2015-02-17 18:50:30 +00:00
Dimitry Andric 7a9afba9ad Remove inclusion of netinet/ip_compat.h for FreeBSD. This header is not
always available, and nothing in sanitizer_platform_limits_posix.cc uses
any of its definitions.

See also: https://svnweb.freebsd.org/changeset/base/277201

Reviewers: kcc, kutuzov.viktor.84, samsonov
Reviewed By: samsonov
Differential Revision: http://reviews.llvm.org/D7486

llvm-svn: 229518
2015-02-17 18:27:39 +00:00
Viktor Kutuzov dd82236273 [Msan] Fix the unit tests' PathToLoadable() to work on FreeBSD
Differential Revision: http://reviews.llvm.org/D7587

llvm-svn: 229491
2015-02-17 12:52:08 +00:00
Evgeniy Stepanov 5c6de59ec4 [msan] Fix UnalignedLoad/UnalignedStore tests.
Add alignment attrubutes to ensure that the tests actually test unaligned
access irrespective of the stack layout.

llvm-svn: 229398
2015-02-16 15:05:14 +00:00
Dmitry Vyukov 620ebaa9c1 tsan: remove everything related to rss/background thread in Go mode
In Go mode the background thread is not started (internal_thread_start is empty).
There is no sense in having this code compiled in.
Also removes dependency on sanitizer_linux_libcdep.cc which is good,
ideally Go runtime does not depend on libc at all.

llvm-svn: 229396
2015-02-16 14:49:34 +00:00
Dmitry Vyukov 3ac5c27c1f tsan: fix freebsd build
GetTls is not defined in Go mode.

llvm-svn: 229395
2015-02-16 14:35:51 +00:00
Dmitry Vyukov 1236868f85 tsan: fix windows build script
add missing source files
+ add -std=c++11 as it is now required to build compiler-rt

llvm-svn: 229393
2015-02-16 13:54:32 +00:00
Dmitry Vyukov 78c25941ba tsan: fix compiler warning
mingw gcc complains:
warning: 'err' may be used uninitialized in this function [-Wmaybe-uninitialized]
       Printf("Failed to read options from '%s': error %d\n", value, err);

llvm-svn: 229392
2015-02-16 13:53:00 +00:00
Dmitry Vyukov 13fd535bcb tsan: fix shadow memory mapping on windows
llvm-svn: 229391
2015-02-16 13:52:04 +00:00
Dmitry Vyukov b3381fad11 tsan: exclude DumpProcessMap on windows
The function uses EnumProcessModules, which requires psapi.lib,
which is not linked with tsan on windows.

llvm-svn: 229390
2015-02-16 13:51:17 +00:00
Viktor Kutuzov 37a79210cb [Msan] Improve the EXPECT_NOT_POISONED() macro to provide the original line number
Differential Revision: http://reviews.llvm.org/D7341

llvm-svn: 229389
2015-02-16 13:30:52 +00:00
Viktor Kutuzov b1f54eeed4 [Msan] Make unit tests that use mempcpy() passing on FreeBSD
Differential Revision: http://reviews.llvm.org/D7588

llvm-svn: 229388
2015-02-16 13:26:32 +00:00
Viktor Kutuzov 1a55126699 [Msan] Disable the fgetgrent_r unit test on FreeBSD
Differential Revision: http://reviews.llvm.org/D7343

llvm-svn: 229387
2015-02-16 13:24:21 +00:00
Viktor Kutuzov f886b38a0e [Msan] Disable fcvt unit tests on FreeBSD
Differential Revision: http://reviews.llvm.org/D7340

llvm-svn: 229386
2015-02-16 13:22:07 +00:00
Viktor Kutuzov 4772b9c843 [Msan] Fix the getgrnam_r unit test to pass on FreeBSD
Differential Revision: http://reviews.llvm.org/D7339

llvm-svn: 229385
2015-02-16 13:19:21 +00:00
Viktor Kutuzov 2e19f31560 [Msan] Fix the sigaction unit test to build on FreeBSD
Differential Revision: http://reviews.llvm.org/D7335

llvm-svn: 229384
2015-02-16 13:15:58 +00:00
Viktor Kutuzov 7eff71a474 [Msan] Fix the ether unit test to build on FreeBSD
Differential Revision: http://reviews.llvm.org/D7334

llvm-svn: 229383
2015-02-16 13:13:53 +00:00
Evgeniy Stepanov 84d30ba43a [asan] Support 'su' rooted devices in ASan setup script.
Android devices may not support 'adb root', but be rooted with 'su'
binary. This patch makes it possible to install ASAN to such
devices. When --use-su flag is specified, most 'adb ...' commangs are
changed to 'adb su -c "..."'.

Some other notes:
 * 'readlink' changed to 'ls -l', since not all devices have readlink
   in their firmware.
 * removing ASan library step moved to very end, because 'su' may not
   run properly without this library until shell will be restarted.

Patch by Dmitry <ripp at yandex-team dot ru>.

llvm-svn: 229368
2015-02-16 10:22:12 +00:00
Dmitry Vyukov a3bdbadfd2 tsan: fix build
Revision 229127 introduced a bug:
zero value is not OK for trace headers,
because stack0 needs constructor call.
Instead unmap the unused part of trace after
all ctors have been executed.

llvm-svn: 229263
2015-02-14 16:14:10 +00:00
Dmitry Vyukov 6aaedb0829 tsan: always subtract one from program counters
Go has a pending change to pass proper PCs to tsan:
https://go-review.googlesource.com/#/c/4902/
So now we can always subtract one from PCs.

llvm-svn: 229262
2015-02-14 16:06:22 +00:00
Dmitry Vyukov 8a9d23bf53 tsan: don't initialize trace header in release mode
We are going to use only a small part of the trace with the default
value of history_size. However, the constructor writes to the whole trace.
It writes mostly zeros, so freshly mmaped memory will do.
The only non-zero field if mutex type used for debugging.

Reduces per-goroutine overhead by 8K.

https://code.google.com/p/thread-sanitizer/issues/detail?id=89

llvm-svn: 229127
2015-02-13 17:39:03 +00:00
Dmitry Vyukov b57e39e310 tsan: fix build
llvm-svn: 229120
2015-02-13 16:08:43 +00:00
Dmitry Vyukov 816bf44ac6 tsan: reduce history size in Go mode
The ContainsSameAccess optimization substantially reduces pressure
on trace by eliminating duplicate accesses. So now we can reduce
default trace size to reduce per-goroutine memory consumption.
Current default size is 64K events, new -- 32K events.
In either case user can change it with GORACE env var.

Reduces per-goroutine memory consumption from 356K to 226K.

llvm-svn: 229117
2015-02-13 15:59:23 +00:00
Dmitry Vyukov 05841b1e39 tsan: disable deadlock detector in Go mode
Go does not use that.
https://code.google.com/p/thread-sanitizer/issues/detail?id=89

llvm-svn: 229116
2015-02-13 15:44:50 +00:00
Dmitry Vyukov a22870ec7a tsan: remove internal deadlock detector from ThreadState in Go mode
Go does not use that.
https://code.google.com/p/thread-sanitizer/issues/detail?id=89

llvm-svn: 229115
2015-02-13 15:37:11 +00:00
Dmitry Vyukov c30c5f7d9d tsan: reduce size of vector clock in Go mode
Go does not have freed memory.
Reduces per-goroutine overhead from 455K to 356K.

https://code.google.com/p/thread-sanitizer/issues/detail?id=89

llvm-svn: 229113
2015-02-13 15:32:34 +00:00
Dmitry Vyukov 41f4eba02d tsan: remove stats from ThreadState ifndef TSAN_COLLECT_STATS
Issue 89: Uses a lot of memory for each goroutine
https://code.google.com/p/thread-sanitizer/issues/detail?id=89

llvm-svn: 229112
2015-02-13 15:25:47 +00:00
Dmitry Vyukov af3b09663b tsan: fix stack printing
strip_path_prefix was not stripped from file names.

llvm-svn: 229106
2015-02-13 14:27:43 +00:00
Alexey Samsonov 1225816a2d [Sanitizer] Change InitializeFlags() signatures. NFC.
These functions are always used to initialize singleton flags(), as
well as other global data (common_flags()).

llvm-svn: 228894
2015-02-12 00:36:42 +00:00
Alexey Samsonov c9b0ea6eec [Sanitizer] Add "final" specifier to FlagHandlerBase::Parse overrides. NFC.
llvm-svn: 228893
2015-02-12 00:36:39 +00:00
Dimitry Andric 349e062695 [Sanitizers] The MAP_NORESERVE define has been removed in FreeBSD 11.x,
and even before that, it was never implemented.  Just define it to zero
instead, so compiler-rt can compile on FreeBSD 11 and later.

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

llvm-svn: 228871
2015-02-11 19:48:27 +00:00
Alexey Samsonov 8812e73c63 [UBSan] Allow UBSan location to store frames returned by symbolizer.
Summary:
__ubsan::getFunctionLocation() used to issue a call to symbolizer, and
convert the result (SymbolizedStack) to one of UBSan structures:
SourceLocation, ModuleLocation or MemoryLocation. This:
(1) is inefficient: we do an extra allocation/deallocation to copy data,
while we can instead can just pass SymbolizedStack around (which
contains all the necessary data).
(2) leaks memory: strings stored in SourceLocation/MemoryLocation are
never deallocated, and Filipe Cabecinhas suggests this causes crashes
of UBSan-ified programs in the wild.

Instead, let Location store a pointer to SymbolizedStack object, and
make sure it's properly deallocated when UBSan handler exits.

ModuleLocation is made obsolete by this change, and is deleted.

Test Plan: check-ubsan test suite

Reviewers: rsmith, filcab

Subscribers: llvm-commits

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

llvm-svn: 228869
2015-02-11 19:45:07 +00:00
Timur Iskhodzhanov 8a8b00b684 [ASan] Print out a diagnostic when a global is unregistered
llvm-svn: 228838
2015-02-11 15:21:09 +00:00
Justin Bogner 43b2cae82a Revert "[UBSan] Enable -Wglobal-constructors."
We're still using global constructors when not on linux, so this was
causing warnings on Darwin. Reverting for now.

This reverts r228384.

llvm-svn: 228795
2015-02-11 03:05:02 +00:00
Alexey Samsonov fa8b3db54b [UBSan] Add report deduplication for -fsanitize=function.
Summary:
Make sure we don't print the error report from -fsanitize=function
twice for the same source location, as we do in another UBSan handlers.

Test Plan: check-ubsan test suite

Reviewers: rsmith, pcc

Reviewed By: pcc

Subscribers: llvm-commits

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

llvm-svn: 228772
2015-02-11 00:05:31 +00:00
Petar Jovanovic 08fc9e9158 [mips] Add __clear_cache() definition for non-Android systems
Make sure clear_cache() builtin has an appropriate definition for Linux.
Call syscall(NR_cacheflush, ...).

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

llvm-svn: 228767
2015-02-10 23:36:19 +00:00
Kuba Brecka 9a18c3016c Fix ASan's Noinst unit tests
We currently skip all "Noinst" unit tests on OS X, which was probably caused when we removed the "allow_reexec" flag. The MaybeReexec function fails to re-execute when the runtime is linked statically, because there is no dylib to use. This patch adds an explicit DisableReexec function that is used from asan_noinst_test.cc and the runtime then doesn't try to re-execute.

Reviewed at http://reviews.llvm.org/D7493

llvm-svn: 228740
2015-02-10 20:37:57 +00:00