Commit Graph

9049 Commits

Author SHA1 Message Date
George Karpenkov 680d102023 Splitting out test for Darwin for print-stack-trace:
New default symbolizer can not symbolize inlined function which appear
under -O3.

llvm-svn: 308925
2017-07-24 20:35:20 +00:00
Stephen Hines aba18768f4 [mips] Switch asm to __asm__ for non-GNU compiles.
Summary:
Using asm works fine for gnu11, but fails if the compiler uses C11.
Switch to the more consistent __asm__, since that is what the rest of
the source is using.

Reviewers: petarj

Reviewed By: petarj

Subscribers: llvm-commits, sdardis, arichardson, pirama

Differential Revision: https://reviews.llvm.org/D35756

llvm-svn: 308922
2017-07-24 20:25:08 +00:00
George Karpenkov b87543c704 Prefer atos to llvm-symbolizer on Darwin
atos is the default symbolizer on Apple's compiler for quite a few years now.
llvm-symbolizer is quite fragile on Darwin: for example, unless a .dSYM
file was explicitly generated symbolication would not work.
It is also very convenient when the behavior of LLVM open source
compiler matches to that of Apple's compiler on Apple's platform.
Furthermore, llvm-symbolizer is not installed on Apple's platform by
default, which leads to strange behavior during debugging: the test
might fail under lit (where it has llvm-symbolizer) but would run
properly when launched on the command line (where it does not, and atos
would be used).

Indeed, there's a downside: atos does not work properly with inlined
functions, hence the test change.
We do not think that this is a major problem, as users would often
compile with -O0 when debugging, and in any case it is preferable to
symbolizer not being able to symbolize.

Differential Revision: https://reviews.llvm.org/D35745

llvm-svn: 308908
2017-07-24 18:24:08 +00:00
Kostya Kortchinsky e6f1b7281f [scudo] Fix QuarantineChunksUpToSize failing test on AArch64
Summary:
Warm-up the other 2 sizes used by the tests, which should get rid of a failure
on AArch64.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: aemerson, rengolin, llvm-commits, kristof.beyls

Differential Revision: https://reviews.llvm.org/D35806

llvm-svn: 308907
2017-07-24 18:22:33 +00:00
Kostya Kortchinsky 2d94405a32 [scudo] Quarantine overhaul
Summary:
First, some context.

The main feedback we get about the quarantine is that it's too memory hungry.
A single MB of quarantine will have an impact of 3 to 4MB of PSS/RSS, and
things quickly get out of hand in terms of memory usage, and the quarantine
ends up disabled.

The main objective of the quarantine is to protect from use-after-free
exploitation by making it harder for an attacker to reallocate a controlled
chunk in place of the targeted freed chunk. This is achieved by not making it
available to the backend right away for reuse, but holding it a little while.

Historically, what has usually been the target of such attacks was objects,
where vtable pointers or other function pointers could constitute a valuable
targeti to replace. Those are usually on the smaller side. There is barely any
advantage in putting the quarantine several megabytes of RGB data or the like.

Now for the patch.

This patch introduces a new way the Quarantine behaves in Scudo. First of all,
the size of the Quarantine will be defined in KB instead of MB, then we
introduce a new option: the size up to which (lower than or equal to) a chunk
will be quarantined. This way, we only quarantine smaller chunks, and the size
of the quarantine remains manageable. It also prevents someone from triggering
a recycle by allocating something huge. We default to 512 bytes on 32-bit and
2048 bytes on 64-bit platforms.

In details, the patches includes the following:
- introduce `QuarantineSizeKb`, but honor `QuarantineSizeMb` if set to fall
  back to the old behavior (meaning no threshold in that case);
  `QuarantineSizeMb` is described as deprecated in the options descriptios;
  documentation update will follow;
- introduce `QuarantineChunksUpToSize`, the new threshold value;
- update the `quarantine.cpp` test, and other tests using `QuarantineSizeMb`;
- remove `AllocatorOptions::copyTo`, it wasn't used;
- slightly change the logic around `quarantineOrDeallocateChunk` to accomodate
  for the new logic; rename a couple of variables there as well;

Rewriting the tests, I found a somewhat annoying bug where non-default aligned
chunks would account for more than needed when placed in the quarantine due to
`<< MinAlignment` instead of `<< MinAlignmentLog`. This is fixed and tested for
now.

Reviewers: alekseyshl, kcc

Reviewed By: alekseyshl

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D35694

llvm-svn: 308884
2017-07-24 15:29:38 +00:00
Francis Ricci 4f82717643 [compiler-rt] Add missing const specifier to MemoryMappedSegment functions
llvm-svn: 308881
2017-07-24 14:31:01 +00:00
Vitaly Buka d4abe9e7d3 [sanitizer_common] Move filesystem-related code out of sanitizer_common.cc
Summary:
This is a pure refactoring change.  It just moves code that is
related to filesystem operations from sanitizer_common.{cc,h} to
sanitizer_file.{cc,h}.  This makes it cleaner to disable the
filesystem-related code for a new port that doesn't want it.

Submitted on behalf of Roland McGrath.

Reviewers: kcc, eugenis, alekseyshl

Reviewed By: alekseyshl

Subscribers: vitalybuka, llvm-commits, kubamracek, mgorny, phosek

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D35591

llvm-svn: 308819
2017-07-22 01:46:40 +00:00
Erich Keane a021743cfd Remove Bitrig: CompilerRT Changes
Bitrig code has been merged back to OpenBSD, thus the OS has been abandoned.

Differential Revision: https://reviews.llvm.org/D35709

llvm-svn: 308798
2017-07-21 22:47:46 +00:00
Dean Michael Berris d8e12128dc [XRay][compiler-rt] Update test to account for change in logging format.
Fixes build breakage for some bots after we've started logging both the
process id and the thread id.

llvm-svn: 308701
2017-07-21 00:30:04 +00:00
Vitaly Buka 6d8fb107b2 Add end-to-end tests for overflows of byval arguments.
Summary:
Included is one test for passing structs by value and one test for passing C++
objects by value.

Submitted on behalf of Matt Morehouse.

Reviewers: eugenis, vitalybuka

Reviewed By: eugenis

Subscribers: srhines, kubamracek, llvm-commits

Differential Revision: https://reviews.llvm.org/D34827

llvm-svn: 308677
2017-07-20 21:40:53 +00:00
Francis Ricci d08a0864e4 Revert "Add MemoryMappedSection struct for two-level memory map iteration"
This probably broke lib0 tsan unit test on 10.11 buildbots

This reverts commit 35ad307c385e384f47a7fb348c14b3602d3a33c4.

llvm-svn: 308676
2017-07-20 21:23:14 +00:00
Vitaly Buka 04787bbc98 [tsan] Update unittest for logging changes of r308637
llvm-svn: 308660
2017-07-20 20:06:00 +00:00
Vitaly Buka fddf535d48 [compiler-rt] Use NOINLE to shrink stack frames
llvm-svn: 308654
2017-07-20 18:54:26 +00:00
Vitaly Buka a19a2762e3 [compiler-rt] Reorder functions to shrink stack frames
llvm-svn: 308652
2017-07-20 18:47:01 +00:00
Vitaly Buka 72b40fbf4d Revert "[compiler-rt] Reorder functions to have smaller stack frames"
Does not compile.

This reverts commit r308650.

llvm-svn: 308651
2017-07-20 18:43:56 +00:00
Vitaly Buka b49c933338 [compiler-rt] Reorder functions to have smaller stack frames
llvm-svn: 308650
2017-07-20 18:43:09 +00:00
Vitaly Buka 094684c155 Revert "[sanitizer_common] Move filesystem-related code out of sanitizer_common.cc"
Breaks Windows build.

This reverts commit r308640.

llvm-svn: 308648
2017-07-20 18:24:45 +00:00
Vitaly Buka 1eb9595c53 [asan] Update unittest for changes in logging r308637
llvm-svn: 308647
2017-07-20 18:20:12 +00:00
Francis Ricci 0ba09182bd Add MemoryMappedSection struct for two-level memory map iteration
Summary: This will allow sanitizer_procmaps on mac to expose section information.

Reviewers: kubamracek, alekseyshl, kcc

Subscribers: llvm-commits, emaste

Differential Revision: https://reviews.llvm.org/D35422

llvm-svn: 308644
2017-07-20 18:06:02 +00:00
Alex Shlyapnikov 89e85d1717 [sanitizer_common] Move filesystem-related code out of sanitizer_common.cc
This is a pure refactoring change. It just moves code that is
related to filesystem operations from sanitizer_common.{cc,h} to
sanitizer_file.{cc,h}. This makes it cleaner to disable the
filesystem-related code for a new port that doesn't want it.

Commiting for mcgrathr.

Reviewers: alekseyshl

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D35591

llvm-svn: 308640
2017-07-20 17:48:42 +00:00
Vitaly Buka bedb2601c1 [compiler-rt] Include thread ID into sanitizers logs
Reviewers: kcc, alekseyshl

Subscribers: kubamracek, llvm-commits, dberris

Differential Revision: https://reviews.llvm.org/D35654

llvm-svn: 308637
2017-07-20 17:31:08 +00:00
Kamil Rytarowski fc1651cb1a Honour 80-character line limit
llvm-svn: 308620
2017-07-20 14:15:00 +00:00
Kamil Rytarowski d9e9e44baa Add NetBSD support in sanitizer_libignore.cc
Summary:
Reuse Linux, FreeBSD and Apple code - no NetBSD specific changes.

Part of the code inspired by the original work on libsanitizer in GCC 5.4 by Christos Zoulas.
    
Sponsored by <The NetBSD Foundation>

