Commit Graph

4356 Commits

Author SHA1 Message Date
Evgeniy Stepanov ca9e045570 [sanitizer] Fix off-by-8x in direct coverage.
File mapping offset was calculated by offsetting (uptr *) instead of (char *).

llvm-svn: 224821
2014-12-24 13:57:11 +00:00
Evgeniy Stepanov 40b16f4037 [sanitizer] Disable InternalMmapWithOffset test on Windows.
llvm-svn: 224820
2014-12-24 13:05:21 +00:00
Evgeniy Stepanov 98211121ab [sanitizer] mmap2 syscall works with 4096-byte units instead of bytes.
Ouch.

llvm-svn: 224819
2014-12-24 12:58:09 +00:00
Kostya Serebryany 9fdeb37bd3 [asan] change the coverage collection scheme so that we can easily emit coverage for the entire process as a single bit set, and if coverage_bitset=1 actually emit that bitset
llvm-svn: 224789
2014-12-23 22:32:17 +00:00
Evgeniy Stepanov b2dacb0c76 [asan] Fix line >80 chars.
llvm-svn: 224763
2014-12-23 10:18:47 +00:00
Evgeniy Stepanov 874b2bb228 [asan] Better error message in coverage.
llvm-svn: 224762
2014-12-23 10:12:51 +00:00
Dmitry Vyukov 10070626b7 tsan: fix style
Usually we roll the variable declaration into the condition in cases like this.

llvm-svn: 224755
2014-12-23 07:21:23 +00:00
Alexey Samsonov b430f6e17a [Sanitizer] Make CommonFlags immutable after initialization.
Summary:
Protect CommonFlags singleton by adding const qualifier to
common_flags() accessor. The only ways to modify the flags are
SetCommonFlagsDefaults(), ParseCommonFlagsFromString() and
OverrideCommonFlags() functions, which are only supposed to be
called during initialization.

Test Plan: regression test suite

Reviewers: kcc, eugenis, glider

Subscribers: llvm-commits

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

llvm-svn: 224736
2014-12-22 21:46:10 +00:00
Viktor Kutuzov 54c7590073 [Msan] Fix msan_test.cc inclusions to build the unit tests on FreeBSD
Differential Revision: http://reviews.llvm.org/D6757

