Commit Graph

5475 Commits

Author SHA1 Message Date
Kuba Brecka e4ac10179c Fix alloca_instruments_all_paddings.cc test to work under higher -O levels (compiler-rt part)
When AddressSanitizer only a single dynamic alloca and no static allocas, due to an early exit from FunctionStackPoisoner::poisonStack we forget to unpoison the dynamic alloca.  This patch fixes that.

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

llvm-svn: 230317
2015-02-24 09:47:33 +00:00
Alexey Samsonov f535d33fee [ASan] Disable strict init-order checking if dlopen() is called.
Revise the fix to https://code.google.com/p/address-sanitizer/issues/detail?id=178:
always disable strict init-order checking the first time dlopen() is
called: at this point shared library is allowed to access globals
defined in the main executable, as they are guaranteed to be
initialized. Revise the test cases:
* simplify init-order-dlopen.cc test case: make it Linux-specific
  (there's no strict init-order checking on other platforms anyway),
  and single-threaded.
* reinforce init-order-pthread-create.cc test case: make sure that
  init-order checker would produce a false positive unless we
  turn it off at the moment we call pthread_create().

llvm-svn: 230288
2015-02-24 00:37:27 +00:00
Kostya Serebryany 04d482e924 [asan] when registering globals, use the same unwinder as we use for malloc, instead of the one used for FATAL crash (which may be too slow)
llvm-svn: 230256
2015-02-23 20:40:53 +00:00
Alexey Samsonov 1f5bcbe918 Re-land part of r230171: fix GoTsanRuntimeCheck with ccache.
llvm-svn: 230247
2015-02-23 19:35:42 +00:00
Alexey Samsonov 562145c4e1 Add -fdefine-sized-deallocation to ASan test case.
This flag is now needed to force Clang emit the weak definition
of sized delete if it's not present in the header.

llvm-svn: 230242
2015-02-23 19:18:31 +00:00
Ed Schouten f6d492e683 Use compiler provided endianness definitions if available.
This makes int_endianness.h work on operating systems for which we
haven't written explicit constructs, as long as GCC or Clang are being
used.

llvm-svn: 230208
2015-02-23 09:27:49 +00:00
Ismail Pazarbasi 87f4c90a5c Unix/BSD system calls are prefixed with SYS_ on FreeBSD and Mac
Also, __syscall form should be used when one or more of the
parameters is a 64-bit argument to ensure that argument alignment
is correct.

llvm-svn: 230183
2015-02-22 22:01:09 +00:00
Renato Golin 4b1482e75c Revert "[ASan] Make the argument of '__sanitizer_annotate_contiguous_container' is not aligned error message easier to understand"
This reverts commit r230019, as it was breaking the ARM sanitizer buildbot
and let other errors be introduced since it wasn't fixed/reverted in
time.

llvm-svn: 230179
2015-02-22 18:58:18 +00:00
Dmitri Gribenko 9cbc6f42aa Revert r230171 "TSan runtime: unbreak the build with ccache"
It broke a buildbot with a non-clang (?) compiler.

llvm-svn: 230174
2015-02-22 12:20:05 +00:00
Kuba Brecka 3280dc7081 Whitespace fix for r230172.
llvm-svn: 230173
2015-02-22 11:49:21 +00:00
Kuba Brecka 11bb33c78b Fix gc-test.cc to work under higher -O levels
The gc-test.cc tries underflows of a variable up to -32 bytes, but on i386, the left redzone is not 32 bytes, it’s only 16 bytes and therefore the access to var[-32] is completely off. The reason why this test didn’t fail before is that we’ve been lucky and there was another variable before the var array, which was also instrumented. This fix uses “-32” for 64-bit systems and “-16” for 32-bit.

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

llvm-svn: 230172
2015-02-22 11:12:17 +00:00
Dmitri Gribenko bc4c42c345 TSan runtime: unbreak the build with ccache
llvm-svn: 230171
2015-02-22 11:04:59 +00:00
Peter Collingbourne 6b0d0464a8 Run simple-fail.cpp at -O{1,2,3}.
It's probably overkill to run the other tests at -O* given the increasing
combinatorial explosion.

llvm-svn: 230117
2015-02-21 01:48:51 +00:00
Peter Collingbourne f1d13da249 CFI: Add tests for 32-bit, 64-bit and memory bitsets. Break optimization in more places.
llvm-svn: 230116
2015-02-21 01:36:08 +00:00
Filipe Cabecinhas 0385152752 Don't set $LIB if we're not targetting windows.
Reviewers: timurrrr, samsonov

Subscribers: llvm-commits

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

llvm-svn: 230091
2015-02-20 23:35:19 +00:00
Peter Collingbourne e0c4f7eb81 Add test suite for the Control Flow Integrity feature.
Differential Revision: http://reviews.llvm.org/D7738

llvm-svn: 230056
2015-02-20 20:31:18 +00:00
Alexey Samsonov d1c318657b [Sanitizer] Refactor SuppressionContext class.
SuppressionContext is no longer a singleton, shared by all sanitizers,
but a regular class. Each of ASan, LSan, UBSan and TSan now have their
own SuppressionContext, which only parses suppressions specific to
that sanitizer.

"suppressions" flag is moved away from common flags into tool-specific
flags, so the user now may pass
  ASAN_OPTIONS=suppressions=asan_supp.txt LSAN_OPIONS=suppressions=lsan_supp.txt
in a single invocation.

llvm-svn: 230026
2015-02-20 17:41:59 +00:00
Timur Iskhodzhanov 8af971b267 [ASan] Make the argument of '__sanitizer_annotate_contiguous_container' is not aligned error message easier to understand
llvm-svn: 230019
2015-02-20 15:45:51 +00:00
Timur Iskhodzhanov d3e81e9625 [ASan/Win] Work around PR22545 - unregister globals when using the MD runtime
llvm-svn: 230018
2015-02-20 15:34:16 +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
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
Filipe Cabecinhas a1225be1ea Make FileCheck be a common dependency, not an ASan one.
Summary:
It still gets picked up by ASan, but it also gets picked up by the other
test suites.

Otherwise, some test suites (e.g: UBSan) would complain they had no
dependencies, and wouldn't run.

Reviewers: samsonov, eugenis

Subscribers: llvm-commits

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

llvm-svn: 229962
2015-02-20 03:41:07 +00:00
Alexey Samsonov 36afc349e8 [Sanitizer] Remove multiline comment to silence GCC warning. NFC.
llvm-svn: 229948
2015-02-20 01:45:51 +00:00
Kostya Serebryany 885994618c [sanitizer] when dumping the basic block trace, also dump the module names. Patch by Laszlo Szekeres
llvm-svn: 229940
2015-02-20 00:30:44 +00:00
Alexey Samsonov 1ec3c5bc99 [Sanitizer] Drop LibIgnore dependency on SuppressionContext. NFC.
Let each LibIgnore user (for now it's only TSan) manually go
through SuppressionContext and pass ignored library templates to
LibIgnore.

llvm-svn: 229924
2015-02-19 22:56:49 +00:00
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
Mohit K. Bhakkad 88077324c6 [LSan][MIPS64] Enable LSan testing for mips64/mips64el
Patch by Sagar Thakur

Reviewers: petarj, earthdok, kcc.

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

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

llvm-svn: 229833
2015-02-19 09:14:43 +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
Renato Golin 67bf4bd316 Revert "Enable ASAN build and test on AArch64"
This reverts commit r229665. It seems that the AArch64 ASAN tests, that
pass on all our internal machines, doesn't like the public buildbot.

Turning this off until we can investigate the public bot for a better
understanding.

llvm-svn: 229739
2015-02-18 20:30:32 +00:00
Greg Fitzgerald 127f4e5c6a [ASan] Set DYLD_LIBRARY_PATH on Darwin
Differential Revision: http://reviews.llvm.org/D7706

llvm-svn: 229714
2015-02-18 18:26:58 +00:00
Timur Iskhodzhanov 805d807139 [ASan/Win] Speculative fix to make the sed command line work with all sed implementations
llvm-svn: 229679
2015-02-18 15:14:07 +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
Renato Golin ee130d1c2a Enable ASAN build and test on AArch64
llvm-svn: 229665
2015-02-18 11:34:41 +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 c12cc5eba8 WinASan: Fix escaping in dll_host.cc test to work with internal shell
llvm-svn: 229570
2015-02-17 22:22:20 +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
Reid Kleckner 7885776604 Use lit's internal shell when running tests on Windows
The internal shell is faster and more predictable than any copy of
bash.exe on the user's system.

LLVM and Clang use the internal shell by default, and have an
environment variable to disable it. I don't think compiler-rt needs that
complexity, so I left it out.

llvm-svn: 229560
2015-02-17 21:57:10 +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
Timur Iskhodzhanov f220f88fc9 [ASan/Win] Add an OOM test
llvm-svn: 229399
2015-02-16 15:24:20 +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
Viktor Kutuzov 0247b970c4 [Asan] Fix the dlclose-test.cc unit test to build on FreeBSD 11
Differential Revision: http://reviews.llvm.org/D7586

llvm-svn: 229381
2015-02-16 13:11:09 +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
Filipe Cabecinhas 8cabc53215 Use @LINE instead of hardcoded line numbers
llvm-svn: 229190
2015-02-14 00:09:09 +00:00
Filipe Cabecinhas 22bba5dd4b Add -frtti to tests that need rtti
llvm-svn: 229184
2015-02-13 23:19:23 +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
Alexey Samsonov 1923595b4f [UBSan] Reduce the number of getCallerLocation() calls.
getCallerLocation() is expensive as it issues a call to symbolizer.
(In fact, this function has a memory leak at the moment, but this
will be fixed in the nearest future). We should only call it if
we're actually going to print an error report, in particular,
once for every reported source location.

__ubsan_handle_type_mismatch: call getCallerLocation() only if
provided source location is invalid, and only if the report is not
deduplicated.

__ubsan_handle_float_cast_overflow: call getSourceLocation with
correct CallerPC (the one in user code, not in UBSan handler). Source
location for this check is not currently emitted by frontend.

llvm-svn: 228732
2015-02-10 19:50:20 +00:00
Timur Iskhodzhanov 8ce4a069e4 [ASan/Win] NFC, just minor simplification of the code
llvm-svn: 228702
2015-02-10 16:29:05 +00:00
Timur Iskhodzhanov 54cc5b6fc8 [ASan/Win] Add the executable's directory to the symbol search path
This should fix symbolization in those cases when the .exe file is moved together with the .pdb

llvm-svn: 228701
2015-02-10 16:17:01 +00:00
Alexey Samsonov e977a8c747 [ASan] Add missing RUN: prefix.
llvm-svn: 228651
2015-02-10 01:55:02 +00:00
Alexey Samsonov 54a0e40442 [CMake] PowerPC: detect host endianness to build corresponding version of runtimes.
Prior to this change we built two identical runtimes, named "powerpc64"
and "powerpc64le", while their actual endianness matched the host
endianness.

llvm-svn: 228650
2015-02-10 01:42:44 +00:00
Timur Iskhodzhanov 758ac94ee2 [ASan/Win] Add a test case for PR22431
llvm-svn: 228573
2015-02-09 12:47:51 +00:00
Kuba Brecka bb39671516 [compiler-rt] Make MaybeReexec properly process DYLD_INSERT_LIBRARIES when using non-absolute paths
MaybeReexec() in asan_mac.cc checks for presence of the ASan dylib in DYLD_INSERT_LIBRARIES, and if it is there, it will process this env. var. and remove the dylib from its value, so that spawned children don't have this variable set. However, the current implementation only works when using a canonical absolute path to the dylib, it fails to remove the dylib for example when using @executable_path.

This patch changes the processing of DYLD_INSERT_LIBRARIES to comparing values only based on filenames (ignoring directories).

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

llvm-svn: 228392
2015-02-06 12:07:29 +00:00
Yury Gribov 55aae51325 [UBSan] Enable -Wglobal-constructors.
llvm-svn: 228384
2015-02-06 05:53:08 +00:00
Alexander Potapenko 1c4d621556 [ASan] Fix interface_symbols_darwin.c test
by manually adding __asan_mz_* to the generated interface functions list.

Declaring these functions in asan_interface_internal.h doesn't work quite well:
their prototypes must match the prototypes of zone functions in malloc/malloc.h,
but some of the types (e.g. malloc_zone_t and size_t) aren't available in
asan_interface_internal.h

llvm-svn: 228290
2015-02-05 13:07:50 +00:00
Juergen Ributzka 6e25858b5c Revert "[ASan] Add the new __asan_mz_* symbols to asan_interface_internal.h"
Reverting r228137 to unbreak the build bots.

llvm-svn: 228172
2015-02-04 19:14:35 +00:00
Alexander Potapenko 42fa73cef0 [ASan] Add the new __asan_mz_* symbols to asan_interface_internal.h
to fix the interface_symbols_darwin.c test.

llvm-svn: 228137
2015-02-04 12:42:12 +00:00
Viktor Kutuzov 2ea54bcb28 [Msan] Fix the pthread_attr_get unit test to build on FreeBSD
Differential Revision: http://reviews.llvm.org/D7342

llvm-svn: 228125
2015-02-04 09:08:00 +00:00
Kostya Serebryany 77cc729ad7 [sanitizer] add another workaround for PR 17409: when over a threshold emit coverage instrumentation as calls.
llvm-svn: 228102
2015-02-04 01:21:45 +00:00
Renato Golin b61cd95431 Revert "Enabling testing ASAN on AArch64"
This reverts commit r227966, which turned ASAN on on AArhc64 and may be the
cause of the bots never finishing the check-all. I'll re-apply once we're
sure that bot can cope with it.

llvm-svn: 228023
2015-02-03 20:23:00 +00:00
Kostya Serebryany cc0c773f76 [sanitizer] move the coverage interface into a separate header, <sanitizer/coverage_interface.h>. NFC, except for the header name change. This may break existing users, but in this case it's better this way (not too many users so far)
llvm-svn: 228017
2015-02-03 19:40:53 +00:00
Alexey Samsonov 9cea2c1035 [ASan] Run tests with both static and dynamic runtime on Windows by default.
llvm-svn: 228001
2015-02-03 18:40:34 +00:00
Alexander Potapenko 270000c194 [ASan] Remove ifdefs for MAC_OS_X_VERSION_10_6, as ASan assumes OSX >= 10.6
llvm-svn: 227968
2015-02-03 12:47:15 +00:00
Alexander Potapenko f203ba35f1 [ASan] Add __asan_ prefix for "mz_*" allocation/deallocation functions
and make them global so that they're not removed by `strip -x`.

llvm-svn: 227967
2015-02-03 12:38:10 +00:00
Renato Golin af1f7d759f Enabling testing ASAN on AArch64
Also, disabling BuiltinLongJmpTest, as it fails for ARM and PPC as well.

Patch by Christophe Lyon.

llvm-svn: 227966
2015-02-03 11:26:52 +00:00
Yury Gribov 8f848ff5ed [ASan] Add use_madv_dontdump flag.
Differential Revision: http://reviews.llvm.org/D7294

llvm-svn: 227959
2015-02-03 10:15:15 +00:00
Stephen Hines 4e52d78767 Remove invalid const qualifier for r0, since it is written by svc.
Summary: This causes an invalid lvalue error when building for Android.

Reviewers: danalbert

Reviewed By: danalbert

Subscribers: llvm-commits

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

llvm-svn: 227907
2015-02-03 01:35:39 +00:00
Alexey Samsonov ec80d97c77 [TSan] Fix remaining bashism in buildgo.sh script.
llvm-svn: 227893
2015-02-02 23:14:46 +00:00
Alexey Samsonov d45837155d [TSan] Update check_analyze.sh expectations to match trunk Clang output.
llvm-svn: 227877
2015-02-02 22:17:23 +00:00
Alexey Samsonov 1270c530e8 [TSan] Fix Go sanity check script.
llvm-svn: 227870
2015-02-02 22:07:39 +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
Alexey Samsonov 1ad375d034 [Sanitizer] Fix checking for weak function presence.
llvm-svn: 227851
2015-02-02 20:37:26 +00:00
Alexey Samsonov c91ffd2c8f [TSan] Build runtime with -msse3 flag.
llvm-svn: 227850
2015-02-02 20:37:25 +00:00
Timur Iskhodzhanov e5935ef0c4 [ASan/Win] Add some diagnostics to help investigate Mprotect failures
llvm-svn: 227803
2015-02-02 15:04:23 +00:00
Timur Iskhodzhanov 82cd135738 [ASan/Win] Add a test case for r208215 [stack buffer overflow in <iostream>]
The issue re-appears if one uses the -fsanitize-blacklist= flag,
so it's time to have a test case.

llvm-svn: 227799
2015-02-02 12:31:11 +00:00
Viktor Kutuzov 4cd3ee38e4 Fix missed #endif in rL227790.
llvm-svn: 227797
2015-02-02 10:48:38 +00:00
Viktor Kutuzov 1f83bbb6fe [Sanitizers] Intercept ether functions on FreeBSD
Committed unreviewed with permission.

llvm-svn: 227795
2015-02-02 10:00:23 +00:00
Viktor Kutuzov 1a3889da34 [Sanitizers] Intercept memrchr() on FreeBSD
Committed unreviewed with permission.

llvm-svn: 227794
2015-02-02 09:58:30 +00:00
Viktor Kutuzov bb8bd90b06 [Sanitizers] Intercept getpwnam_r() on FreeBSD
Committed unreviewed with permission.

llvm-svn: 227793
2015-02-02 09:56:11 +00:00
Viktor Kutuzov 3ac0eb7480 [Sanitizers] Intercept getpwent_r() on FreeBSD
Committed unreviewed with permission.

llvm-svn: 227792
2015-02-02 09:53:02 +00:00
Viktor Kutuzov fc44a096a9 [Sanitizers] Intercept getpwent() on FreeBSD
Committed unreviewed with permission.

llvm-svn: 227791
2015-02-02 09:49:28 +00:00
Viktor Kutuzov 0c0ebaa79f [Msan] Disable unit tests for non-FreeBSD functions on FreeBSD
Differential Revision: http://reviews.llvm.org/D7252

llvm-svn: 227790
2015-02-02 09:46:07 +00:00
Viktor Kutuzov 7891c8c173 [Sanitizers] Re-apply the fix ordering initialization of coverage and guard arrays
Original commit: http://reviews.llvm.org/rL226440
Related review: http://reviews.llvm.org/D6892

llvm-svn: 227789
2015-02-02 09:38:10 +00:00
Kumar Sukhani 14a4f24d2c [asan][mips] Fix MIPS64 Asan mapping
llvm-svn: 227683
2015-01-31 09:13:58 +00:00
Alexey Samsonov e41a26e4b4 Revert "Remove unused function."
This reverts commit r227633. SetEnv was prematurely deleted.

llvm-svn: 227665
2015-01-31 01:27:18 +00:00
Alexey Samsonov a11a86b9ce [TSan] Fix Go build.
llvm-svn: 227634
2015-01-30 23:04:57 +00:00
Alexey Samsonov df0b22c5a8 Remove unused function.
llvm-svn: 227633
2015-01-30 23:04:54 +00:00
Viktor Kutuzov 6fe85cbb8e [Sanitizers] Intercept gethost functions on FreeBSD
Committed unreviewed with permission.

llvm-svn: 227572
2015-01-30 12:58:37 +00:00
Viktor Kutuzov c97b1e7c32 [Msan] Fix the shmctl unit tests to pass on FreeBSD
Differential Revision: http://reviews.llvm.org/D7253

llvm-svn: 227571
2015-01-30 12:55:40 +00:00
Viktor Kutuzov 07e6c00171 [Sanitizers] Introduce GET_LINK_MAP_BY_DLOPEN_HANDLE() macro
Differential Revision: http://reviews.llvm.org/D7233

llvm-svn: 227570
2015-01-30 12:43:52 +00:00
Yury Gribov 2bbad68617 [Sanitizer] Make BlockingMutex really linker initialized.
Differential Revision: http://reviews.llvm.org/D7171

llvm-svn: 227560
2015-01-30 06:20:43 +00:00
Yury Gribov 640017411c Replace code dup with a macro.
Differential Revision: http://reviews.llvm.org/D7172

llvm-svn: 227559
2015-01-30 06:18:46 +00:00
Alexey Samsonov 8b3334d909 [TSan] Fix -Werror=sign-compare warning. NFC.
llvm-svn: 227527
2015-01-30 01:02:12 +00:00
Kuba Brecka 0f776b0905 [compiler-rt] OS X: Update the CMake and Make builds to explicitely use libc++, mmacosx-version-min and SDKs
In both CMake and Makefiles, we are inconsistent about the use of libstdc++ vs. libc++, SDKs and minimum deployment targets for OS X. Let's fix the detection of SDKs, and let's explicitely set that we link against libc++ and mmacosx-version-min is 10.7.

llvm-svn: 227509
2015-01-29 23:19:26 +00:00
Alexey Samsonov 807f1b539c [CMake] Get rid of TARGET_64_BIT_CFLAGS: explicitly list required flags for each architecture.
llvm-svn: 227496
2015-01-29 21:32:34 +00:00
Evgeniy Stepanov 6037579926 [asan] Add one more wait-for-device in the Android setup script.
llvm-svn: 227473
2015-01-29 17:24:21 +00:00
Kostya Serebryany 3c052cc051 [asan] use getrusage as an alternative to reading /proc/self/statm. Also move GetRSS to sanitizer_linux_libcdep.cc (no change in the function itself)
llvm-svn: 227416
2015-01-29 02:54:39 +00:00
Alexey Samsonov 7f25a40550 [ASan] Generalize/simplify lit test configs generation.
llvm-svn: 227413
2015-01-29 02:28:53 +00:00
Kostya Serebryany 21a1a23790 [sanitizer] allow to reset the bb/edge coverage data inside the process while it is running (single-threaded). Also expose the current coverage set to the process.
llvm-svn: 227387
2015-01-28 22:39:44 +00:00
Nico Weber 64a74bf1cf Fix indents on asan_symbolize.py's argument parsing code. No behavior change.
llvm-svn: 227327
2015-01-28 17:29:57 +00:00
Nico Weber 406f640a68 Make asan_symbolize.py not crash on Windows.
asan_symbolize.py isn't needed on Windows, but it's nice if asan has a unified
UI on all platforms. So rather than have asan_symolize.py die on startup due to
it importing modules that don't exist on Windows, let it just echo the input.

llvm-svn: 227326
2015-01-28 17:28:04 +00:00
Alexey Samsonov 605f2df106 [ASan] Fix test cases: don't assume that fast unwinder can't unwind through libc.
llvm-svn: 227265
2015-01-27 23:06:48 +00:00
Alexey Samsonov e745728fad [ASan] Fix use-after-scope in COMMON_INTERCEPTOR_ENTER implementation.
Make sure "void *ctx" doesn't point to an object which already went out
of scope. This might also fix -Wuninitialized warnings GCC 4.7 produces
while building ASan runtime.

llvm-svn: 227258
2015-01-27 22:50:19 +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
Justin Bogner 91487e80c8 profile: add lib/profile to cc_kext on darwin,arm64
These functions are already present in the cc_kext for arm32 and for x86 and
x86_64.  It was an oversight that they were not included for arm64.

Based on a patch by Lawrence D'Anna. Thanks!

llvm-svn: 227206
2015-01-27 17:10:07 +00:00
Evgeniy Stepanov 0bc26c0934 Revert r226440.
It was fixed the right way in r227195.

llvm-svn: 227196
2015-01-27 15:06:54 +00:00
Evgeniy Stepanov 8441bb239f [msan] Refactor memory layout specification and setup.
A flexible way of describing MSan memory layout details on various
platforms. No significant functional changes, but the memory layout
description that you get at verbosity=1 looks slightly different.
This change includes stronger sanity checks than before.

The goal of this change is to allow more than 2 application memory
ranges for https://code.google.com/p/memory-sanitizer/issues/detail?id=76.

llvm-svn: 227192
2015-01-27 13:20:34 +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
Mohit K. Bhakkad 6fe5700f6b [MSan] Enable MSan unit tests for all archs
Reviewers: Reviewers: eugenis, kcc, samsonov, petarj

Subscribers: dsanders, sagar, lldb-commits

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

llvm-svn: 227189
2015-01-27 12:38:25 +00:00
Kuba Brecka aa772feb8e [ASan] Use rpath in tests that produce a shared library
Modifying Darwin/interception-in-shared-lib-test.cc and suppressions-library.cc
to use rpath instead of linking against the full path to the temporary file.
NFC.

llvm-svn: 227161
2015-01-27 01:29:18 +00:00
Viktor Kutuzov e8dd0ca483 [Msan] Disable the ppoll unit test on FreeBSD
Differential Revision: http://reviews.llvm.org/D7145

llvm-svn: 227106
2015-01-26 18:05:54 +00:00
Viktor Kutuzov 965918e7d4 [Msan] Fix the statfs unit test to pass on FreeBSD
Differential Revision: http://reviews.llvm.org/D7144

llvm-svn: 227100
2015-01-26 17:31:23 +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
Sergey Matveev f4e33cc9bb [sanitizer] Update descriptor size for glibc 2.13.
See https://code.google.com/p/address-sanitizer/issues/detail?id=361

It's still not clear whether the values are correct in all cases, but at least
this should unbreak our bots.

llvm-svn: 226938
2015-01-23 21:12:39 +00:00
Kuba Brecka 9a36b3e147 [compiler-rt] Ensure AsanInitFromRtl is called from a static initializer on OS X by using ASAN_DYNAMIC=1
The idea is to ensure that the ASan runtime gets initialized early (i.e.
before other initializers/constructors) even when DYLD_INSERT_LIBRARIES
is not used. In that case, the interceptors are not installed (on OS X,
DYLD_INSERT_LIBRARIES is required for interceptors to work), and therefore
ASan gets currently initialized quite late -- from the main executable's
module initializer. The following issues are a consequence of this:

  https://code.google.com/p/address-sanitizer/issues/detail?id=363
  https://code.google.com/p/address-sanitizer/issues/detail?id=357

Both of them are fixed with this patch.

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

llvm-svn: 226929
2015-01-23 19:29:19 +00:00
Kuba Brecka f1397fa7d7 [compiler-rt] Fix the prototype of ioctl interceptor
The interceptor of ioctl is using a non-standard prototype:

  INTERCEPTOR(int, ioctl, int d, unsigned request, void *arg)

At least on OS X, the request argument should be unsigned long and not 
just unsigned, and also instead of the last argument (arg), the function
should be accepting a variable number of arguments, so the prototype
should be:

  int ioctl(int fildes, unsigned long request, ...);

We can still keep using `unsigned` internally to save space, because we
know that all possible values of `request` will fit into it.

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

llvm-svn: 226926
2015-01-23 19:17:20 +00:00
Evgeniy Stepanov d486e09d8e [sanitizer] Fix an edge case in MemoryRangeIsAvailable.
llvm-svn: 226913
2015-01-23 15:14:27 +00:00
Viktor Kutuzov 8f6001bf59 [Sanitizers] Intercept statfs() on FreeBSD
Committed unreviewed with permission.

llvm-svn: 226910
2015-01-23 14:39:23 +00:00
Kuba Brecka 4edeced078 Fix the extra whitespace from r226878.
llvm-svn: 226884
2015-01-23 00:14:22 +00:00
Kuba Brecka 405de4ae10 Fix/workaround for OS X truncated stacktraces taken by external tools
This patch is a proposed solution for https://code.google.com/p/address-sanitizer/issues/detail?id=375:

When the stacktraces are captured and printed by ASan itself, they are fine, but when the program has already printed the report (or is just printing it), capturing a stacktrace via other means is broken. "Other means" include OS X CrashReporter, debuggers or calling backtrace() within the program. For example calling backtrace() from a sanitizer_set_death_callback function prints a very truncated stacktrace.

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

llvm-svn: 226878
2015-01-22 23:36:47 +00:00
Evgeniy Stepanov 0729053dac [sanitizer] Move sched_getparam test under Linux/.
llvm-svn: 226832
2015-01-22 15:34:50 +00:00
Timur Iskhodzhanov 23cfd6ecff [ASan/Win] Fix PR20944 -- run ASan gtests as part of check-asan on Windows
llvm-svn: 226831
2015-01-22 14:54:22 +00:00
Dmitry Vyukov 48846ba570 tsan: use hacky call only on x86_64
required for mips64 and aarch64 ports

llvm-svn: 226829
2015-01-22 14:13:56 +00:00
Evgeniy Stepanov 229984947b [sanitizer] Intercept sched_getparam.
llvm-svn: 226827
2015-01-22 14:03:07 +00:00
Evgeniy Stepanov 8eb8204e3f [sanitizer] Fix windows build.
llvm-svn: 226825
2015-01-22 13:47:12 +00:00
Evgeniy Stepanov d38af30b74 [msan] Better use-after-free reports.
By attaching an extra integer tag to heap origins, we are able
to distinguish between uninits
 - created by heap allocation,
 - created by heap deallocation (i.e. use-after-free),
 - created by __msan_allocated_memory call,
 - etc.

See https://code.google.com/p/memory-sanitizer/issues/detail?id=35.

llvm-svn: 226821
2015-01-22 13:33:16 +00:00
Timur Iskhodzhanov b4b6b74079 [ASan/Win] Move the shadow to 0x30000000
llvm-svn: 226809
2015-01-22 12:24:21 +00:00
Timur Iskhodzhanov 841572e90a [ASan] Print out the shadow memory range on shadow mapping failures
llvm-svn: 226807
2015-01-22 12:05:27 +00:00
Evgeniy Stepanov a6b279546d [msan] Relax CHECK conditions in 2 tests.
Sometimes malloc/realloc/etc are symbolized as
__interceptor_malloc/realloc/etc.

llvm-svn: 226803
2015-01-22 09:27:00 +00:00
Viktor Kutuzov b7766be002 [Msan] Fix the readv and preadv unit tests to pass on FreeBSD
Differential Revision: http://reviews.llvm.org/D7091

llvm-svn: 226801
2015-01-22 09:00:46 +00:00
Viktor Kutuzov ed9a90b7c8 [Msan] Fix the strerror_r unit test to build on FreeBSD
Differential Revision: http://reviews.llvm.org/D7089

llvm-svn: 226800
2015-01-22 08:57:59 +00:00
Viktor Kutuzov e787b141e7 [Msan] Fix the DynRet unit test to build on FreeBSD
Differential Revision: http://reviews.llvm.org/D7086

llvm-svn: 226799
2015-01-22 08:54:03 +00:00
Viktor Kutuzov 75a52451e8 [Sanitizers] Fix inet_aton() and inet_pton() interceptors to work on FreeBSD
Differential Revision: http://reviews.llvm.org/D7084

llvm-svn: 226796
2015-01-22 08:51:07 +00:00
Viktor Kutuzov 3f68fae900 [Sanitizers] Intercept preadv() on FreeBSD
Committed unreviewed with permission.

llvm-svn: 226794
2015-01-22 08:47:54 +00:00
Evgeniy Stepanov 844f5828e9 [msan] Fix origins in realloc.
Fixes 2 issues in origins arising from realloc() calls:
 * In the in-place grow case origin for the new memory is not set at all.
 * In the copy-realloc case __msan_memcpy is used, which unwinds stack from
   inside the MSan runtime. This does not generally work (as we may be built
   w/o frame pointers), and produces "bad" stack trace anyway, with several
   uninteresting (internal) frames on top.

This change also makes realloc() honor "zeroise" and "poison_in_malloc" flags.

See https://code.google.com/p/memory-sanitizer/issues/detail?id=73.

llvm-svn: 226674
2015-01-21 16:48:29 +00:00
Evgeniy Stepanov 84adb5d1d0 [msan] Refactor shadow operations.
Move a bunch of functions to a new source file and rename some of them for
consistency. No functional changes.

llvm-svn: 226673
2015-01-21 16:42:30 +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
Evgeniy Stepanov 79ca0fd1a0 [msan] Update origin for the entire destination range on memory store.
Previously we always stored 4 bytes of origin at the destination address
even for 8-byte (and longer) stores.

This should fix rare missing, or incorrect, origin stacks in MSan reports.

llvm-svn: 226658
2015-01-21 13:21:31 +00:00
Alexander Potapenko cb273921de [ASan] Fix the test expectations for dyld_insert_libraries_reexec.cc
llvm-svn: 226651
2015-01-21 10:04:41 +00:00
Viktor Kutuzov d518cb76ad [Msan] Fix the accept unit test to pass on FreeBSD
Differential Revision: http://reviews.llvm.org/D7083

llvm-svn: 226650
2015-01-21 09:46:21 +00:00
Viktor Kutuzov f6894e9c2c [Sanitizers] Intercept confstr() on FreeBSD
Committed unreviewed with permission.

llvm-svn: 226649
2015-01-21 08:56:40 +00:00
Viktor Kutuzov 1f01782e5c [Sanitizers] Intercept opendir()
Differential Revision: http://reviews.llvm.org/D6968

llvm-svn: 226648
2015-01-21 08:54:01 +00:00
Dmitry Vyukov 8070ac6bd6 tsan: don't unroll memory access loop in debug mode
MemoryAccess function consumes ~4K of stack in debug mode,
in significant part due to the unrolled loop.
And gtest gives only 4K of stack to death test
threads, which causes stack overflows in debug mode.

llvm-svn: 226644
2015-01-21 08:09:13 +00:00
Kostya Serebryany 82b58712c1 [sanitizer] First step toward supporting 42-bit AS on aarch64
aarch64-linux kernel has configurable 39, 42 or 47 bit virtual address
space.  Most distros AFAIK use 42-bit VA right now, but there are also
39-bit VA users too.  The ppc64 handling can be used for this just fine
and support all the 3 sizes.

There are other issues, like allocator32 not really being able to support
the larger addres spaces, and hardcoded 39-bit address space size in other
macros.

Patch by Jakub Jelinek.

llvm-svn: 226639
2015-01-21 02:11:05 +00:00
Nico Weber 896984c251 Much spelling. Wow.
llvm-svn: 226638
2015-01-21 02:09:16 +00:00
Kostya Serebryany d4a032f6c6 [sanitizer] Fix aarch64 sanitizer build with recent glibc
glibc recently changed ABI on aarch64-linux:
https://sourceware.org/git/?p=glibc.git;a=commit;h=5c40c3bab2fddaca8cfe12d75944d1fef8adf1a4
Instead of having unsigned short mode; unsigned short __pad1; it now has
unsigned int mode; field in ipc_perm structure.

This patch allows to build against the recent glibc and disables the
ipc_perm.mode verification for older versions of glibc.

I think it shouldn't be a big deal even for older glibcs, I couldn't find
any place which would actually care about the exact mode field, rather than
the whole structure, appart from the CHECK_SIZE_AND_OFFSET macro.

Patch by Jakub Jelinek

llvm-svn: 226637
2015-01-21 02:08:42 +00:00
Kostya Serebryany c6338ac943 [asan] use MADV_NOHUGEPAGE for shadow to reduce the actual memory usage
llvm-svn: 226636
2015-01-21 02:05:31 +00:00
Petar Jovanovic 605c14807f [MIPS64] Make __clear_cache more optimal
Use synci implementation of clear_cache for short address ranges.
For long address ranges, make a kernel call.

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

llvm-svn: 226567
2015-01-20 15:04:19 +00:00
Evgeniy Stepanov f074b3c2de [asan] Allow changing verbosity in activation flags.
This change removes some debug output in asan_flags.cc that
was reading the verbosity level before all the flags were parsed.

llvm-svn: 226566
2015-01-20 13:21:20 +00:00
Evgeniy Stepanov fbeb7e65d9 [asan] Warn if unsupported flags are used at activation.
llvm-svn: 226563
2015-01-20 12:19:14 +00:00
Viktor Kutuzov eae2e04923 [Msan] Fix the readlink unit test to pass on FreeBSD
Differential Revision: http://reviews.llvm.org/D7052

llvm-svn: 226554
2015-01-20 09:57:28 +00:00
Dmitry Vyukov cc5e40811b tsan: remove TSAN_SHADOW_COUNT
TSAN_SHADOW_COUNT is defined to 4 in all environments.
Other values of TSAN_SHADOW_COUNT were never tested and
were broken by recent changes to shadow mapping.
Remove it as there is no reason to fix nor maintain it.

llvm-svn: 226466
2015-01-19 15:01:07 +00:00
Viktor Kutuzov 9c967286e0 [Sanitizers] Intercept statvfs() on FreeBSD
Committed unreviewed with permission.

llvm-svn: 226462
2015-01-19 13:26:25 +00:00
Viktor Kutuzov 68f150f3d4 [Msan] Intercept stat() and fstatat() on FreeBSD
Differential Revision: http://reviews.llvm.org/D7051

llvm-svn: 226461
2015-01-19 13:22:33 +00:00
Evgeniy Stepanov a2edd9159a [sanitizer] Make unrecognized flags not fatal.
Print a warning at verbosity=1 and higher instead of dying immediately.

llvm-svn: 226458
2015-01-19 12:22:57 +00:00
Evgeniy Stepanov 6c6e589c1f [sanitizer] Switch flag parsing to LowLevelAlloc.
InternalAlloc is quite complex and its behavior may depend on the values of
flags. As such, it should not be used while parsing flags.

Sadly, LowLevelAlloc does not support deallocation of memory.

llvm-svn: 226453
2015-01-19 11:47:13 +00:00
Evgeniy Stepanov 3231dd3c1c [sanitizer] Simplify code in flag parser.
llvm-svn: 226452
2015-01-19 10:54:36 +00:00
Viktor Kutuzov abfacbdf3a [Sanitizers] Order initialization of coverage and guard arrays
Differential Revision: http://reviews.llvm.org/D6892

llvm-svn: 226440
2015-01-19 09:41:52 +00:00
Evgeniy Stepanov 141c5a9ae0 [sanitizer] Move options-related tests to sanitizer_common.
And handle help=1 in standalone LSan.

llvm-svn: 226438
2015-01-19 09:21:44 +00:00
Evgeniy Stepanov e5b1c0d98e [msan] Use internal__exit() instead of _exit().
llvm-svn: 226437
2015-01-19 09:20:28 +00:00
Evgeniy Stepanov 0540f4141f [dfsan] Use append_no_rtti_flag instead of manually specifying -fno-rtti.
llvm-svn: 226435
2015-01-19 08:26:38 +00:00
David Blaikie 4da5edbebe Update for tests failing due to improvements in clang's column information for aggregate expressions
llvm-svn: 226393
2015-01-18 02:17:55 +00:00
Hal Finkel 0e39c55d22 [sanitizer] Adjust max read size in FlagHandlerInclude
Setting the maximum read size in FlagHandlerInclude to 2^15 might be a good
default, but causes the read to fail on systems with a page size larger than
that (ReadFileToBuffer(...) will fail if the maximum allowed size is less than
the value returned by GetPageSizeCached()). For example, on my PPC64/Linux
system, GetPageSizeCached() returns 2^16. In case the page size is larger, use
that instead.

llvm-svn: 226368
2015-01-17 03:31:43 +00:00
Justin Bogner 66fd5c914a InstrProf: Optionally print an error when emitting profile data fails
Debugging a missing profile is a bit painful right now. We can make
people's lives a bit easier by adding a knob to enable printing a
helpful error message for such failures.

llvm-svn: 226312
2015-01-16 20:10:56 +00:00
Evgeniy Stepanov 5450a9635a [sanitizer] Additional error checking.
llvm-svn: 226279
2015-01-16 15:25:16 +00:00
Viktor Kutuzov 05f6929932 [Sanitizers] Intercept clock_gettime() on FreeBSD
Committed unreviewed with permission.

llvm-svn: 226276
2015-01-16 14:54:39 +00:00
Viktor Kutuzov 068ece9679 [Sanitizers] Intercept lgamma_r() on FreeBSD
Committed unreviewed with permission.

llvm-svn: 226275
2015-01-16 14:52:17 +00:00
Evgeniy Stepanov 4286a9bd5a [asan] Change detection of allow_user_segv_handler on Android.
llvm-svn: 226273
2015-01-16 13:12:22 +00:00
Evgeniy Stepanov 4448007885 [asan] More verbose output from one of the tests.
Trying to debug a buildbot-only failure.

llvm-svn: 226270
2015-01-16 12:08:32 +00:00
Evgeniy Stepanov 82d3ef1617 [asan] Fix asan_options-include test.
Wrong include order.

llvm-svn: 226268
2015-01-16 10:30:53 +00:00
Evgeniy Stepanov 29235e374c [sanitizer] Fix bashism in check_lint.sh.
llvm-svn: 226267
2015-01-16 10:20:49 +00:00
Evgeniy Stepanov e0009356ba [sanitizer] Cleanup linter temporary files.
llvm-svn: 226266
2015-01-16 10:09:56 +00:00
Evgeniy Stepanov db20539d3a [sanitizer] Fix compiler warning in the flag parser code.
llvm-svn: 226263
2015-01-16 09:32:31 +00:00
Hal Finkel e67f32aa99 [asan] Loosen test for upcoming ppc64 change
This test casts 0x4 to a function pointer and calls it. Unfortunately, the
faulting address may not exactly be 0x4 on PPC64 ELFv1 systems. The LLVM PPC
backend used to always generate the loads "in order", so we'd fault at 0x4
anyway. However, at upcoming change to loosen that ordering, and we'll pick a
different order on some targets. As a result, as explained in the comment, we
need to allow for certain nearby addresses as well.

llvm-svn: 226202
2015-01-15 20:48:38 +00:00
Evgeniy Stepanov 8c9a0708a0 [sanitizer] Restore -fno-lto accidentally removed in r226169.
llvm-svn: 226177
2015-01-15 16:31:22 +00:00
Evgeniy Stepanov bc14dd46f2 [sanitizer] Implement include= option.
Allows loading sanitizer options from file.

llvm-svn: 226175
2015-01-15 16:26:59 +00:00
Evgeniy Stepanov f294d5b829 [sanitizer] Flag parser rewrite.
The new parser is a lot stricter about syntax, reports unrecognized
flags, and will make it easier to implemented some of the planned features.

llvm-svn: 226169
2015-01-15 15:13:43 +00:00
Evgeniy Stepanov 1a1a7d0f30 [lsan] Fix a typo in a test.
llvm-svn: 226168
2015-01-15 15:00:49 +00:00
Evgeniy Stepanov fa1d9f4860 Fix compilation of compiler_rt against libunwind.
libunwind defines _Unwind_GetLanguageSpecificData as returning long
instead of (uint8_t *).

llvm-svn: 226167
2015-01-15 14:27:38 +00:00
Saleem Abdulrasool a7452e434b builtins: avoid duplicating unwind declarations
Use unwind.h to get the declarations for unwinding interfaces.  This header is
already provided by clang and gcc, so this adds no additional dependencies for
building the builtins library.  It avoids the duplication which may drift over
time though.

llvm-svn: 225990
2015-01-14 15:55:17 +00:00
Viktor Kutuzov 0181812bf6 [Msan] Fix strlen() and strnlen() interceptors to work on FreeBSD
Differential Revision: http://reviews.llvm.org/D6928

llvm-svn: 225986
2015-01-14 14:59:46 +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
Rafael Espindola c7e4fb209e Another try at handling LD_LIBRARY_PATH not being defined.
llvm-svn: 225932
2015-01-14 02:23:27 +00:00
Rafael Espindola a9782ecfb0 Handle LD_LIBRARY_PATH not being defined.
Should fix the bots after r225890.

llvm-svn: 225919
2015-01-14 01:28:08 +00:00
Alexey Samsonov f3b61be2ee Update test cases for new -fsanitize-recover= semantics.
llvm-svn: 225725
2015-01-12 23:02:42 +00:00
Peter Collingbourne 75e259ed95 [dfsan] Export dfsan_get_label_info function with C linkage.
llvm-svn: 225692
2015-01-12 20:40:30 +00:00
Viktor Kutuzov b4b05017cf [Msan] Fix use of mmap(MAP_ANONYMOUS) in the unit tests on FreeBSD
Differential Revision: http://reviews.llvm.org/D6929

llvm-svn: 225688
2015-01-12 20:18:38 +00:00
Viktor Kutuzov 6aba5098fd [Msan] Fix tests reading /proc files on FreeBSD
Differential Revision: http://reviews.llvm.org/D6926

llvm-svn: 225686
2015-01-12 20:15:33 +00:00
Timur Iskhodzhanov 00ede84084 [ASan] Move the shadow on Windows 32-bit from 0x20000000 to 0x40000000
llvm-svn: 225641
2015-01-12 17:38:58 +00:00
Evgeniy Stepanov 3f2e761826 [asan] Fix uninit in coverage.
pc_fd was not initialized to (-1) on some code paths, resulting in the program
erroneously closing stdin when reinitializing coverage.

llvm-svn: 225637
2015-01-12 17:13:20 +00:00
Evgeniy Stepanov 5975243955 [asan] Pass activation options in the android test runner.
llvm-svn: 225636
2015-01-12 17:10:05 +00:00
Ehsan Akhgari d918614586 Fix two extra semicolon warnings
Reviewers: timurrrr

Subscribers: llvm-commits

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

llvm-svn: 225635
2015-01-12 17:03:02 +00:00
Jay Foad 335c08e56c [ASan] Handle SIGBUS on Linux.
Summary:
On Linux in some situations we can get SIGBUS instead of SIGSEGV on
stack overflow, so asan should handle SIGBUS as well as SIGSEGV.

https://code.google.com/p/address-sanitizer/issues/detail?id=369

Reviewers: samsonov, glider

Reviewed By: glider

Subscribers: glider, llvm-commits

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

llvm-svn: 225630
2015-01-12 13:46:37 +00:00
Roman Divacky 0c9c0c5a6d Add FreeBSD support for __clear_cache.
llvm-svn: 225610
2015-01-11 18:21:11 +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
Alexey Samsonov 95674c8181 Remove AsanInterceptsSignal in favor of (equivalent) IsDeadlySignal.
llvm-svn: 225556
2015-01-09 23:03:31 +00:00
Kostya Serebryany 96fc9a2537 [sanitizer] use the right memory order
llvm-svn: 225546
2015-01-09 21:01:34 +00:00
Kuba Brecka 1a03ccd848 [asan] Adding a regression test for https://code.google.com/p/address-sanitizer/issues/detail?id=368
llvm-svn: 225484
2015-01-09 00:26:45 +00:00
Kostya Serebryany 8cc4002df2 [asan] make a test consume 2x less RAM (we observe flaky bot failures that seem like OOMs)
llvm-svn: 225478
2015-01-08 23:37:09 +00:00
Alexey Samsonov a04ca22edf Fix memory leaks in GetListOfModules() users.
llvm-svn: 225472
2015-01-08 22:31:14 +00:00
Alexey Samsonov b40fd1b24e [Sanitizer] Remove the hardcoded limit of address ranges in LoadedModule.
This should fix https://code.google.com/p/address-sanitizer/issues/detail?id=368.

llvm-svn: 225469
2015-01-08 22:03:05 +00:00
Viktor Kutuzov e01a595dad [Sanitizers] Fix internal_lseek() to work on FreeBSD
Differential Revision: http://reviews.llvm.org/D6825

llvm-svn: 225443
2015-01-08 13:28:22 +00:00
Renato Golin ea56f08b3f XFAIL AArch64 UBsan test, just like ARM
llvm-svn: 225370
2015-01-07 20:03:47 +00:00
Kostya Serebryany 7ad02fca09 [asan] add flag quarantine_size_mb, deprecate quarantine_size
llvm-svn: 225337
2015-01-07 02:37:52 +00:00
Alexey Samsonov 7eba6dfdaa [TSan] Fix Go build.
llvm-svn: 225336
2015-01-07 02:12:41 +00:00
Alexey Samsonov 03499e920b [Sanitizer] Change the runtime flag representation.
This mirrors r225239 to all the rest sanitizers:
ASan, DFSan, LSan, MSan, TSan, UBSan.

Now the runtime flag type, name, default value and
description is located in the single place in the
.inc file.

llvm-svn: 225327
2015-01-07 00:38:00 +00:00
Kostya Serebryany 7e85a9216e [asan] add a flag soft_rss_limit_mb
llvm-svn: 225323
2015-01-06 23:53:32 +00:00
Alexey Samsonov 6239ebc1c2 [Sanitizer] Improve unit tests in COMPILER_RT_DEBUG=ON mode.
Propagate -DSANITIZER_DEBUG definition to unit tests.
Make sure unit tests depend on compiler-rt headers.

llvm-svn: 225298
2015-01-06 20:58:40 +00:00
Alexey Samsonov ea04032144 Use -DSANITIZER_DEBUG=1 if COMPILER_RT_DEBUG=ON, now that PR22083 is fixed.
llvm-svn: 225293
2015-01-06 20:25:34 +00:00
Kostya Serebryany 4e781371d1 [ubsan] disable coverage-levels.cc on darwin until we can investigate what's wrong there.
llvm-svn: 225281
2015-01-06 18:48:49 +00:00