Reviewers: joerg, vitalybuka, filcab, kcc

Reviewed By: filcab

Subscribers: emaste, kubamracek, llvm-commits

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D35628

llvm-svn: 308616
2017-07-20 13:33:06 +00:00
Kamil Rytarowski 734acfda0f Add NetBSD support in sanitizer_procmaps.h
Summary:
Reuse Linux and FreeBSD - no NetBSD specific changes.

Part of the code inspired by the original work on libsanitizer in GCC 5.4 by Christos Zoulas.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, filcab, kcc, vitalybuka

Reviewed By: filcab

Subscribers: llvm-commits, emaste, kubamracek, #sanitizers

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D35629

llvm-svn: 308615
2017-07-20 13:31:06 +00:00
Kamil Rytarowski bd82d28413 Add NetBSD support in sanitizer_procmaps_common.cc
Summary:
Reuse Linux and FreeBSD code - no NetBSD specific changes.

Part of the code inspired by the original work on libsanitizer in GCC 5.4 by Christos Zoulas.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, kcc, vitalybuka, filcab

Reviewed By: filcab

Subscribers: emaste, kubamracek, llvm-commits, #sanitizers

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D35632

llvm-svn: 308614
2017-07-20 13:28:28 +00:00
Vitaly Buka 7af8fa41d3 [compiler-rt] Replace VPrintf with VReport in sanitizer_tls_get_addr.cc
Summary:
Thread id will be added to VRerort. Having thread here is useful.
This is also common place for logging for all sanitizers, so I can use this in
common test.

Reviewers: kcc, alekseyshl

Subscribers: kubamracek, llvm-commits, dberris

Differential Revision: https://reviews.llvm.org/D35655

llvm-svn: 308578
2017-07-20 01:36:16 +00:00
Alex Shlyapnikov 36a1c17dff [asan] Move memcpy, memmove, memset code out of asan_interceptors.cc
This is a pure refactoring change. It simply moves all the code and
macros related to defining the ASan interceptor versions of memcpy,
memmove, and memset into a separate file. This makes it cleaner to
disable all the other interceptor code while still using these three,
for a port that defines these but not the other common interceptors.

Reviewers: alekseyshl

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D35590

llvm-svn: 308575
2017-07-20 01:29:01 +00:00
Craig Topper b77279083c [X86][builtins] Sync getX86CpuIDAndInfoEx with llvm's Host.cpp again.
We now use __cpuidex intrinsics intead of inline asm on 32-bit Windows. We already used it on 64-bit.

llvm-svn: 308420
2017-07-19 05:11:20 +00:00
Francis Ricci bf60f68c2c Revert "Add MemoryMappedSection struct for two-level memory map iteration"
This reverts commit c8095ce74118dee8544b0f1ffaba8f46aa10215c.

Reverted due to some buildbot timeouts, perhaps due to 10.11 issues.

llvm-svn: 308395
2017-07-18 23:51:47 +00:00
Francis Ricci 1b5f773859 Revert "Only scan global sections containing data in LSan on darwin"
This reverts commit 7e46d78d47832f03ce42adcf56417fbfd47cbaad.

llvm-svn: 308394
2017-07-18 23:51:44 +00:00
Francis Ricci e43f27666d Don't call exit() from atexit handlers on Darwin
Summary:
Calling exit() from an atexit handler is undefined behavior.
On Linux, it's unavoidable, since we cannot intercept exit (_exit isn't called
if a user program uses return instead of exit()), and I haven't
seen it cause issues regardless.

However, on Darwin, I have a fairly complex internal test that hangs roughly
once in every 300 runs after leak reporting finishes, which is resolved with
this patch, and is presumably due to the undefined behavior (since the Die() is
the only thing that happens after the end of leak reporting).

In addition, this is the way TSan works as well, where an atexit handler+Die()
is used on Linux, and an _exit() interceptor is used on Darwin. I'm not sure if it's
intentionally structured that way in TSan, since TSan sets up the atexit handler and the
_exit() interceptor on both platforms, but I have observed that on Darwin, only the
_exit() interceptor is used, and on Linux the atexit handler is used.

There is some additional related discussion here: https://reviews.llvm.org/D35085

Reviewers: alekseyshl, kubamracek

Subscribers: eugenis, vsk, llvm-commits

Differential Revision: https://reviews.llvm.org/D35513

llvm-svn: 308353
2017-07-18 20:18:32 +00:00
Alex Shlyapnikov 42bea018af [Sanitizers] ASan/MSan/LSan allocators set errno on failure.
Summary:
ASan/MSan/LSan allocators set errno on allocation failures according to
malloc/calloc/etc. expected behavior.

MSan allocator was refactored a bit to make its structure more similar
with other allocators.

Also switch Scudo allocator to the internal errno definitions.

TSan allocator changes will follow.

Reviewers: eugenis

Subscribers: llvm-commits, kubamracek

Differential Revision: https://reviews.llvm.org/D35275

llvm-svn: 308344
2017-07-18 19:11:04 +00:00
Vitaly Buka 013317d9d5 [asan] Remove recent asan tests which expect death in allocator
These tests assume allocator_may_return_null=false
If allocator_may_return_null=true, gtest would not be able to switch it.
Tests needs to be re-implemented as lit tests.

llvm-svn: 308254
2017-07-18 01:39:56 +00:00
Francis Ricci 7096b08cd7 Only scan global sections containing data in LSan on darwin
Summary:
__DATA segments on Darwin contain a large number of separate sections,
most of which cannot actually contain pointers, and contain const values or
objc metadata. Only scanning sections which can contain pointers greatly improves
performance.

On a medium-sized (~4000 files) internal project, I saw a speedup of about 50%
in standalone LSan's execution time (50% improvement in the time spent running
LSan, not the total program time).

Reviewers: kcc, kubamracek, alekseyshl

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D35432

llvm-svn: 308231
2017-07-17 23:03:03 +00:00
Vitaly Buka 4a8f16ec9d [sanitizers] Make sure that all complex macros uses parenthesis
Summary:
Without them expressions like this may have different values.
(SANITIZER_INTERCEPT_MEMRCHR && SANITIZER_INTERCEPT_PREADV)

Reviewers: alekseyshl

Subscribers: srhines, kubamracek, llvm-commits

Differential Revision: https://reviews.llvm.org/D35512

llvm-svn: 308228
2017-07-17 22:49:46 +00:00
Kamil Rytarowski e9140e5b95 Add missing && to fix syntax.
llvm-svn: 308221
2017-07-17 21:09:34 +00:00
Kamil Rytarowski 20f5a5c64c Add NetBSD support in platform_interceptors.h
Summary:
Introduce SI_NETBSD for NetBSD.

Add NetBSD support for appropriate `SANITIZER_INTERCEPT_*`.

Part of the code inspired by the original work on libsanitizer in GCC 5.4 by Christos Zoulas.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, dim, kcc, alekseyshl, filcab, eugenis, vitalybuka

Reviewed By: vitalybuka

Subscribers: srhines, kubamracek, #sanitizers

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D35468

llvm-svn: 308217
2017-07-17 20:49:13 +00:00
Kamil Rytarowski 27169a7709 Introduce SANITIZER_NETBSD in sanitizer_platform.h
Summary:
Add defines for new NetBSD: SANITIZER_NETBSD,
it will be used across the codebase for sanitizers.

NetBSD is a POSIX-like platform, add it to SANITIZER_POSIX.

Part of the code inspired by the original work on libsanitizer in GCC 5.4 by Christos Zoulas.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, kcc, dim, alekseyshl, filcab, eugenis, vitalybuka

Reviewed By: kcc

Subscribers: kubamracek, #sanitizers

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D35467

llvm-svn: 308216
2017-07-17 20:47:53 +00:00
Francis Ricci 455ba3fd79 Add MemoryMappedSection struct for two-level memory map iteration
Summary: This will allow sanitizer_procmaps on mac to expose section information.

Reviewers: kubamracek, alekseyshl, kcc

Subscribers: llvm-commits, emaste

Differential Revision: https://reviews.llvm.org/D35422

llvm-svn: 308210
2017-07-17 20:09:20 +00:00
Vitaly Buka 923ddad4c6 [asan] Disable not working new test on Windows
llvm-svn: 308123
2017-07-16 01:28:40 +00:00
Vitaly Buka d8afaeb866 [msan] Add missing include for fix test on Windows
llvm-svn: 308122
2017-07-16 01:19:35 +00:00
Vitaly Buka a016feb7a1 [tsan] Disable test with debug runtime
Test expects at least -O1 compiled runtime.

llvm-svn: 308121
2017-07-16 01:05:37 +00:00
Vitaly Buka 3f25b53485 [asan] Attempt to fix test in Windows after r308064
llvm-svn: 308120
2017-07-16 00:40:40 +00:00
Vitaly Buka 50648af623 [compiler-rt] Fix fix format specifies type in test
llvm-svn: 308117
2017-07-16 00:17:11 +00:00
George Karpenkov e89d0a8f5c [compiler-rt] [CMake] Build compiler-rt with no optimizations if the flag says so
Differential Revision: https://reviews.llvm.org/D35400

llvm-svn: 308072
2017-07-15 00:30:46 +00:00
Alex Shlyapnikov 31e8173c94 [Sanitizers] ASan and LSan allocator set errno on failure.
Summary:
Set proper errno code on alloction failures and change some
implementations to satisfy their man-specified requirements:

LSan: valloc and memalign
ASan: pvalloc, memalign and posix_memalign

Changing both allocators in one patch since LSan depends on ASan allocator in some configurations.

Reviewers: vitalybuka

Subscribers: kubamracek, llvm-commits

Differential Revision: https://reviews.llvm.org/D35440