llvm-svn: 224724
2014-12-22 19:14:23 +00:00
Kuba Brecka 742c471142 AddressSanitizer: Abort after failed exec() and get rid of the allow_reexec ASan flag
As mentioned in
https://code.google.com/p/address-sanitizer/issues/detail?id=365, when the
re-exec that adds the required DYLD_INSERT_LIBRARIES variable fails, ASan
currently continues to run, but things are broken (some memory can be
overwritten, interceptors don't work, ...). This patch aborts if the execv()
fails and prints an error message that DYLD_INSERT_LIBRARIES is required. It
also removes the "alllow_reexec" flag, since using it causes the same issues.

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

llvm-svn: 224712
2014-12-22 17:32:27 +00:00
Kuba Brecka 090d33e393 AddressSanitizer: Properly handle dispatch_source_set_cancel_handler with a
NULL handler

Per
https://developer.apple.com/library/mac/documentation/Performance/Reference/GCD_libdispatch_Ref/index.html,
the dispatch_source_set_cancel_handler() API *can* be called with a NULL
handler. In that case, the libdispatch removes an already existing cancellation
handler, if there was one. ASan's interceptor always creates a new block that
always tries to call the original handler. In case the original block is NULL,
a segmentation fault happens. Let's fix that by not wrapping a NULL-block at
all.

It looks like all the other libdispatch APIs (which we intercept) do *not*
allow NULL. So it's really only the dispatch_source_set_cancel_handler one that
needs this fix.

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

llvm-svn: 224711
2014-12-22 17:30:04 +00:00
Alexander Potapenko 7f9be7120d [ASan] Fix the logic that decides whether we need to spawn a new llvm-symbolizer in asan_symbolize.py
llvm-svn: 224710
2014-12-22 16:00:00 +00:00
Viktor Kutuzov 90f8673f05 [Sanitizers] Intercept wcsnrtombs() on FreeBSD
Differential Revision: http://reviews.llvm.org/D6755

llvm-svn: 224709
2014-12-22 14:45:30 +00:00
Viktor Kutuzov 2a5b81dd7f [Msan] Fix uname() interception on FreeBSD
Differential Revision: http://reviews.llvm.org/D6738

llvm-svn: 224708
2014-12-22 14:42:24 +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 8f9911b571 tsan: fix debugging output
llvm-svn: 224701
2014-12-22 12:31:32 +00:00
Viktor Kutuzov d4c3ffc5bf [Sanitizers] Intercept snprintf_l() on FreeBSD
Differential Revision: http://reviews.llvm.org/D6418

llvm-svn: 224700
2014-12-22 12:29:40 +00:00
Viktor Kutuzov 35fb0b5d52 [Sanitizers] Intercept wordexp on FreeBSD
Differential Revision: http://reviews.llvm.org/D6737

llvm-svn: 224699
2014-12-22 12:21:35 +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
Kostya Serebryany baae9d2df1 [sanitizer] fix a performance regression in sanitizer coverage: move a small perf-critical function to a header. ALso set the coverage guard to 1 before the early return from CoverageData::Add
llvm-svn: 224660
2014-12-20 01:45:28 +00:00
Kostya Serebryany f053fc9b5c [sanitizer] initialize two flas in SetCommonFlagsDefaults
llvm-svn: 224645
2014-12-19 23:09:59 +00:00
Alexey Samsonov 2f8c8d59b2 [Sanitizer] Refactor CommonFlags interface. NFC.
Add CommonFlags::SetDefaults() and CommonFlags::ParseFromString(),
so that this object can be easily tested. Enforce
that ParseCommonFlagsFromString() and SetCommonFlagsDefaults()
work only with singleton CommonFlags, shared across all sanitizer
runtimes.

llvm-svn: 224617
2014-12-19 21:40:04 +00:00
Alexey Samsonov 04eeec32e6 [ASan] Change activation strategy.
Now ASan deactivation doesn't modify common or ASan-specific runtime
flags. Flags stay constant after initialization, and "deactivation"
instead stashes initialized runtime state, and deactivates the
runtime. Activation then just restores the original state (possibly,
overriden by some activation flags provided in system property on
Android).

llvm-svn: 224614
2014-12-19 20:35:53 +00:00
Alexey Samsonov 30f330b39b [Sanitizer] Make Quarantine::Init slightly safer.
ASan Quarantine can be reinitialized at activation/deactivation.
Make max_size_/min_size_ atomic.

llvm-svn: 224613
2014-12-19 20:35:50 +00:00
Alexey Samsonov d6b24fa1e2 [ASan] Introduce AllocatorOptions to configure allocator behavior.
Summary:
Reduce the dependency of allocator code on runtime flags. Instead,
pass a bunch of options that configure allocator behavior at
initialization or re-initialization. That would allow us to
cleaner modify allocator behavior during a program execution
when ASan is activated or de-activated.

Test Plan: regression test suite

Reviewers: kcc

Subscribers: llvm-commits, eugenis

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

llvm-svn: 224605
2014-12-19 19:35:11 +00:00
Alexey Samsonov 1b64854574 [ASan] Restrict the set of flags overriden at activation.
Summary:
Change the way ASan flag parsing is performed at activation: instead
of overwriting all ASan and common flags from the activation string,
ASan will now only override a handful of whitelisted flags.
This is a first step towards making runtime flags immutable after
initialization. I plan to re-factor the activation stragegy to
the following one:

  - Parse commandline flags. Override the defaults from compile
    definition, env var, etc. Flags are immutable at this point.
  - Initiailize the runtime from commandline flags.
  - If ASan needs to be started deactivated, stash the runtime
    state in "asan_deactivated_flags" and deactivate the runtime.
  - When ASan is activated, override "asan_deactivated_flags" with
    activation flags, and use it to re-activate the runtime.

Test Plan: regression test suite

Reviewers: eugenis, kcc

Subscribers: llvm-commits

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

llvm-svn: 224601
2014-12-19 19:16:07 +00:00
Alexey Samsonov 583e9d29ad [ASan] Move flag validation from ParseFlagsFromString() to InitializeFlags().
llvm-svn: 224600
2014-12-19 19:16:02 +00:00
Saleem Abdulrasool 5bbc718539 builtins: rely on the compiler for user label prefix
clang does not like the definition of builtins.  In order to work around this,
we use a SUN CC to redefine the generated name.  However, this requires that we
account for the user label prefix.  Rather than hard coding that into the file,
rely on the compiler to tell us the information and use the preprocessor to
generate the name as we do in the assembly routines.  NFC.

llvm-svn: 224597
2014-12-19 18:54:13 +00:00
Sergey Matveev 8cd909e749 [sanitizer] Rename InitIfLinkerInitialized to InitLinkerInitialized.
llvm-svn: 224577
2014-12-19 14:45:19 +00:00
Dmitry Vyukov 7fe690ce12 tsan: intercept closedir
llvm-svn: 224575
2014-12-19 14:29:40 +00:00
Dmitry Vyukov f6fab7adcf tsan: disable __tls_get_addr interceptor
see the added comments for details, it's messy

llvm-svn: 224531
2014-12-18 18:39:55 +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
Jay Foad d348d7c757 [Sanitizer] Fix GetRSS on Linux with non-4k pages
Summary:
The numbers in /proc/self/statm are in pages, not in fixed 4k units.
This fixes Linux/hard_rss_limit_mb_test.cc on my PowerPC64 box which
has 64k pages.

Reviewers: kcc, willschm

Reviewed By: willschm

Subscribers: llvm-commits

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

llvm-svn: 224522
2014-12-18 16:24:01 +00:00
Dmitry Vyukov 84fa6b37f4 tsan: fix deadlock reporting
currently deadlock detector reports effectively random stacks in report after flush
because it looks at old edges with wrong stacks

llvm-svn: 224519
2014-12-18 14:05:34 +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 e1881269f8 tsan: don't crash with NULL deref during reporting
tctx==NULL crash observed during deadlock reporting.
There seems to be some bugs in the deadlock detector,
but it is still useful to be more robust during reporting.

llvm-svn: 224508
2014-12-18 10:19:32 +00:00
Dmitry Vyukov a4cd69217b tsan: disable flaky debug check
see the comment for details

llvm-svn: 224507
2014-12-18 10:17:01 +00:00
Petar Jovanovic 7a6f5e47cf Do not define CRT_HAS_128BIT for MIPS64
Do not define it for MIPS64 until its backend supports it.
See the bug report [1] for more information.

[1] http://llvm.org/bugs/show_bug.cgi?id=20098

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

llvm-svn: 224488
2014-12-18 01:21:33 +00:00
Alexey Samsonov 969902b43b [ASan] Always build shared ASan runtime on Linux.
This commit changes the strategy for building shared ASan runtime
and the way we test it:
  - COMPILER_RT_BUILD_SHARED_ASAN CMake option is removed. We now
    always build shared ASan runtime (it is the default on Android,
    Windows and Mac, and not the default on Linux and FreeBSD).
  - Platforms, which use static runtime by default now have
    "check-asan-dynamic" testsuite. This testsuite contains instrumented
    unit tests, and ASan lit tests, and runs them with shared ASan
    runtime. This testsuite is *not* a part of "check-asan" and
    *not* a part of "check-all", as adding 1000 more test cases, which
    duplicate existing ones is costly. However, you're welcome to
    add this command to your buildbot.

llvm-svn: 224470
2014-12-17 23:14:01 +00:00
Kostya Serebryany 20f3a52249 [sanitizer] add CombinedAllocator::InitIfLinkerInitialized and use it in lsan: speeds up lsan start-up time by ~25%
llvm-svn: 224469
2014-12-17 23:06:36 +00:00
Kostya Serebryany 4de56ef736 [sanitizer] allow -fsanitize-coverage=N w/ -fsanitize=leak, compiler-rt part
llvm-svn: 224464
2014-12-17 21:51:07 +00:00
Alexey Samsonov 9aca5e07ec [ASan] Move flag parsing logic to asan_flags.cc. NFC.
llvm-svn: 224450
2014-12-17 19:31:39 +00:00
Evgeniy Stepanov 372deb091e [msan] Stop calling pthread_getspecific in signal handlers.
pthread_getspecific is not async-signal-safe.

MsanThread pointer is now stored in a TLS variable, and the TSD slot
is used only for its destructor, and never from a signal handler.

This should fix intermittent CHECK failures in MsanTSDSet.

llvm-svn: 224423
2014-12-17 10:30:06 +00:00
Alexey Samsonov b2dcac0bb7 [ASan] Re-structure the allocator code. NFC.
Introduce "Allocator" object, which contains all the bits and pieces
ASan allocation machinery actually use: allocator from sanitizer_common,
quarantine, fallback allocator and quarantine caches, fallback mutex.

This step is a preparation to adding more state to this object. We want
to reduce dependency of Allocator on commandline flags and be able to
"safely" modify its behavior (such as the size of the redzone) at
runtime.

llvm-svn: 224406
2014-12-17 01:55:03 +00:00
Alexey Samsonov 2c31cc3cf1 Rename asan_allocator2.cc to asan_allocator.cc
llvm-svn: 224396
2014-12-17 00:26:50 +00:00
Alexey Samsonov 91bb25f515 [ASan] Introduce SetCanPoisonMemory() function.
SetCanPoisonMemory()/CanPoisonMemory() functions are now used
instead of "poison_heap" flag to determine if ASan is allowed
to poison the shadow memory. This allows to hot-patch this
value in runtime (e.g. during ASan activation) without introducing
a data race.

llvm-svn: 224395
2014-12-17 00:01:02 +00:00
Kostya Serebryany 5f5bc4abd3 [asan] trying to fix Mac build
llvm-svn: 224370
2014-12-16 21:06:07 +00:00
Hans Wennborg 7dd94570b0 Fix Win build after r224353: void function returning zero.
llvm-svn: 224366
2014-12-16 20:46:05 +00:00
Kostya Serebryany 43eb7735f2 [asan] new flag: hard_rss_limit_mb
llvm-svn: 224353
2014-12-16 19:13:01 +00:00
Mohit K. Bhakkad a94a037528 internal_stat for mips64
llvm-svn: 224326
2014-12-16 07:11:08 +00:00
Kuba Brecka 731089bbce Add an MACOS_VERSION_UNKNOWN_NEWER enum value for OS X versions above 10.10.
We recently had a broken version check because an newer OS X version is treated as MACOS_VERSION_UNKNOWN which is less than all the defined values. Let's have a separate enum value for unknown but newer versions, so the ">=" and "<=" version checks still work even in upcoming OS X releases.

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

llvm-svn: 224315
2014-12-16 04:46:15 +00:00
Alexey Samsonov 1c65001e5e Fix data symbolization with libbacktrace. Patch by Jakub Jelinek!
llvm-svn: 224308
2014-12-16 01:52:55 +00:00
Alexey Samsonov bba821b5b1 [ASan] Allow to atomically modify malloc_context_size at runtime.
Summary:
Introduce __asan::malloc_context_size atomic that is used to determine
required malloc/free stack trace size. It is initialized with
common_flags()->malloc_context_size flag, but can later be overwritten
at runtime (e.g. when ASan is activated / deactivated).

Test Plan: regression test suite

Reviewers: kcc, eugenis

Subscribers: llvm-commits

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

llvm-svn: 224305
2014-12-16 01:23:03 +00:00
Kostya Serebryany 42102b110e [asan] introduce __sanitizer_set_death_callback, deprecate __asan_set_death_callback
llvm-svn: 224286
2014-12-15 23:02:57 +00:00
Alexey Samsonov 6334f46db8 [Sanitizer] Introduce Allocator::may_return_null bool flag.
Summary:
Turn "allocator_may_return_null" common flag into an
Allocator::may_return_null bool flag. We want to make sure
that common flags are immutable after initialization. There
are cases when we want to change this flag in the allocator
at runtime: e.g. in unit tests and during ASan activation
on Android.

Test Plan: regression test suite, real-life applications

Reviewers: kcc, eugenis

Subscribers: llvm-commits

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

llvm-svn: 224148
2014-12-12 20:07:35 +00:00
Kumar Sukhani adb3864744 [mips] [test] Enable COMPILER_RT_INCLUDE_TESTS for MIPS
Enabling COMPILER_RT_INCLUDE_TESTS and updating tests/sanitizer_allocator_test.cc to remove Allocator64 related tests for MIPS.

Reviewed By: samsonov

llvm-svn: 224101
2014-12-12 07:08:12 +00:00
Alexey Samsonov c60042ef8b [ASan] Group all flag parsing code together. NFC.
llvm-svn: 224087
2014-12-12 01:08:24 +00:00
Alexey Samsonov 0545f4b0f3 [ASan] Change fake stack and local variables handling.
This commit changes the way we get fake stack from ASan runtime
(to find use-after-return errors) and the way we represent local
variables:
  - __asan_stack_malloc function now returns pointer to newly allocated
    fake stack frame, or NULL if frame cannot be allocated. It doesn't
    take pointer to real stack as an input argument, it is calculated
    inside the runtime.
  - __asan_stack_free function doesn't take pointer to real stack as
    an input argument. Now this function is never called if fake stack
    frame wasn't allocated.
  - __asan_init version is bumped to reflect changes in the ABI.
  - new flag "-asan-stack-dynamic-alloca" allows to store all the
    function local variables in a dynamic alloca, instead of the static
    one. It reduces the stack space usage in use-after-return mode
    (dynamic alloca will not be called if the local variables are stored
    in a fake stack), and improves the debug info quality for local
    variables (they will not be described relatively to %rbp/%rsp, which
    are assumed to be clobbered by function calls). This flag is turned
    off by default for now, but I plan to turn it on after more
    testing.

llvm-svn: 224063
2014-12-11 21:53:19 +00:00
Alexey Samsonov 2c3045f1b9 [Sanitizer] Don't modify mmap_limit_mb flag in runtime.
Instead, rely on the fact that RAW_CHECK doesn't call mmap(),
and we'll be able to print an error message and kill a program.

llvm-svn: 224034
2014-12-11 18:45:24 +00:00
Alexey Samsonov 3a41ed1574 [Sanitizer] Fix report_path functionality:
Summary:
  - Make sure mmap() is never called inside RawWrite function.
  - Wrap a bunch of standalone globals in a ReportFile object.
  - Make sure accesses to these globals are thread-safe.
  - Fix report_path functionality on Windows, where
    __sanitizer_set_report_path() would break program.

I've started this yak shaving in order to make
"CommonFlags::mmap_limit_mb" immutable. Currently we drop this flag
to zero before printing an error message.

Test Plan: regression test suite

Reviewers: kcc, glider

Subscribers: llvm-commits

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

llvm-svn: 224031
2014-12-11 18:30:25 +00:00
Dmitry Vyukov a1038b1081 tsan: fix Go build
GetRSS is used in Go build.

llvm-svn: 224023
2014-12-11 16:12:45 +00:00
Dmitry Vyukov 4bde5c42b0 tsan: don't subtract one from fake PCs
These are fake and not actual PCs, more like function IDs.
Pass them to external symbolizer untouched.

llvm-svn: 224022
2014-12-11 16:12:16 +00:00
Evgeniy Stepanov e14d29b1de [sanitizer] Disable compile-time checks for __kernel_old_uid_t size on aarch64.
Should fix PR21476.

llvm-svn: 223925
2014-12-10 11:44:09 +00:00
Saleem Abdulrasool 1fe0c18914 builtins: cleanup constant data section selection
Each of the object formats use a different directive for selecting the constant
section.  Use a macro to avoid the duplication across a number of files.  Also
correct a small macro mismatch on the Windows case (HIDDEN_DIRECTIVE -> HIDDEN).

Patch by Vadim Chugunov!

llvm-svn: 223910
2014-12-10 02:36:22 +00:00
Alexey Samsonov 20962292e8 [DD] Don't store the second copy of CommonFlags inside DDFlags.
llvm-svn: 223909
2014-12-10 02:30:04 +00:00
Alexey Samsonov c2485cab33 [CMake] Make sure dd is built as a part of compiler-rt.
Remove unused variables and definitions in CMake files
for TSan and DD (deadlock detector).

llvm-svn: 223908
2014-12-10 02:14:15 +00:00
Justin Bogner 55248db0c9 profile: Add low level versions of profile buffer functions
On Darwin, compiler_rt uses magic linker symbols to find the profile
counters in the __DATA segment.  This is a reasonable method for
normal, hosted, userspace programs.  However programs with custom
memory layouts, such as the kernel, will need to tell compiler_rt
explicitly where to find these sections.

Patch by Lawrence D'Anna. Thanks!

llvm-svn: 223840
2014-12-09 22:07:25 +00:00
Kostya Serebryany 83ed889bbd [tsan] remove TSAN_GO in favor of SANITIZER_GO
llvm-svn: 223732
2014-12-09 01:31:14 +00:00
Kostya Serebryany 6c54a6b5dd [asan] move GetRSS from tsan to sanitizer_common
llvm-svn: 223730
2014-12-09 01:22:59 +00:00
Alexey Samsonov 761e22ad8e Update bogus file permissions.
Suggested in http://reviews.llvm.org/D6547.

llvm-svn: 223715
2014-12-08 23:28:07 +00:00
Evgeniy Stepanov 3a9be641d5 [msan] Intercept wcsto*.
Intercept wcstod, wcstof, wcstold, wcstol, wcstoul, wcstoll, wcstoull.

llvm-svn: 223650
2014-12-08 10:41:28 +00:00
Peter Collingbourne fd860bc41a [DFSAN][MIPS] adding support of DFSAN for MIPS64
Minor changes to enable DFSAN on MIPS64

Patch by Kumar Sukhani!

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

llvm-svn: 223517
2014-12-05 21:22:36 +00:00
Kuba Brecka dde00302c7 Implement AddressSanitizer suppressions.
Adds 3 new suppression types, "interceptor_name", "interceptor_via_fun", "interceptor_via_lib".

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

llvm-svn: 223508
2014-12-05 20:26:09 +00:00
Sergey Matveev eba518be94 [ASan] Refactor thread starting code.
Move thread context creation into AsanThread::Create().

llvm-svn: 223483
2014-12-05 17:31:13 +00:00
Sergey Matveev 324ed20dcd [ASan] Fix Win build following r223419.
llvm-svn: 223477
2014-12-05 16:53:58 +00:00
Dmitry Vyukov bf253a3d3f tsan: protect trace memory range on startup
so that user does not map something there ahead of us

llvm-svn: 223456
2014-12-05 10:06:06 +00:00
Sergey Matveev b029c5101f [ASan, LSan] Improve tracking of thread creation.
In the current scheme of things, the call to ThreadStart() in the child
thread is not synchronized with the parent thread. So, if a pointer is passed to
pthread_create, there may be a window of time during which this pointer will not
be discoverable by LSan. I.e. the pthread_create interceptor has already
returneed and thus the pointer is no longer on the parent stack, but we don't
yet know the location of the child stack. This has caused bogus leak reports
(see http://llvm.org/bugs/show_bug.cgi?id=21621/).

This patch makes the pthread_create interceptor wait until the child thread is
properly registered before returning.

llvm-svn: 223419
2014-12-05 00:10:15 +00:00
Kostya Serebryany 29a2236c7d [msan] allow -fsanitize-coverage=N together with -fsanitize=memory, compiler-rt part
llvm-svn: 223314
2014-12-03 23:29:14 +00:00
Hans Wennborg d59474a6cb ASan CMakeLists.txt: fix bad indent; NFC
llvm-svn: 223258
2014-12-03 19:05:42 +00:00
Evgeniy Stepanov 7395cae005 [msan] Change the way origin ids are built.
Previously, all origin ids were "chained" origins, i.e values of
ChainedOriginDepot. This added a level of indirection for simple
stack and heap allocation, which were represented as chains of
length 1. This costs both RAM and CPU, but provides a joined 2**29
origin id space. It also made function (any instrumented function)
entry non-async-signal-safe, but that does not really matter because
memory stores in track-origins=2 mode are not async-signal-safe anyway.

With this change, the type of the origin is encoded in origin id.
See comment in msan_origin.h for more details. This reduces chained and stack
origin id range to 2**28 each, but leaves extra 2**31 for heap origins.

This change should not have any user-visible effects.

llvm-svn: 223233
2014-12-03 13:58:40 +00:00
Evgeniy Stepanov 340347a83f [msan] Re-enable one test.
It has been fixed a long time ago.

llvm-svn: 223226
2014-12-03 12:11:33 +00:00
Alexey Samsonov 656c29b08f Replace InternalScopedBuffer<char> with InternalScopedString where applicable.
Summary: No functionality change.

Test Plan: make check-all

Reviewers: kcc

Reviewed By: kcc

Subscribers: llvm-commits

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

llvm-svn: 223164
2014-12-02 22:20:11 +00:00
Alexey Samsonov 3da2b06593 Add missing #include to fix Android build.
llvm-svn: 223157
2014-12-02 21:40:41 +00:00
Alexey Samsonov 0e90668f14 Simplify Symbolizer::SymbolizePC() interface.
Return a linked list of AddressInfo objects, instead of using an array of
these objects as an output parameter. This simplifies the code in callers
of this function (especially TSan).

Fix a few memory leaks from internal allocator, when the returned
AddressInfo objects were not properly cleared.

llvm-svn: 223145
2014-12-02 19:48:40 +00:00
Viktor Kutuzov fbd6ec09df [Tsan] Do not flush all streams on exit
Differential Revision: http://reviews.llvm.org/D6462

llvm-svn: 223121
2014-12-02 14:59:51 +00:00
Alexey Samsonov 4cdf4eba74 Add override specifiers to Symbolizer methods. NFC.
llvm-svn: 223094
2014-12-01 23:47:51 +00:00
Kuba Brecka 4bd88e3deb Add a HasSuppressionType method into SuppressionContext
Extending SuppressionContext to add a HasSuppressionType method that tells whether a certain suppression type is currently used or not. It's a step to implement issue suppressions for ASan, see http://reviews.llvm.org/D6280.

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

llvm-svn: 222954
2014-11-29 14:18:05 +00:00
Viktor Kutuzov 30bd345613 [Msan] Generalize mapping facilities to add FreeBSD support
Differential Revision: http://reviews.llvm.org/D6387

llvm-svn: 222919
2014-11-28 11:42:55 +00:00
Evgeniy Stepanov f34bad98af [asan] Remove the local copy of Android ucontext.h.
This header is present in the r10c release of the NDK.

llvm-svn: 222915
2014-11-28 10:37:44 +00:00
Viktor Kutuzov d977985e43 [Msan] Fix some interceptors to pass initialization on FreeBSD
Differential Revision: http://reviews.llvm.org/D6417

llvm-svn: 222885
2014-11-27 14:28:57 +00:00
Viktor Kutuzov 38ec0481d2 [Msan] Exclude non-FreeBSD interceptors on FreeBSD
Differential Revision: http://reviews.llvm.org/D6404

llvm-svn: 222822
2014-11-26 10:51:49 +00:00
Viktor Kutuzov 3e4542eac4 [Msan] Check returning value of DTLS_Get()
Differential Revision: http://reviews.llvm.org/D6403

llvm-svn: 222818
2014-11-26 10:42:02 +00:00
Alexey Samsonov 4cc76cb872 [Sanitizer] Bump kMaxPathLength to 4096 and use it more extensively instead of hardcoded constants
llvm-svn: 222803
2014-11-26 01:48:39 +00:00
Evgeniy Stepanov 089c066bd6 [msan] Remove leftover MSanDR bits in tests.
llvm-svn: 222762
2014-11-25 15:00:23 +00:00
Viktor Kutuzov 28e3d0b6f9 [Sanitizers] Intercept __tls_get_addr() and shmctl() on FreeBSD
Differential Revision: http://reviews.llvm.org/D6384

llvm-svn: 222757
2014-11-25 13:08:02 +00:00
Viktor Kutuzov 9b75b757de [Asan] Pack signal context into a structure
Differential Revision: http://reviews.llvm.org/D6148

llvm-svn: 222756
2014-11-25 13:00:21 +00:00
Yury Gribov 4646b11acf [asan] Improvements for asan deactivated mode: disable asan activation for runtime library on Linux, disable malloc checks.
Reviewed in http://reviews.llvm.org/D6265

llvm-svn: 222732
2014-11-25 07:10:30 +00:00
Kostya Serebryany 4cadd4afa0 [asan/coverage] change the way asan coverage instrumentation is done: instead of setting the guard to 1 in the generated code, pass the pointer to guard to __sanitizer_cov and set it there. No user-visible functionality change expected
llvm-svn: 222675
2014-11-24 18:49:53 +00:00
Eric Fiselier 909deebfc8 [compiler-rt] Make the MSAN wmemset intercepter call wmemset instead of memset. Fixes PR 21579
Summary:
Exactly what the title says. I've tested this change against the libc++ test failures and it solves all of them. The check-msan rule also still passes.
I'm not sure why it called memset originally. 

I can add tests if requested but currently there are no tests involving wide chars and they are a c++11 features.

Reviewers: kcc, eugenis

Reviewed By: eugenis

Subscribers: llvm-commits

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

llvm-svn: 222673
2014-11-24 18:17:04 +00:00
Jay Foad e47130e407 [ASan] Get fake stack code working with GCC 4.8.2.
Summary:
TestCases/Linux/heavy_uar_test.cc was failing on my
PowerPC64 box with GCC 4.8.2, because the compiler recognised
a memset-like loop and turned it into a call to memset, which
got intercepted by __asan_memset, which got upset because it was
being called on an address in high shadow memory.

Use break_optimization to stop the compiler from doing this.

Reviewers: kcc, samsonov

Reviewed By: kcc

Subscribers: llvm-commits

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

llvm-svn: 222572
2014-11-21 21:25:09 +00:00