llvm-svn: 308064
2017-07-14 22:23:47 +00:00
Alex Shlyapnikov d08c32b2f4 [Sanitizers] LSan allocator set errno on failure.
Set proper errno code on alloction failures and change valloc and
memalign implementations to satisfy their man-specified requirements.

llvm-svn: 308063
2017-07-14 22:23:46 +00:00
Alex Shlyapnikov df18cbba55 [Sanitizers] Scudo allocator set errno on failure.
Summary:
Set proper errno code on alloction failure and change pvalloc and
posix_memalign implementation to satisfy their man-specified
requirements.

Reviewers: cryptoad

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D35429

llvm-svn: 308053
2017-07-14 21:17:16 +00:00
Dmitry Vyukov 9f2c6207d5 tsan: optimize sync clock memory consumption
This change implements 2 optimizations of sync clocks that reduce memory consumption:

Use previously unused first level block space to store clock elements.
Currently a clock for 100 threads consumes 3 512-byte blocks:

2 64-bit second level blocks to store clock elements
+1 32-bit first level block to store indices to second level blocks
Only 8 bytes of the first level block are actually used.
With this change such clock consumes only 2 blocks.

Share similar clocks differing only by a single clock entry for the current thread.
When a thread does several release operations on fresh sync objects without intervening
acquire operations in between (e.g. initialization of several fields in ctor),
the resulting clocks differ only by a single entry for the current thread.
This change reuses a single clock for such release operations. The current thread time
(which is different for different clocks) is stored in dirty entries.

We are experiencing issues with a large program that eats all 64M clock blocks
(32GB of non-flushable memory) and crashes with dense allocator overflow.
Max number of threads in the program is ~170 which is currently quite unfortunate
(consume 4 blocks per clock). Currently it crashes after consuming 60+ GB of memory.
The first optimization brings clock block consumption down to ~40M and
allows the program to work. The second optimization further reduces block consumption
to "modest" 16M blocks (~8GB of RAM) and reduces overall RAM consumption to ~30GB.

Measurements on another real world C++ RPC benchmark show RSS reduction
from 3.491G to 3.186G and a modest speedup of ~5%.

Go parallel client/server HTTP benchmark:
https://github.com/golang/benchmarks/blob/master/http/http.go
shows RSS reduction from 320MB to 240MB and a few percent speedup.

Reviewed in https://reviews.llvm.org/D35323

llvm-svn: 308018
2017-07-14 11:30:06 +00:00
Kostya Serebryany c56d444b75 Fix sanitizer build against latest glibc
Summary:
libsanitizer doesn't build against latest glibc anymore, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81066 for details.
One of the changes is that stack_t changed from typedef struct sigaltstack { ... } stack_t; to typedef struct { ... } stack_t; for conformance reasons.
And the other change is that the glibc internal __need_res_state macro is now ignored, so when doing
```
#define __need_res_state
#include <resolv.h>
```
the effect is now the same as just
```
#include <resolv.h>
```
and thus one doesn't get just the
```
struct __res_state { ... };
```
definition, but newly also the
```
extern struct __res_state *__res_state(void) __attribute__ ((__const__));
```
prototype.  So __res_state is no longer a type, but a function.

Reviewers: kcc, ygribov

Reviewed By: kcc

Subscribers: kubamracek

Differential Revision: https://reviews.llvm.org/D35246

llvm-svn: 307969
2017-07-13 21:59:01 +00:00
Kostya Kortchinsky b44364dd15 [scudo] Do not grab a cache for secondary allocation & per related changes
Summary:
Secondary backed allocations do not require a cache. While it's not necessary
an issue when each thread has its cache, it becomes one with a shared pool of
caches (Android), as a Secondary backed allocation or deallocation holds a
cache that could be useful to another thread doing a Primary backed allocation.

We introduce an additional PRNG and its mutex (to avoid contention with the
Fallback one for Primary allocations) that will provide the `Salt` needed for
Secondary backed allocations.

I changed some of the code in a way that feels more readable to me (eg: using
some values directly rather than going  through ternary assigned variables,
using directly `true`/`false` rather than `FromPrimary`). I will let reviewers
decide if it actually is.

An additional change is to mark `CheckForCallocOverflow` as `UNLIKELY`.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D35358

llvm-svn: 307958
2017-07-13 21:01:19 +00:00
Vedant Kumar 965f23fe84 [ubsan] Teach the pointer overflow check that "p - <unsigned> <= p" (compiler-rt)
Compiler-rt changes associated with: D34121

llvm-svn: 307956
2017-07-13 20:55:41 +00:00
Kuba Mracek f0c652a52e For Darwin's GetTaskInfoMaxAddress, define the real structure with real fields to avoid confusion. NFC.
llvm-svn: 307945
2017-07-13 20:02:45 +00:00
Craig Topper e6b07073ca [compiler-rt][X86] Match the detection of cpu's for __cpu_model to the latest version of gcc
Summary:
We were missing many feature flags that newer gcc supports and we had our own set of feature flags that gcc didnt' support that were overlapping. Clang's implementation assumes gcc's features list so a mismatch here is problematic.

I've also matched the cpu type/subtype lists with gcc and removed all the cpus that gcc doesn't support. I've also removed the fallback autodetection logic that was taken from Host.cpp. It was the main reason we had extra feature flags relative to gcc. I don't think gcc does this in libgcc.

Once this support is in place we can consider implementing __builtin_cpu_is in clang. This could also be needed for function dispatching that Erich Keane is working on.

Reviewers: echristo, asbirlea, RKSimon, erichkeane, zvi

Reviewed By: asbirlea

Subscribers: dberris, llvm-commits

Differential Revision: https://reviews.llvm.org/D35214

llvm-svn: 307878
2017-07-13 02:56:24 +00:00
Xinliang David Li 028c78b593 Fix broken test
llvm-svn: 307869
2017-07-13 00:22:01 +00:00
Vitaly Buka 9fd492e71e [asan] Avoid recompilation of the same code in the test
llvm-svn: 307868
2017-07-12 23:59:22 +00:00
Kuba Mracek c1e903be19 [asan] For iOS/AArch64, if the dynamic shadow doesn't fit, restrict the VM space
On iOS/AArch64, the address space is very limited and has a dynamic maximum address based on the configuration of the device. We're already using a dynamic shadow, and we find a large-enough "gap" in the VM where we place the shadow memory. In some cases and some device configuration, we might not be able to find a large-enough gap: E.g. if the main executable is linked against a large number of libraries that are not part of the system, these libraries can fragment the address space, and this happens before ASan starts initializing.

This patch has a solution, where we have a "backup plan" when we cannot find a large-enough gap: We will restrict the address space (via MmapFixedNoAccess) to a limit, for which the shadow limit will fit.

Differential Revision: https://reviews.llvm.org/D35098

llvm-svn: 307865
2017-07-12 23:29:21 +00:00
Xinliang David Li 07df59b7b6 [PGO] Add a test for 2-deep loop nest
llvm-svn: 307864
2017-07-12 23:28:45 +00:00
Kuba Mracek 7004b7cf0d Add explicit CMake targets for ASan/TSan iOS Simulator testing and update the instructions how to run them.
llvm-svn: 307844
2017-07-12 21:02:48 +00:00
Kuba Mracek 4c4ea1d1ba On Darwin, start building the TSan iOS dylib by default.
llvm-svn: 307839
2017-07-12 20:25:14 +00:00
Petr Hosek 969518b442 [builtins] Better Fuchsia support
Add Fuchsia support to some builtings and avoid building builtins
that are not and will never be used on Fuchsia.

Differential Revision: https://reviews.llvm.org/D34075

llvm-svn: 307832
2017-07-12 19:33:30 +00:00
Kuba Mracek 46f2b8485a On Darwin, start building the TSan dylib for the iOS simulator.
llvm-svn: 307816
2017-07-12 17:30:54 +00:00
Kuba Mracek 476c3e9ba0 Fix the declaration of DARWIN_PREFER_PUBLIC_SDK cmake variable (move before the return).
llvm-svn: 307815
2017-07-12 17:11:53 +00:00
Kostya Kortchinsky 00582563be [scudo] PRNG makeover
Summary:
This follows the addition of `GetRandom` with D34412. We remove our
`/dev/urandom` code and use the new function. Additionally, change the PRNG for
a slightly faster version. One of the issues with the old code is that we have
64 full bits of randomness per "next", using only 8 of those for the Salt and
discarding the rest. So we add a cached u64 in the PRNG that can serve up to
8 u8 before having to call the "next" function again.

During some integration work, I also realized that some very early processes
(like `init`) do not benefit from `/dev/urandom` yet. So if there is no
`getrandom` syscall as well, we have to fallback to some sort of initialization
of the PRNG.

Now a few words on why XoRoShiRo and not something else. I have played a while
with various PRNGs on 32 & 64 bit platforms. Some results are below. LCG 32 & 64
are usually faster but produce respectively 15 & 31 bits of entropy, meaning
that to get a full 64-bit, you would need to call them several times. The simple
XorShift is fast, produces 32 bits but is mediocre with regard to PRNG test
suites, PCG is slower overall, and XoRoShiRo is faster than XorShift128+ and
produces full 64 bits.

%%%
root@tulip-chiphd:/data # ./randtest.arm
[+] starting xs32...
[?] xs32 duration: 22431833053ns
[+] starting lcg32...
[?] lcg32 duration: 14941402090ns
[+] starting pcg32...
[?] pcg32 duration: 44941973771ns
[+] starting xs128p...
[?] xs128p duration: 48889786981ns
[+] starting lcg64...
[?] lcg64 duration: 33831042391ns
[+] starting xos128p...
[?] xos128p duration: 44850878605ns

root@tulip-chiphd:/data # ./randtest.aarch64
[+] starting xs32...
[?] xs32 duration: 22425151678ns
[+] starting lcg32...
[?] lcg32 duration: 14954255257ns
[+] starting pcg32...
[?] pcg32 duration: 37346265726ns
[+] starting xs128p...
[?] xs128p duration: 22523807219ns
[+] starting lcg64...
[?] lcg64 duration: 26141304679ns
[+] starting xos128p...
[?] xos128p duration: 14937033215ns
%%%

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: aemerson, kristof.beyls, llvm-commits

Differential Revision: https://reviews.llvm.org/D35221

llvm-svn: 307798
2017-07-12 15:29:08 +00:00
Dmitry Vyukov 1fa729999b tsan: remove some clock-related stats
The stats are too dependent on implementation
and won't be relevant in future.

llvm-svn: 307786
2017-07-12 12:54:38 +00:00
Dmitry Vyukov 62b9ad718f tsan: refactor SyncClock code
1. Add SyncClock::ResetImpl which removes code
   duplication between ctor and Reset.
2. Move SyncClock::Resize to SyncClock methods,
   currently it's defined between ThreadClock methods.

llvm-svn: 307785
2017-07-12 12:50:36 +00:00
Dmitry Vyukov 5f924089e5 tsan: prepare clock for future changes
Pass ClockCache to ThreadClock::set and introduce ThreadCache::ResetCached.
For now both are unused, but will reduce future diffs.

llvm-svn: 307784
2017-07-12 12:45:20 +00:00
Dmitry Vyukov 293b4fc04e tsan: s/-1/kInvalidTid/
llvm-svn: 307781
2017-07-12 12:36:44 +00:00
Dmitry Vyukov 5abf9bb1ca tsan: give debug names to dense allocators
Improves crash message on dense alloc overflow.
Allows to understand what alloc overflowed.

llvm-svn: 307780
2017-07-12 12:34:12 +00:00
Dmitry Vyukov 7bf9ee041a tsan: don't create sync objects on acquire-load
Don't create sync object if it does not exist yet. For example, an atomic
pointer is initialized to nullptr and then periodically acquire-loaded.

llvm-svn: 307778
2017-07-12 12:28:23 +00:00
Dmitry Vyukov 0a9265c26c tsan: add another test for clock growth
llvm-svn: 307777
2017-07-12 12:25:03 +00:00
Dmitry Vyukov 05d297080e tsan: add test for __tsan_java_find
The test should have been added in 289682
"tsan: allow Java VM iterate over allocated objects"
but I forgot to avn add.

Author: Alexander Smundak (asmundak)
Reviewed in https://reviews.llvm.org/D27720

llvm-svn: 307776
2017-07-12 12:23:31 +00:00
Vitaly Buka 11fe7beda9 [tsan] Update test to r307338
r307338 enabled new optimization reducing number of operation in tested functions.
There is no any performance regression detectable with TsanRtlTest DISABLED_BENCH.Mop* tests.

llvm-svn: 307739
2017-07-12 00:14:05 +00:00
Francis Ricci 9fd8a6381c Use internal_strncpy to copy filename in linux procmaps
Cleaner than using a while loop to copy the string character by character.

Reviewers: alekseyshl, glider

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D35136

llvm-svn: 307696
2017-07-11 19:40:54 +00:00
Francis Ricci edd53cb652 Inline function to get mac segment address range
Summary:
This function is only called once and is fairly simple. Inline to
keep API simple.

Reviewers: alekseyshl, kubamracek

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D35270

llvm-svn: 307695
2017-07-11 19:40:53 +00:00
Francis Ricci f6a4329b7d Refactor MemoryMappingLayout::Next to use a single struct instead of output parameters. NFC.
Summary:
This is the first in a series of patches to refactor sanitizer_procmaps
to allow MachO section information to be exposed on darwin.

In addition, grouping all segment information in a single struct is
cleaner than passing it through a large set of output parameters, and
avoids the need for annotations of NULL parameters for unneeded
information.

The filename string is optional and must be managed and supplied by the
calling function. This is to allow the MemoryMappedSegment struct to be
stored on the stack without causing overly large stack sizes.

Reviewers: alekseyshl, kubamracek, glider

Subscribers: emaste, llvm-commits

Differential Revision: https://reviews.llvm.org/D35135

llvm-svn: 307688
2017-07-11 18:54:00 +00:00
Evgeniy Stepanov b76e4d12f4 [asan] Fix asan_device_setup --use-su mode on Android 7.x.
mount command does not accept -o remount,rw flag on some versions of Android.
mount -o rw,remount works everywhere.

llvm-svn: 307685
2017-07-11 18:18:50 +00:00
Petar Jovanovic adf4ce3a2c Remove duplicate assignments in stat64/kernel_stat_to_stat functions
Remove duplicate assignments in stat64_to_stat() and kernel_stat_to_stat().

llvm-svn: 307657
2017-07-11 13:03:48 +00:00
George Karpenkov 0b4ebb1d0b Do not crash with missing symbolication when running in DEDUP mode
Printing stacktrace from ASAN crashes with a segfault in DEDUP mode when
symbolication is missing.

Differential Revision: https://reviews.llvm.org/D34914

llvm-svn: 307577
2017-07-10 20:06:06 +00:00
Kuba Mracek 7fa20ac847 Add an #if SANITIZER_MAC and a comment to lsan_common's suppression for "_os_trace".
llvm-svn: 307567
2017-07-10 18:55:33 +00:00
Craig Topper 76ac813790 [X86] Sync a few more things from llvm's Host.cpp to cpu_model.
This syncs the cpuid functions and adds breaks to the appropriate spots in the CPU decoding switches. Also a few formatting tweaks.

llvm-svn: 307561
2017-07-10 17:47:23 +00:00
Craig Topper 61d8450277 [X86] Resync cpu_model.c with llvm's Host.cpp in preparation for making it compatible with newer gcc.
llvm-svn: 307558
2017-07-10 17:30:20 +00:00
Kuba Mracek 21ad3fd3c5 Fix-up for r307537: We need to #include stdint.h to get int32_t.
llvm-svn: 307557
2017-07-10 17:11:52 +00:00
Kuba Mracek dbfd7f35ff Fix a build failure due to r307541 (tsan_rtl_aarch64.S:54: Error: unknown pseudo-op: `.').
llvm-svn: 307549
2017-07-10 15:58:22 +00:00
Kuba Mracek 6496d92dd2 [lsan] Add _os_trace into LSan's suppression list
Differential Revision: https://reviews.llvm.org/D35173

llvm-svn: 307548
2017-07-10 15:55:25 +00:00
Kuba Mracek 9ae34c2d3f Fix-up for r307540.
llvm-svn: 307547
2017-07-10 15:52:30 +00:00
Kuba Mracek 7cd7c1a7b5 [tsan] Add comments for the bool argument of ThreadIgnoreBegin/ThreadIgnoreSyncBegin, NFC.
Differential Revision: https://reviews.llvm.org/D35134

llvm-svn: 307545
2017-07-10 15:37:13 +00:00
Kuba Mracek f20cb690b5 [tsan] Add a mapping for Darwin/AArch64
This patch defines the TSan memory map and offsets for Darwin on AArch64.

Differential Revision: https://reviews.llvm.org/D35147

llvm-svn: 307544
2017-07-10 15:35:04 +00:00
Kuba Mracek 8bd2cca391 [tsan] Port setjmp/longjmp assembly to Darwin/AArch64
This patch ports the assembly file implementing TSan's setjmp support to AArch64 on Darwin.

Differential Revision: https://reviews.llvm.org/D35143

llvm-svn: 307541
2017-07-10 15:28:16 +00:00
Kuba Mracek 8b225456c2 [tsan] Add a max VM address check for Darwin/AArch64
Differential Revision: https://reviews.llvm.org/D35154

llvm-svn: 307540
2017-07-10 15:24:48 +00:00
Kuba Mracek 989513be94 Reverting an accidentally landed change.
llvm-svn: 307539
2017-07-10 15:20:50 +00:00
Kuba Mracek 872cb7086c Fixup whitespace.
llvm-svn: 307538
2017-07-10 15:19:14 +00:00
Kuba Mracek 91f3fa5f31 [tsan] Add support for running TSan tests on iOS simulator and devices
Differential Revision: https://reviews.llvm.org/D35157

llvm-svn: 307537
2017-07-10 15:00:55 +00:00
Kuba Mracek 5c2e3e2b75 Make sure SANITIZER_MIN_OSX_VERSION is defined before using it.
llvm-svn: 307448
2017-07-07 22:40:13 +00:00
Kuba Mracek afbde43a8f Update buildgo.sh to pass -isysroot on Darwin.
llvm-svn: 307443
2017-07-07 21:17:29 +00:00
Kuba Mracek 0fa9d68740 Fix-up for r307307: vm_info.max_address is the first non-addressable pointer, so we need to subtract one.
llvm-svn: 307408
2017-07-07 15:32:44 +00:00
Evgeniy Stepanov 7d3eeaaa96 Revert r307342, r307343.
Revert "Copy arguments passed by value into explicit allocas for ASan."
Revert "[asan] Add end-to-end tests for overflows of byval arguments."

Build failure on lldb-x86_64-ubuntu-14.04-buildserver.
Test failure on clang-cmake-aarch64-42vma and sanitizer-x86_64-linux-android.

llvm-svn: 307345
2017-07-07 01:31:23 +00:00
Kuba Mracek 7a493393b3 [cmake] Cache results of find_darwin_sdk_dir
This improves find_darwin_sdk_dir to cache the results of executing xcodebuild to find the SDK. Should significantly reduce the CMake re-configure time.

Differential Revision: https://reviews.llvm.org/D34736

llvm-svn: 307344
2017-07-07 01:06:20 +00:00
Evgeniy Stepanov 03542db81c [asan] Add end-to-end tests for overflows of byval arguments.
Included is one test for passing structs by value and one test for passing C++
objects by value.

Patch by Matt Morehouse.

Differential revision: https://reviews.llvm.org/D34827

llvm-svn: 307343
2017-07-07 00:48:38 +00:00
Kuba Mracek 935243486c [cmake] Add an option to prefer public SDK in find_darwin_sdk_dir
Adds a CMake option DARWIN_PREFER_PUBLIC_SDK, off by default. When on, this prefers to use the public SDK, even when an internal one is present. With this, it's easy to emulate a build that the public buildbots are doing.

Differential Revision: https://reviews.llvm.org/D35071

llvm-svn: 307330
2017-07-06 23:09:16 +00:00
Reid Kleckner da565bc97c [asan] Fix -Winvalid-paste error with clang-cl
We don't need to paste tokens here. String literal concatenation works
just fine here with MSVC and Clang.

llvm-svn: 307321
2017-07-06 21:51:32 +00:00
Kuba Mracek 560440975a Fix whitespace lint issue (introduced in r307307).
llvm-svn: 307309
2017-07-06 20:38:33 +00:00
Kuba Mracek e9b5857db3 [sanitizer] Use TASK_VM_INFO to get the maximum VM address on iOS/AArch64
We currently hardcode the maximum VM address on iOS/AArch64, which is not really correct and this value changes between device configurations. Let's use TASK_VM_INFO to retrieve the maximum VM address dynamically.

Differential Revision: https://reviews.llvm.org/D35032

llvm-svn: 307307
2017-07-06 20:30:09 +00:00
Kuba Mracek c7f895351e More fixup for r307281: Move the #includes to sanitizer_linux.cc
llvm-svn: 307284
2017-07-06 17:45:01 +00:00
Kuba Mracek 47e994c4f1 Fixup for r307281: Also move GetKernelAreaSize into sanitizer_linux.cc
llvm-svn: 307282
2017-07-06 17:17:50 +00:00
Kuba Mracek 72665d6c15 [sanitizer] Split GetMaxVirtualAddress into separate Linux version and Mac version [NFC]
The logic in GetMaxVirtualAddress is already pretty complex, and I want to get rid of the hardcoded value for iOS/AArch64, which would need adding more Darwin-specific code, so let's split the implementation into sanitizer_linux.cc and sanitizer_mac.cc files. NFC.

Differential Revision: https://reviews.llvm.org/D35031

llvm-svn: 307281
2017-07-06 17:13:40 +00:00
Alex Shlyapnikov 35adb43950 [Sanitizers] Consolidate internal errno definitions.
Move internal errno definitions to common to be shared by all sanitizers
and to be used by allocators.

llvm-svn: 307233
2017-07-06 00:50:57 +00:00
Kuba Mracek 7149ca04ad [tsan] Use pthread_sigmask instead of sigprocmask to block signals in a thread on Darwin
On Darwin, sigprocmask changes the signal mask for the entire process. This has some unwanted consequences, because e.g. internal_start_thread wants to disable signals only in the current thread (to make the new thread inherit the signal mask), which is currently broken on Darwin. This patch switches to pthread_sigmask.

Differential Revision: https://reviews.llvm.org/D35016

llvm-svn: 307212
2017-07-05 22:17:44 +00:00
Jonas Hahnfeld 5b14061848 [asan] Remove check for stack size
This has been introduced in r304598 and fails for increased stack sizes.

Differential Revision: https://reviews.llvm.org/D34876

llvm-svn: 307127
2017-07-05 06:54:43 +00:00
Hiroshi Inoue 7e6d29535d fix trivial typos in comments; NFC
llvm-svn: 307124
2017-07-05 05:43:31 +00:00
Hiroshi Inoue 03656aa3dc fix trivial typos in comments; NFC
llvm-svn: 307005
2017-07-03 06:44:05 +00:00
Hiroshi Inoue 85c529c988 fix trivial typo; NFC
llvm-svn: 306955
2017-07-01 08:58:47 +00:00
Vitaly Buka 080118351b [asan] This Android lit workaround should not be needed as bug is fixed
llvm-svn: 306942
2017-07-01 04:23:47 +00:00
Vitaly Buka d29d3da349 [asan] Fix test on Android i686/fugu
printf from .preinit_array may crash.

llvm-svn: 306940
2017-07-01 03:54:19 +00:00
Vitaly Buka c1c17833ff [asan] Disable test which fails on Android x86
Other Android CPUs probably pass just by luck as ulimit was not executed.

llvm-svn: 306914
2017-06-30 23:47:03 +00:00
Alex Shlyapnikov d3213c792e [LSan] Make LSan allocator allocator_may_return_null compliant
Summary:
An attempt to reland D34786 (which caused bot failres on Mac), now with
properly intercepted operators new() and delete().

LSan allocator used to always return nullptr on too big allocation requests
(the definition of "too big" depends on platform and bitness), now it
follows policy configured by allocator_may_return_null flag

Reviewers: eugenis

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D34845

llvm-svn: 306845
2017-06-30 17:21:34 +00:00
Kuba Mracek c41ba09433 [objc] Don't require null-check and don't emit memset when result is ignored for struct-returning method calls [compiler-rt part]
This fixes an issue with the emission of lifetime markers for struct-returning Obj-C msgSend calls. When the result of a struct-returning call is ignored, the temporary storage is only marked with lifetime markers in one of the two branches of the nil-receiver-check. The check is, however, not required when the result is unused. If we still need to emit the check (due to consumer arguments), let's not emit the memset to zero out the result if it's unused. This fixes a use-after-scope false positive with AddressSanitizer.

Differential Revision: https://reviews.llvm.org/D34834

llvm-svn: 306838
2017-06-30 16:29:43 +00:00
Kostya Kortchinsky b138ab810f [sanitizer] Small tweaks and fixes to allocator related functions
Summary:
In `sanitizer_allocator_primary32.h`:
- rounding up in `MapWithCallback` is not needed as `MmapOrDie` does it. Note
  that the 64-bit counterpart doesn't round up, this keeps the behavior
  consistent;
- since `IsAligned` exists, use it in `AllocateRegion`;
- in `PopulateFreeList`:
  - checking `b->Count` to be greater than 0 when `b->Count() == max_count` is
    redundant when done more than once. Just check that `max_count` is greater
    than 0 out of the loop; the compiler (at least on ARM) didn't optimize it;
  - mark the batch creation failure as `UNLIKELY`;

In `sanitizer_allocator_primary64.h`:
- in `MapWithCallback`, mark the failure condition as `UNLIKELY`;

In `sanitizer_posix.h`:
- mark a bunch of Mmap related failure conditions as `UNLIKELY`;
- in `MmapAlignedOrDieOnFatalError`, we have `IsAligned`, so use it; rearrange
  the conditions as one test was redudant;
- in `MmapFixedImpl`, 30 chars was not large enough to hold the message and a
  full 64-bit address (or at least a 48-bit usermode address), increase to 40.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: aemerson, kubamracek, kristof.beyls, llvm-commits

Differential Revision: https://reviews.llvm.org/D34840

llvm-svn: 306834
2017-06-30 16:05:40 +00:00
Hiroshi Inoue 32f2183483 fix trivial typos, NFC
llvm-svn: 306807
2017-06-30 08:28:50 +00:00
Alex Shlyapnikov 346988bf02 Merge
llvm-svn: 306748
2017-06-29 21:54:38 +00:00
Alex Shlyapnikov cb823f6a19 [Sanitizers] Rename CallocShouldReturnNullDueToOverflow to CheckForCallocOverflow
Summary:
Due to changes in semantics, CheckForCallocOverflow makes much more sense
now.

Reviewers: eugenis

Subscribers: llvm-commits, kubamracek

Differential Revision: https://reviews.llvm.org/D34799

llvm-svn: 306747
2017-06-29 21:54:37 +00:00
Alex Shlyapnikov 93c1a8c7c7 Merge
llvm-svn: 306746
2017-06-29 21:54:36 +00:00
Vedant Kumar ff3227e77d [profile] Move __llvm_profile_filename into a separate object
Users can specify the path a raw profile is written to by passing
-fprofile-instr-generate=<path>, but this functionality broke on Darwin
after __llvm_profile_filename was made weak [1], resulting in profiles
being written to "default.profraw" even when <path> is specified.

The situation is that instrumented programs provide a weak definition of
__llvm_profile_filename, which conflicts with a weak redefinition
provided by the profiling runtime.

The linker appears to pick the 'winning' definition arbitrarily: on
Darwin, it usually prefers the larger definition, which is probably why
the instrprof-override-filename.c test has been passing.

The fix is to move the runtime's definition into a separate object file
within the archive. This means that the linker won't "see" the runtime's
definition unless the user program has not provided one. I couldn't
think of a great way to test this other than to mimic the Darwin
failure: use -fprofile-instr-generate=<some-small-path>.

Testing: check-{clang,profile}, modified instrprof-override-filename.c.

[1] [Profile] deprecate __llvm_profile_override_default_filename
https://reviews.llvm.org/D22613
https://reviews.llvm.org/D22614

Differential Revision: https://reviews.llvm.org/D34797

llvm-svn: 306710
2017-06-29 17:42:24 +00:00
Reid Kleckner 4f98ab369d Export the nothrow overload of operator new
This missing export was causing allocator_returns_null.cc to fail on
Windows with a dynamic ASan runtime.

llvm-svn: 306707
2017-06-29 17:39:53 +00:00
Reid Kleckner 4acf36beb6 Fix WinASan after moving wcslen interceptor to sanitizer_common
Do this by removing SANITIZER_INTERCEPT_WCSLEN and intercept wcslen
everywhere. Before this change, we were already intercepting wcslen on
Windows, but the interceptor was in asan, not sanitizer_common. After
this change, we stopped intercepting wcslen on Windows, which broke
asan_dll_thunk.c, which attempts to thunk to __asan_wcslen in the ASan
runtime.

llvm-svn: 306706
2017-06-29 17:15:53 +00:00
Kostya Kortchinsky 0ce4999002 [scudo] Change aligned alloc functions to be more compliant & perf changes
Summary:
We were not following the `man` documented behaviors for invalid arguments to
`memalign` and associated functions. Using `CHECK` for those was a bit extreme,
so we relax the behavior to return null pointers as expected when this happens.
Adapt the associated test.

I am using this change also to change a few more minor performance improvements:
- mark as `UNLIKELY` a bunch of unlikely conditions;
- the current `CHECK` in `__sanitizer::RoundUpTo` is redundant for us in *all*
  calls. So I am introducing our own version without said `CHECK`.
- change our combined allocator `GetActuallyAllocatedSize`. We already know if
  the pointer is from the Primary or Secondary, so the `PointerIsMine` check is
  redundant as well, and costly for the 32-bit Primary. So we get the size by
  directly using the available Primary functions.

Finally, change a `int` to `uptr` to avoid a warning/error when compiling on
Android.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D34782

llvm-svn: 306698
2017-06-29 16:45:20 +00:00
Michael Zolotukhin 1576571112 Revert "[LSan] Make LSan allocator allocator_may_return_null compliant"
This reverts commit r306624.

The committed test failed on various bots (e.g. on green dragon).

llvm-svn: 306644
2017-06-29 04:39:17 +00:00
Vitaly Buka 1631129834 Revert "[asan] Control location of symbolizer on device using ANDROID_SYMBOLIZER_PATH"
Not needed, I am going to put symbolizer into tests dir.

This reverts commit r306627.

llvm-svn: 306630
2017-06-29 02:48:06 +00:00
Vitaly Buka 72c24da063 [asan] Control location of symbolizer on device using ANDROID_SYMBOLIZER_PATH
llvm-svn: 306627
2017-06-29 01:04:32 +00:00
Alex Shlyapnikov 17277f13f0 [LSan] Make LSan allocator allocator_may_return_null compliant
Summary:
LSan allocator used to always return nullptr on too big allocation requests
(the definition of "too big" depends on platform and bitness), now it
follows policy configured by allocator_may_return_null flag.

Reviewers: eugenis

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D34786

llvm-svn: 306624
2017-06-29 01:02:40 +00:00
Vitaly Buka 2af2fd5f76 [asan] Fix try to fix test on Android
%T is dir on host system, device does not have it

llvm-svn: 306621
2017-06-29 00:19:29 +00:00
Vitaly Buka 0c981cf69b [asan] Disable tests which do no work on Android
llvm-svn: 306620
2017-06-29 00:19:28 +00:00
Vitaly Buka 3681a55137 [asan] This test now passes
llvm-svn: 306619
2017-06-29 00:19:27 +00:00
Alex Shlyapnikov 4b450685d3 [Sanitizers] Operator new() interceptors always die on allocation error
Summary:
Operator new interceptors behavior is now controlled by their nothrow
property as well as by allocator_may_return_null flag value:

- allocator_may_return_null=* + new()        - die on allocation error
- allocator_may_return_null=0 + new(nothrow) - die on allocation error
- allocator_may_return_null=1 + new(nothrow) - return null

Ideally new() should throw std::bad_alloc exception, but that is not
trivial to achieve, hence TODO.

Reviewers: eugenis

Subscribers: kubamracek, llvm-commits

Differential Revision: https://reviews.llvm.org/D34731

llvm-svn: 306604
2017-06-28 21:58:57 +00:00
Xinliang David Li f50cc3ed8a [PGO] Reduce IO in profile dumping with merging
Differential Revision: http://reviews.llvm.org/D34709

llvm-svn: 306561
2017-06-28 16:46:06 +00:00
Kuba Mracek ce65982ea1 Revert r306504: Re-enable wait.cc, wait4.cc, waitid.cc tests on Darwin.
llvm-svn: 306551
2017-06-28 15:13:09 +00:00
Dean Michael Berris 66e08e7781 [XRay][compiler-rt][NFC] Move test case into correct directory.
Followup to D34669.

llvm-svn: 306506
2017-06-28 05:21:15 +00:00
Dean Michael Berris c3881436cf [XRay][compiler-rt] Only run test in x86_64 linux.
Followup to D34669.

llvm-svn: 306505
2017-06-28 05:19:59 +00:00
Kuba Mracek 70e8e9d8f6 Re-enable wait.cc, wait4.cc, waitid.cc tests on Darwin. They used to be flaky, something to do with LeakSanitizer now being enabled on Darwin. Let's re-enable them and see if they are still flaky or not.
llvm-svn: 306504
2017-06-28 05:03:28 +00:00
Dean Michael Berris 261d97332d [XRay][compiler-rt][NFC] Add example always/never instrument files.
Summary:
This change introduces two files that show exaples of the
always/never instrument files that can be provided to clang. We don't
add these as defaults yet in clang, which we can do later on (in a
separate change).

We also add a test that makes sure that these apply in the compiler-rt
project tests, and that changes in clang don't break the expectations in
compiler-rt.

Reviewers: pelikan, kpw

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D34669

llvm-svn: 306502
2017-06-28 04:44:36 +00:00
Evgeniy Stepanov 9e4519db1e [asan] Fix windows build.
llvm-svn: 306493
2017-06-28 00:37:29 +00:00
Evgeniy Stepanov 6f75e2dd48 [msan] Intercept wcscat, wcsncat.
Also move wcslen, wscnlen to common interceptors.

Reviewers: vitalybuka

Reviewed By: vitalybuka

Subscribers: kubamracek, llvm-commits

Differential Revision: https://reviews.llvm.org/D34656

llvm-svn: 306482
2017-06-27 22:52:38 +00:00
Xinliang David Li 1f0d0b2a4c [Profile] Remove redundant call
llvm-svn: 306480
2017-06-27 22:42:24 +00:00
Francis Ricci fa0e536521 Don't build tsan/dd when COMPILER_RT_HAS_TSAN is false
llvm-svn: 306463
2017-06-27 21:10:46 +00:00
Francis Ricci 23aae3b554 Don't double-include cfi tests on linux
llvm-svn: 306455
2017-06-27 19:52:35 +00:00
Francis Ricci d379d1c2ee Loop directly over sanitizers to build in cmake
Summary: Cleaner than computing the intersection for each possible sanitizer

Reviewers: compnerd, beanz

Subscribers: llvm-commits, mgorny

Differential Revision: https://reviews.llvm.org/D34693

llvm-svn: 306453
2017-06-27 19:32:39 +00:00
Francis Ricci 57a3f4584d Only test sanitizers that are built when COMPILER_RT_SANITIZERS_TO_BUILD is used
Summary: This allows check-all to be used when only a subset of the sanitizers are built.

Reviewers: beanz, compnerd, rnk, pcc

Subscribers: llvm-commits, mgorny

Differential Revision: https://reviews.llvm.org/D34644

llvm-svn: 306450
2017-06-27 19:18:01 +00:00
Xinliang David Li 967669f6c1 [PGO] Refactor file/buffer writer callback interfaces /NFC
Introduces a 'owner' struct to include the overridable write
method and the write context in C.

This allows easy introdution of new member API to help reduce
profile merge time in the follow up patch.

llvm-svn: 306432
2017-06-27 17:28:01 +00:00
Francis Ricci 07fa7942fd Revert "Only test sanitizers that are built when COMPILER_RT_SANITIZERS_TO_BUILD is used"
This breaks cfi testing in cases when the cfi runtime isn't built.

This reverts commit 1c6a7b07545f0c9ce68e8b226f5397694ce48af7.

llvm-svn: 306431
2017-06-27 17:24:26 +00:00
Francis Ricci 80296ee7f3 Only test sanitizers that are built when COMPILER_RT_SANITIZERS_TO_BUILD is used
Summary: This allows check-all to be used when only a subset of the sanitizers are built.

Reviewers: beanz, compnerd

Subscribers: llvm-commits, mgorny

Differential Revision: https://reviews.llvm.org/D34644

llvm-svn: 306415
2017-06-27 15:22:56 +00:00
Francis Ricci 2189fe1870 [tsan] Add missing include directory for test unittests
Summary: Required to fix standalone builds in some configurations

Reviewers: kubamracek, zaks.anna

Subscribers: mgorny, llvm-commits

Differential Revision: https://reviews.llvm.org/D34631

llvm-svn: 306411
2017-06-27 14:56:59 +00:00
Alex Shlyapnikov 01676883cd [Sanitizers] 64 bit allocator respects allocator_may_return_null flag
Summary:
Make SizeClassAllocator64 return nullptr when it encounters OOM, which
allows the entire sanitizer's allocator to follow
allocator_may_return_null=1 policy
(LargeMmapAllocator: D34243, SizeClassAllocator64: D34433).

Reviewers: eugenis

Subscribers: srhines, kubamracek, llvm-commits

Differential Revision: https://reviews.llvm.org/D34540

llvm-svn: 306342
2017-06-26 22:54:10 +00:00
Kuba Mracek 495371d6df [asan] Flag 'asan_gen_prefixes.cc' as unsupported on iOS. The ARM and ARM64 assemblers can use different label prefixes than the expected.
llvm-svn: 306335
2017-06-26 21:37:40 +00:00
Derek Bruening 92e4443c32 [esan] Disable flaky tests for PR33590
Disables 3 esan workingset tests until their underlying failures are
determined and resolved.

llvm-svn: 306259
2017-06-26 01:02:54 +00:00
Xinliang David Li 95ce779185 [PGO] Implementate profile counter regiser promotion (test case)
Differential Revision: http://reviews.llvm.org/D34085

llvm-svn: 306232
2017-06-25 00:27:09 +00:00
Vitaly Buka b768d5b863 [asan] Regression test for PR33372
Reviewers: eugenis

Subscribers: kubamracek, llvm-commits

Differential Revision: https://reviews.llvm.org/D34315

llvm-svn: 306195
2017-06-24 01:40:41 +00:00
Evgeniy Stepanov 90e5c30836 [asan] Add support for Android debug message.
Add ASan report to the "debug message" field in Android tombstones.

llvm-svn: 306184
2017-06-23 23:38:20 +00:00
Vedant Kumar d1c3780cf6 [ubsan] Improve diagnostics for return value checks (compiler-rt)
Differential Revision: https://reviews.llvm.org/D34298

llvm-svn: 306164
2017-06-23 21:32:48 +00:00
Alex Shlyapnikov f3cc7cc3d8 [Sanitizers] 32 bit allocator respects allocator_may_return_null flag
Summary:
Make SizeClassAllocator32 return nullptr when it encounters OOM, which
allows the entire sanitizer's allocator to follow allocator_may_return_null=1
policy, even for small allocations (LargeMmapAllocator is already fixed
by D34243).

Will add a test for OOM in primary allocator later, when
SizeClassAllocator64 can gracefully handle OOM too.

Reviewers: eugenis

Subscribers: kubamracek, llvm-commits

Differential Revision: https://reviews.llvm.org/D34433

llvm-svn: 305972
2017-06-22 00:02:37 +00:00
Justin Bogner dd862f9106 [sanitizer-coverage] Stop marking this test as unsupported on Darwin
The bug that was causing this to fail was fixed in r305429.

llvm-svn: 305942
2017-06-21 19:04:59 +00:00
Kostya Kortchinsky 2b053b1c28 [sanitizer] Add a function to gather random bytes
Summary:
AFAICT compiler-rt doesn't have a function that would return 'good' random
bytes to seed a PRNG. Currently, the `SizeClassAllocator64` uses addresses
returned by `mmap` to seed its PRNG, which is not ideal, and  
`SizeClassAllocator32` doesn't benefit from the entropy offered by its 64-bit
counterpart address space, so right now it has nothing. This function aims at
solving this, allowing to implement good 32-bit chunk randomization. Scudo also
has a function that does this for Cookie purposes, which would go away in a
later CL once this lands.

This function will try the `getrandom` syscall if available, and fallback to
`/dev/urandom` if not.

Unfortunately, I do not have a way to implement and test a Mac and Windows
version, so those are unimplemented as of now. Note that `kRandomShuffleChunks`
is only used on Linux for now.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: zturner, rnk, llvm-commits, kubamracek

Differential Revision: https://reviews.llvm.org/D34412

llvm-svn: 305922
2017-06-21 15:56:03 +00:00
Simon Dardis f62399945c [mips][compiler-rt] Fix build breakage.
Change some reinterpret_casts to c-style casts due to template instantiation
restrictions and build breakage due to missing paranthesises.

llvm-svn: 305899
2017-06-21 11:29:15 +00:00
Vitaly Buka ff7b8ea2a0 Revert "[compiler-rt] Don't reset non-default user handler if allow_user_segv_handler is true."
Summary:
On Android we still need to reset preinstalled handlers and allow use handlers later.

This reverts commit r304039.

Reviewers: eugenis

Subscribers: kubamracek, dberris, llvm-commits

Differential Revision: https://reviews.llvm.org/D34434

llvm-svn: 305871
2017-06-21 01:10:23 +00:00
Evgeniy Stepanov 827cd74618 [asan] Fix android compiler wrapper lost in r301617.
llvm-svn: 305870
2017-06-21 00:56:31 +00:00
Alex Shlyapnikov ccab11b0e8 [Sanitizers] Move cached allocator_may_return_null flag to sanitizer_allocator
Summary:
Move cached allocator_may_return_null flag to sanitizer_allocator.cc and
provide API to consolidate and unify the behavior of all specific allocators.

Make all sanitizers using CombinedAllocator to follow
AllocatorReturnNullOrDieOnOOM() rules to behave the same way when OOM
happens.

When OOM happens, turn allocator_out_of_memory flag on regardless of
allocator_may_return_null flag value (it used to not to be set when
allocator_may_return_null == true).

release_to_os_interval_ms and rss_limit_exceeded will likely be moved to
sanitizer_allocator.cc too (later).

Reviewers: eugenis

Subscribers: srhines, kubamracek, llvm-commits

Differential Revision: https://reviews.llvm.org/D34310

llvm-svn: 305858
2017-06-20 21:23:02 +00:00
Alex Shlyapnikov a26d10802b [ASan] Disable allocator_oom_test.cc on s390
Summary:
ASan shadow memory on s390 is larger than other configurations, let's
disable this test for now (will revisit it later).

Reviewers: eugenis

Subscribers: kubamracek, llvm-commits

Differential Revision: https://reviews.llvm.org/D34414

llvm-svn: 305822
2017-06-20 19:16:41 +00:00
Evgeniy Stepanov a2049b5210 [asan] Fix android setup script to overwrite the symlink.
This fixes asan_device_setup failing to update an existing asan
installation.

llvm-svn: 305746
2017-06-19 21:42:44 +00:00
Francis Ricci 42175cb0d7 Add lsan interceptors for libdispatch functions on darwin
Summary:
This is required for standalone LSan to work with libdispatch worker threads,
and is a slimmed down version of the functionality provided for ASan
in asan_mac.cc.

Re-commit of r305695 with use_stacks=0 to get around a racy lingering pointer.

Reviewers: alekseyshl, kubamracek, glider, kcc

Subscribers: mgorny, llvm-commits

Differential Revision: https://reviews.llvm.org/D34247

llvm-svn: 305732
2017-06-19 19:21:31 +00:00
Francis Ricci 214b354f2e Revert "Add lsan interceptors for libdispatch functions on darwin"
This reverts r305695

llvm-svn: 305712
2017-06-19 17:08:55 +00:00
Francis Ricci 4f1e047a6d Add lsan interceptors for libdispatch functions on darwin
Summary:
This is required for standalone LSan to work with libdispatch worker threads,
and is a slimmed down version of the functionality provided for ASan
in asan_mac.cc.

Reviewers: alekseyshl, kubamracek, glider, kcc

Subscribers: mgorny, llvm-commits

Differential Revision: https://reviews.llvm.org/D34247

llvm-svn: 305695
2017-06-19 14:09:10 +00:00
Sagar Thakur 6478d14a0d [scudo] Enabling MIPS support for Scudo
Adding MIPS 32-bit and 64-bit support for Scudo.

Reviewed by cryptoad, sdardis.
Differential: D31803

llvm-svn: 305682
2017-06-19 11:28:59 +00:00
Dean Michael Berris 8d6f9c24d3 [XRay][compiler-rt][NFC] Add a test for both arg1 and arg0 handling in the same binary
This test makes sure we can handle both arg0 and arg1 handling in the
same binary, and making sure that the XRay runtime calls the correct
trampoline when handlers for both of these cases are installed.

llvm-svn: 305660
2017-06-19 03:52:25 +00:00
Dean Michael Berris 043d3f8682 [XRay][compiler-rt][NFC] Add a name for argument to __xray_set_handler_arg1(...)
Just makes the interface consistent with the other functions in
include/xray/xray_interface.h.

llvm-svn: 305658
2017-06-19 01:30:04 +00:00
Pirama Arumuga Nainar 31b825d834 Call cmake_minimum_required at the top of CMakeLists.txt
Summary:
Since r298413, the NEW behavior of the CMake policy CMP0056 is followed.
However, it is only effective after the call to cmake_minimum_required.
This causes CMAKE_EXE_LINKER_FLAGS etc. to be unused when CMake tries to
check compilers for languages specified in the 'project' declaration.

Set cmake_minimum_required(VERSION) at the top of the file and ahead of
the project declaration.

Reviewers: beanz

Subscribers: mgorny, srhines, llvm-commits

Differential Revision: https://reviews.llvm.org/D34282

llvm-svn: 305593
2017-06-16 21:14:45 +00:00
Alex Shlyapnikov 5a308f24c3 [Sanitizer] Remove CombinedAllocator::Allocate's 'cleared' parameter
Summary:
CombinedAllocator::Allocate cleared parameter is not used anywhere and
seem to be obsolete.

Reviewers: eugenis

Subscribers: llvm-commits, kubamracek

Differential Revision: https://reviews.llvm.org/D34289

llvm-svn: 305590
2017-06-16 21:00:03 +00:00
Reid Kleckner f1b9f3a23f [WinASan] Fix hotpatching new Win 10 build 1703 x64 strnlen prologue
The first instruction of the new ucrtbase!strnlen implementation loads a
global, presumably to dispatch between SSE and non-SSE optimized strnlen
implementations.

Fixes PR32895 and probably
https://github.com/google/sanitizers/issues/818

llvm-svn: 305581
2017-06-16 20:44:00 +00:00
Alex Shlyapnikov d340605a37 [Sanitizers] Fix allocator OOM test on Windows.
Summary:
Point of failure is different after D34243, hence the change of the
message.

Reviewers: eugenis

Subscribers: llvm-commits, kubamracek

Differential Revision: https://reviews.llvm.org/D34292

llvm-svn: 305580
2017-06-16 20:36:39 +00:00
Alex Shlyapnikov 9092fe6f4b [Sanitizers] Secondary allocator respects allocator_may_return_null=1.
Summary:
Context: https://github.com/google/sanitizers/issues/740.

Making secondary allocator to respect allocator_may_return_null=1 flag
and return nullptr when "out of memory" happens.

More changes in primary allocator and operator new will follow.

Reviewers: eugenis

Subscribers: kubamracek, llvm-commits

Differential Revision: https://reviews.llvm.org/D34243

llvm-svn: 305569
2017-06-16 18:48:08 +00:00
Dean Michael Berris 10bbc4f99e Add test for logging the implicit "this" argument for C++ member functions.
Summary:
This allows us to do more interesting things with the data available to
C++ methods, to log the `this` pointer.

Depends on D34050.

Reviewers: pelikan

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D34051

llvm-svn: 305545
2017-06-16 03:24:07 +00:00
Evgeniy Stepanov 2aed0fb07e [cfi] Enable icall tests with thinlto.
llvm-svn: 305534
2017-06-16 00:18:35 +00:00
Vedant Kumar f7e804157e [ubsan] Fix a faulty memory accessibility check
The dynamic type check needs to inspect vtables, but could crash if it
encounters a vtable pointer to inaccessible memory. In the first attempt
to fix the issue (r304437), we performed a memory accessibility check on
the wrong range of memory. This should *really* fix the problem.

Patch by Max Moroz!

Differential Revision: https://reviews.llvm.org/D34215

llvm-svn: 305489
2017-06-15 18:23:16 +00:00
Vitaly Buka 4a2cc96f1f [asan] Fix typo in doc string.
llvm-svn: 305436
2017-06-15 00:31:59 +00:00
Vitaly Buka 7901b47094 [asan] Return allow_user_segv_handler=0 to fix compatibility issues.
Summary:
After r303941 it was not possible to setup ASAN_OPTIONS to have the same
behavior for pre r303941 and post r303941 builds.
Pre r303941 Asan does not accept handle_sigbus=2.
Post r303941 Asan does not accept allow_user_segv_handler.

This fix ignores allow_user_segv_handler=1, but for allow_user_segv_handler=0
it will upgrade flags like handle_sigbus=1 to handle_sigbus=2. So user can set
ASAN_OPTIONS=allow_user_segv_handler=0 and have same behavior on old and new
clang builds (except range from r303941 to this revision).

In future users which need to prevent third party handlers should switch to
handle_sigbus=2 and remove allow_user_segv_handler as soon as suport of older
builds is not needed.

Related bugs:
  https://github.com/google/oss-fuzz/issues/675
  https://bugs.chromium.org/p/chromium/issues/detail?id=731130

Reviewers: eugenis

Subscribers: llvm-commits, kubamracek

Differential Revision: https://reviews.llvm.org/D34227

llvm-svn: 305433
2017-06-15 00:19:13 +00:00
Kostya Kortchinsky 77f30c9c31 [sanitizer] Reverting D34152
Summary:
This broke thread_local_quarantine_pthread_join.cc on some architectures, due
to the overhead of the stashed regions. Reverting while figuring out the best
way to deal with it.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: llvm-commits, kubamracek

Differential Revision: https://reviews.llvm.org/D34213

llvm-svn: 305404
2017-06-14 17:32:26 +00:00
Kostya Kortchinsky eca926ab3a [sanitizer] MmapAlignedOrDie changes to reduce fragmentation
Summary:
The reasoning behind this change is explained in D33454, which unfortunately
broke the Windows version (due to the platform not supporting partial unmapping
of a memory region).

This new approach changes `MmapAlignedOrDie` to allow for the specification of
a `padding_chunk`. If non-null, and the initial allocation is aligned, this
padding chunk will hold the address of the extra memory (of `alignment` bytes).
This allows `AllocateRegion` to get 2 regions if the memory is aligned
properly, and thus help reduce fragmentation (and saves on unmapping
operations). As with the initial D33454, we use a stash in the 32-bit Primary
to hold those extra regions and return them on the fast-path.

The Windows version of `MmapAlignedOrDie` will always return a 0
`padding_chunk` if one was requested.

Reviewers: alekseyshl, dvyukov, kcc

Reviewed By: alekseyshl

Subscribers: llvm-commits, kubamracek

Differential Revision: https://reviews.llvm.org/D34152

llvm-svn: 305391
2017-06-14 15:32:17 +00:00
Alex Shlyapnikov 8531fa3028 [ASan] Move rss_limit_is_exceeded_ flag to ASan.
Summary:
Move the OOM decision based on RSS limits out of generic allocator to
ASan allocator, where it makes more sense at the moment.

Reviewers: eugenis

Subscribers: kubamracek, llvm-commits

Differential Revision: https://reviews.llvm.org/D34180

llvm-svn: 305342
2017-06-13 23:57:24 +00:00
Evgeniy Stepanov cde90a66b5 [sanitize] Remove stack size limits from secondary threads.
If pthread_attr_getstack tell us the stack is 2G, why would we doubt that?

Differential Revision: https://reviews.llvm.org/D34169

llvm-svn: 305330
2017-06-13 22:29:15 +00:00
Dmitry Vyukov dc2a38cdf2 tsan: fix reading of mutex flags
SyncVar::IsFlagSet returns true if any flag is set.
This is wrong. Check the actual requested flag.

llvm-svn: 305281
2017-06-13 09:37:51 +00:00
Dmitry Vyukov f5b3b84826 tsan: fix pedantic warnings
ISO C++ does not allow ?: with omitted middle operand

llvm-svn: 305273
2017-06-13 07:09:56 +00:00
Vedant Kumar 8c31c2a546 [ubsan] Detect invalid unsigned pointer index expression (compiler-rt)
Compiler-rt part of: https://reviews.llvm.org/D33910

Differential Revision: https://reviews.llvm.org/D33911

llvm-svn: 305217
2017-06-12 18:42:51 +00:00
Vedant Kumar c7672d66ba Mark a sancov test as unsupported on x86_64h-darwin
Failing bot: http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-expensive/6891

llvm-svn: 305133
2017-06-10 00:12:11 +00:00
Xinliang David Li 384f704834 Minor clean up of profile rt tests
llvm-svn: 305113
2017-06-09 21:14:19 +00:00
Maxim Ostapenko d8c47ca836 [asan] Fix ASan internal failure in AllocateFromLocalPool
This patch addresses PR 33206. There might be a situation when dynamic ASan runtime initializes later
than shared library which has malloc in static constructor (rtld doesn't provide an order of shared libs initialization).
In this case ASan hasn't yet initialized interceptors, but already intercepts malloc.
If malloc is too big to be handled by static local pool, ASan will die with error: 
Sanitizer CHECK failed: lib/asan/asan_malloc_linux.cc:40 ((allocated_for_dlsym)) < ((kDlsymAllocPoolSize)) (1036, 1024)

Patch by Denis Khalikov.

Differential Revision: https://reviews.llvm.org/D33784

llvm-svn: 305058
2017-06-09 07:47:38 +00:00
Kostya Serebryany 2c2fb8896b [sanitizer-coverage] one more flavor of coverage: -fsanitize-coverage=inline-8bit-counters. Experimental so far, not documenting yet. Reapplying revisions 304630, 304631, 304632, 304673, see PR33308
llvm-svn: 305026
2017-06-08 22:58:19 +00:00
Vedant Kumar cecb1121bb Mark the tsan strerror_r test as unsupported on Darwin
llvm-svn: 304944
2017-06-07 21:10:35 +00:00
Vedant Kumar 3e95c498aa Revert "Fix tsan test for Darwin. NFCI."
This reverts commit r304941. Vitaly Buka writes:
"Actually it depends on return value.
Test is for char* version of function. It will probably fail for int
version."

llvm-svn: 304943
2017-06-07 21:10:33 +00:00
Vedant Kumar a302ae096e Fix tsan test for Darwin. NFCI.
On Darwin, strerror_r returns an int, not a char*. I don't think this
test really depends on what strerror_r returns, so I've used something
else in place of the result of the call to strerror_r.

llvm-svn: 304941
2017-06-07 20:43:15 +00:00
Evgeniy Stepanov 7922ac23f1 [sanitizer] Fix symbolizer build after r304864.
r304864 moved code into a new BinaryFormat library. Update the
symbolizer build script.

llvm-svn: 304930
2017-06-07 17:24:58 +00:00
Vitaly Buka d9bc851fb3 [tsan]: Fix GNU version of strerror_r interceptor
GNU version of strerror_r returns a result pointer that doesn't match the input
buffer. The result pointer is in fact a pointer to some internal storage.
TSAN was recording a write to this location, which was incorrect.

Fixed https://github.com/google/sanitizers/issues/696

llvm-svn: 304858
2017-06-07 01:53:38 +00:00
Alex Shlyapnikov effb794346 [ASan] A speculative attempt to fix a flaky test on ppc64be.
Summary:
As mentioned in test/msan/fork.cc, if test output is redirected to a file
(as opposed to being piped directly to FileCheck), we may lose some "done"s due to
a kernel bug: https://lkml.org/lkml/2014/2/17/324, so let's pipe the
output of the test.

Reviewers: eugenis

Subscribers: llvm-commits, kubamracek

Differential Revision: https://reviews.llvm.org/D33915

llvm-svn: 304744
2017-06-05 22:23:15 +00:00