Commit Graph

9555 Commits

Author SHA1 Message Date
Martin Pelikan f5f4c009fe [XRay] [compiler-rt] fix build by including errno.h into FDR mode
The build got broken after D39277 (and rL316816) deleted <cerrno>.

llvm-svn: 316821
2017-10-28 01:35:07 +00:00
Dean Michael Berris e8fec1955a [XRay][compiler-rt] Remove more STL dependenices from FDR mode
Summary:
This change removes dependencies on STL types:

  - std::aligned_storage -- we're using manually-aligned character
    buffers instead for metadata and function records.

  - std::tuple -- use a plain old struct instead.

This is an incremental step in removing all STL references from the
compiler-rt implementation of XRay (llvm.org/PR32274).

Reviewers: dblaikie, pelikan, kpw

Subscribers: llvm-commits

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

llvm-svn: 316816
2017-10-27 23:59:41 +00:00
Kostya Kortchinsky 91b7558ca8 [scudo] Allow to specify the maximum number of TSDs at compile time
Summary:
This introduces `SCUDO_MAX_CACHES` allowing to define an upper bound to the
number of `ScudoTSD` created in the Shared TSD model (by default 32U).
This name felt clearer than `SCUDO_MAX_TSDS` which is technically what it really
is. I am opened to suggestions if that doesn't feel right.

Additionally change `getNumberOfCPUs` to return a `u32` to be more consistent.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: llvm-commits

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

llvm-svn: 316788
2017-10-27 20:10:14 +00:00
Alex Shlyapnikov f280eff080 [LSan] Disable a couple of failing tests on PPC64 (pending investigation).
llvm-svn: 316720
2017-10-27 00:29:40 +00:00
Alex Shlyapnikov e4b9ae666e [LSan] Enable LSan tests on PPC64 Linux.
Summary:
LSan is functional on PPC64 Linux now, let's enable all tests.

One test required ppc specific changes: use_registers.cc.

Reviewers: eugenis

Subscribers: mgorny, llvm-commits

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

llvm-svn: 316698
2017-10-26 20:59:04 +00:00
Alex Shlyapnikov 9b4e32785a [Sanitizers] Set default allocator_release_to_os_interval_ms to 5 seconds
Summary:
With new release to OS approach (see D38245) it's reasonable to enable
it by default. Setting allocator_release_to_os_interval_ms to 5000 seems
to be a reasonable default (might be tuned later, based on the
feedback).

Also delaying the first release to OS in each bucket for at least
allocator_release_to_os_interval_ms after the first allocation to
prevent just allocated memory to be madvised back to OS and let short
lived processes to avoid release to OS overhead altogether.

Reviewers: cryptoad

Subscribers: kubamracek, llvm-commits, mehdi_amini

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

llvm-svn: 316683
2017-10-26 17:59:24 +00:00
Vitaly Buka f3e0f76196 [sanitizer] Fix internal symbolized build on Debian 9
llvm-svn: 316637
2017-10-26 06:08:01 +00:00
Alex Shlyapnikov 02bda37492 [LSan] Adjust LSan allocator limits for PPC64.
Summary: Now the limits are the same as for ASan allocator.

Reviewers: cryptoad

Subscribers: llvm-commits

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

llvm-svn: 316633
2017-10-26 01:22:48 +00:00
Kostya Serebryany 3c9e59d0f6 [libFuzzer] trying to make a test more stable on Mac
llvm-svn: 316627
2017-10-25 23:24:45 +00:00
Kostya Kortchinsky f9008a3a06 [scudo] Remove comment about security of the 32-bit allocator
Summary:
The 32-bit allocator is now on par with the 64-bit in terms of security (chunks
randomization is done, batches separation is done).

Unless objection, the comment can go away.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: llvm-commits

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

llvm-svn: 316620
2017-10-25 22:00:26 +00:00
Evgeniy Stepanov 0b8602791b [msan] Intercept __strxfrm_l.
llvm-svn: 316613
2017-10-25 21:40:17 +00:00
Kamil Rytarowski 175e775e0f Try to unbreak Linux sanitizers
Add fallback definition of internal_syscall_ptr and internal_syscall64
for Linux/x86_64 and Linux/aarch64.

llvm-svn: 316598
2017-10-25 17:56:36 +00:00
Kostya Kortchinsky c484912b06 [sanitizer] Random shuffling of chunks for the 32-bit Primary Allocator
Summary:
The 64-bit primary has had random shuffling of chunks for a while, this
implements it for the 32-bit primary. Scudo is currently the only user of
`kRandomShuffleChunks`.

This change consists of a few modifications:
- move the random shuffling functions out of the 64-bit primary to
  `sanitizer_common.h`. Alternatively I could move them to
  `sanitizer_allocator.h` as they are only used in the allocator, I don't feel
  strongly either way;
- small change in the 64-bit primary to make the `rand_state` initialization
  `UNLIKELY`;
- addition of a `rand_state` in the 32-bit primary's `SizeClassInfo` and
  shuffling of chunks when populating the free list.
- enabling the `random_shuffle.cpp` test on platforms using the 32-bit primary
  for Scudo.

Some comments on why the shuffling is done that way. Initially I just
implemented a `Shuffle` function in the `TransferBatch` which was simpler but I
came to realize this wasn't good enough: for chunks of 10000 bytes for example,
with a `CompactSizeClassMap`, a batch holds only 1 chunk, meaning shuffling the
batch has no effect, while a region is usually 1MB, eg: 104 chunks of that size.
So I decided to "stage" the newly gathered chunks in a temporary array that
would be shuffled prior to placing the chunks in batches.
The result is looping twice through n_chunks even if shuffling is not enabled,
but I didn't notice any significant significant performance impact.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: srhines, llvm-commits, kubamracek

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

llvm-svn: 316596
2017-10-25 17:24:56 +00:00
Alex Shlyapnikov a53b55f66c [Sanitizers] ASan: detect new/delete calls with mismatched alignment.
ASan allocator stores the requested alignment for new and new[] calls
and on delete and delete[] verifies that alignments do match.

The representable alignments are: default alignment, 8, 16, 32, 64, 128,
256 and 512 bytes. Alignments > 512 are stored as 512, hence two
different alignments > 512 will pass the check (possibly masking the bug),
but limited memory requirements deemed to be a resonable tradeoff for
relaxed conditions.

The feature is controlled by new_delete_type_mismatch flag, the same one
protecting new/delete matching size check.

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

Issue: https://github.com/google/sanitizers/issues/799
llvm-svn: 316595
2017-10-25 17:21:37 +00:00
Kamil Rytarowski 9c1eeaca80 Add NetBSD improvements in sanitizers
Summary:
Changes:

 * Add initial msan stub support.
 * Handle NetBSD specific pthread_setname_np(3).
 * NetBSD supports __attribute__((tls_model("initial-exec"))),
   define it in SANITIZER_TLS_INITIAL_EXEC_ATTRIBUTE.
 * Add ReExec() specific bits for NetBSD.
 * Simplify code and add syscall64 and syscall_ptr for !NetBSD.
 * Correct bunch of syscall wrappers for NetBSD.
 * Disable test/tsan/map32bit on NetBSD as not applicable.
 * Port test/tsan/strerror_r to a POSIX-compliant OSes.
 * Disable __libc_stack_end on NetBSD.
 * Disable ReadNullSepFileToArray() on NetBSD.
 * Define struct_ElfW_Phdr_sz, detected missing symbol by msan.
 * Change type of __sanitizer_FILE from void to char. This helps
   to reuse this type as an array. Long term it will be properly
   implemented along with SANITIZER_HAS_STRUCT_FILE setting to 1.
 * Add initial NetBSD support in lib/tsan/go/buildgo.sh.
 * Correct referencing stdout and stderr in tsan_interceptors.cc
   on NetBSD.
 * Document NetBSD x86_64 specific virtual memory layout in
   tsan_platform.h.
 * Port tests/rtl/tsan_test_util_posix.cc to NetBSD.
 * Enable NetBSD tests in test/msan/lit.cfg.
 * Enable NetBSD tests in test/tsan/lit.cfg.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, vitalybuka, eugenis, kcc, dvyukov

Reviewed By: dvyukov

Subscribers: #sanitizers, llvm-commits, kubamracek

Tags: #sanitizers

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

llvm-svn: 316591
2017-10-25 17:09:05 +00:00
Reid Kleckner 03d02a0e1d [asan] Don't print rows of shadow bytes outside shadow memory
Summary:
They might not be mapped on some platforms such as Win64.  In
particular, this happens if the user address is null. There will not be
any shadow memory 5*16 bytes before the user address. This happens on
Win64 in the error_report_callback.cc test case. It's not clear why this
isn't a problem on Linux as well.

Fixes PR35058

Reviewers: vitalybuka

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 316589
2017-10-25 16:54:12 +00:00
Dmitry Vyukov 60d8ad2849 [tsan] Fix warnings in tsan_interceptors.cc from expansion of variadic macros
C99 technically requires the rest arguments to be used in C variadic macros.
This presents a problem with the macro SCOPED_TSAN_INTERCEPTOR when func
takes no arguments. This happens with the function pause. Like other void
argument functions, we pass in a fake argument to avoid this warning.

Author: Alex Langford (xiaobai)
Reviewed in: https://reviews.llvm.org/D39151

llvm-svn: 316558
2017-10-25 08:05:13 +00:00
Dean Michael Berris 389ebc0c4f [XRay][compiler-rt][NFC] Clean up xray log files before running test
Improves the test behaviour in the face of failure. Without this change
the fdr-single-thread.cc test may leave around artefacts of a previous
failing run since the cleanup doesn't happen if any of the intermediary
steps fail.

Non-functional change.

Subscribers: llvm-commits
llvm-svn: 316548
2017-10-25 05:19:20 +00:00
Dimitry Andric 95af9e654f On FreeBSD, skip the first entry in the dl_iterate_phdr list.
Summary:
Similar to NetBSD, in FreeBSD, the first returned entry when callbacks
are done via dl_iterate_phdr will return the main program.  Ignore that
entry when checking that the dynamic ASan lib is loaded first.

Reviewers: eugenis, krytarowski, emaste, joerg

Reviewed By: eugenis, krytarowski

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 316487
2017-10-24 19:45:59 +00:00
Reid Kleckner 80db37ec25 [asan] Add more x86 prologue decodings to handle x64 VC 2017 CRT
Fixes atoi and strtol interception.

llvm-svn: 316482
2017-10-24 18:22:07 +00:00
Dean Michael Berris 23e54d85be [XRay][compiler-rt] More fixups.
Follow-up to D39175.

llvm-svn: 316410
2017-10-24 02:43:49 +00:00
Dean Michael Berris 2e592ea7ed [XRay][compiler-rt] Fixup shadowing
Follow-up to D39175.

llvm-svn: 316409
2017-10-24 02:36:32 +00:00
Dean Michael Berris 0b1cce2036 [XRay][compiler-rt] Remove C++ STL from the buffer queue implementation
Summary:
This change removes the dependency on C++ standard library
types/functions in the implementation of the buffer queue. This is an
incremental step in resolving llvm.org/PR32274.

Reviewers: dblaikie, pelikan

Subscribers: llvm-commits

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

llvm-svn: 316406
2017-10-24 01:39:59 +00:00
Alex Shlyapnikov 5ded0701a9 [Sanitizers-libFuzzer] Addressing coding style issues.
Summary: The result of clang-format and few manual changes (as prompted on D39155).

Reviewers: vitalybuka

Subscribers: llvm-commits

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

llvm-svn: 316395
2017-10-23 23:24:33 +00:00
Alex Shlyapnikov 6f1c26f222 [libFuzzer] Periodically purge allocator's quarantine to prolong fuzzing sessions.
Summary:
Fuzzing targets that allocate/deallocate a lot of memory tend to consume
a lot of RSS when ASan quarantine is enabled. Purging quarantine between
iterations and returning memory to OS keeps RSS down and should not
reduce the quarantine effectiveness provided the fuzz target does not
preserve state between iterations (in this case this feature can be turned off).

Based on D39153.

Reviewers: vitalybuka

Subscribers: llvm-commits

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

llvm-svn: 316382
2017-10-23 22:04:30 +00:00
Alex Shlyapnikov 1108d072f4 [Sanitizers] Add total primary allocator RSS to allocator report.
Summary: .

Reviewers: cryptoad

Subscribers: llvm-commits, kubamracek

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

llvm-svn: 316356
2017-10-23 17:58:16 +00:00
Evgeniy Stepanov aedda3bafc Revert "[Compiler-rt][MIPS] Fix cross build for XRAY."
Breaks build:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/4677/steps/build%20with%20ninja/logs/stdio

In file included from compiler-rt/lib/xray/xray_fdr_logging.cc:34:
In file included from compiler-rt/lib/xray/xray_fdr_logging_impl.h:36:
In file included from compiler-rt/lib/xray/xray_flags.h:18:
compiler-rt/lib/xray/../sanitizer_common/sanitizer_flag_parser.h:23:7: error: '__sanitizer::FlagHandlerBase' has virtual functions but non-virtual destructor [-Werror,-Wnon-virtual-dtor]
class FlagHandlerBase {

llvm-svn: 316348
2017-10-23 17:13:24 +00:00
Alex Shlyapnikov 028c4cddad [Sanitizers] New sanitizer API to purge allocator quarantine.
Summary:
Purging allocator quarantine and returning memory to OS might be desired
between fuzzer iterations since, most likely, the quarantine is not
going to catch bugs in the code under fuzz, but reducing RSS might
significantly prolong the fuzzing session.

Reviewers: cryptoad

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 316347
2017-10-23 17:12:07 +00:00
Kostya Kortchinsky 9e917a13fb [scudo] Add a shared runtime
Summary:
Up to now, the Scudo cmake target only provided a static library that had to be
linked to an executable to benefit from the hardened allocator.
This introduces a shared library as well, that can be LD_PRELOAD'ed.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: srhines, mgorny, llvm-commits

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

llvm-svn: 316342
2017-10-23 16:27:47 +00:00
Nitesh Jain cf8a5c26f9 [Compiler-rt][MIPS] Fix cross build for XRAY.
Reviewers: dberris, sdardis

Subscribers: jaydeep, bhushan, llvm-commits

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

llvm-svn: 316286
2017-10-22 09:37:50 +00:00
Dmitry Vyukov 3d34d877cb tsan: add tests missed in r316209
llvm-svn: 316210
2017-10-20 12:10:21 +00:00
Dmitry Vyukov 9e2cd1c125 [tsan] Add Mutex annotation flag for constant-initialized __tsan_mutex_linker_init behavior
Add a new flag, _⁠_tsan_mutex_not_static, which has the opposite sense
of _⁠_tsan_mutex_linker_init. When the new _⁠_tsan_mutex_not_static flag
is passed to _⁠_tsan_mutex_destroy, tsan ignores the destruction unless
the mutex was also created with the _⁠_tsan_mutex_not_static flag.

This is useful for constructors that otherwise woud set
_⁠_tsan_mutex_linker_init but cannot, because they are declared constexpr.

Google has a custom mutex with two constructors, a "linker initialized"
constructor that relies on zero-initialization and sets
⁠_⁠_tsan_mutex_linker_init, and a normal one which sets no tsan flags.
The "linker initialized" constructor is morally constexpr, but we can't
declare it constexpr because of the need to call into tsan as a side effect.

With this new flag, the normal c'tor can set _⁠_tsan_mutex_not_static,
the "linker initialized" constructor can rely on tsan's lazy initialization,
and _⁠_tsan_mutex_destroy can still handle both cases correctly.

Author: Greg Falcon (gfalcon)
Reviewed in: https://reviews.llvm.org/D39095

llvm-svn: 316209
2017-10-20 12:08:53 +00:00
Marco Castelluccio 17103fc12f Use O_BINARY when opening GCDA file on Windows
Summary:
Fixes https://bugs.llvm.org/show_bug.cgi?id=34922.

Apparently, the mode in **fdopen** gets simply ignored and Windows only cares about the mode of the original **open**.

I have verified this both with the simple case from bug 34922 and with a full Firefox build.

Reviewers: zturner

Reviewed By: zturner

Subscribers: llvm-commits

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

llvm-svn: 316048
2017-10-18 00:22:01 +00:00
Evgeniy Stepanov db8d53cdad Revert "[asan] Deflake one test by running it 3 times."
Disable this test on Android/x86 only.

llvm-svn: 316023
2017-10-17 19:57:48 +00:00
Dean Michael Berris 1d2f9e2bdd [XRay][compiler-rt] Always place the CPU record first for every buffer
Summary:
In FDR Mode, when we set up a new buffer for a thread that's just
overflowed, we must place the CPU identifier with the TSC record as the
first record. This is so that we can reconstruct all the function
entry/exit with deltas rooted on a TSC record for the CPU at the
beginning of the buffer.

Without doing this, the tools are rejecting the log for cases when we've
overflown and have different buffers that don't have the CPU and TSC
records as the first entry in the buffers.

Reviewers: pelikan

Subscribers: llvm-commits

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

llvm-svn: 315987
2017-10-17 10:33:24 +00:00
Evgeniy Stepanov 1993de54ee [cfi] Test cross-dso CFI on Android.
Reviewers: vitalybuka, pcc

Subscribers: llvm-commits, srhines

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

llvm-svn: 315922
2017-10-16 18:03:11 +00:00
Kostya Kortchinsky 73a80c5493 [scudo] Do not include sanitizer_posix.h if not on a Posix platform
Summary:
Move the `sanitizer_posix.h` include within the `SANITIZER_ANDROID` `#if`,
otherwise this errors when built on non-Posix platforms (eg: Fuchsia).

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: llvm-commits

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

llvm-svn: 315917
2017-10-16 17:06:13 +00:00
Vitaly Buka ac03fb616f [asan] Increase kHandlerStackSize for TracerThreadSignalHandler
4096 is not enough on some platform, e.g. Debian 4.9.0-3-amd64

llvm-svn: 315844
2017-10-15 04:18:29 +00:00
George Karpenkov 1b11460610 [xray] Fix CMake for X-RAY tests
Correctly depend on llvm-xray, make sure unit tests are being run.

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

llvm-svn: 315827
2017-10-14 21:38:13 +00:00
Kostya Serebryany fc3079963f [libFuzzer] print a better warning if we hit the ld bug
llvm-svn: 315778
2017-10-14 00:07:11 +00:00
Evgeniy Stepanov 4fb209ede2 [asan] Deflake one test by running it 3 times.
The test seems to trigger an android platform bug under load.

llvm-svn: 315777
2017-10-13 23:57:08 +00:00
Evgeniy Stepanov f156c932ae [cfi] Use %ld_flags_rpath_* substitutions in tests (NFC)
llvm-svn: 315775
2017-10-13 23:33:12 +00:00
Alex Shlyapnikov 29d3ba7576 [Sanitizers] Always build libFuzzer with frame pointers.
Lacking frame pointers, sanitized fuzzers collect bogus stack
traces and the set of stack traces grows indefinitely, leading to OOMs.

llvm-svn: 315770
2017-10-13 21:57:43 +00:00
Peter Collingbourne 868783e855 LowerTypeTests: Give imported symbols a type with size 0 so that they are not assumed not to alias.
It is possible for both a base and a derived class to be satisfied
with a unique vtable. If a program contains casts of the same pointer
to both of those types, the CFI checks will be lowered to this
(with ThinLTO):

if (p != &__typeid_base_global_addr)
  trap();
if (p != &__typeid_derived_global_addr)
  trap();

The optimizer may then use the first condition combined
with the assumption that __typeid_base_global_addr and
__typeid_derived_global_addr may not alias to optimize away the second
comparison, resulting in an unconditional trap.

This patch fixes the bug by giving imported globals the type [0 x i8]*,
which prevents the optimizer from assuming that they do not alias.

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

llvm-svn: 315753
2017-10-13 21:02:16 +00:00
Kostya Kortchinsky f4c11e353a [scudo] Allow for non-Android Shared TSD platforms, part 2
Summary:
Follow up to D38826.

We introduce `pthread_{get,set}specific` versions of `{get,set}CurrentTSD` to
allow for non Android platforms to use the Shared TSD model.
We now allow `SCUDO_TSD_EXCLUSIVE` to be defined at compile time.

A couple of things:
- I know that `#if SANITIZER_ANDROID` is not ideal within a function, but in
  the end I feel it looks more compact and clean than going the .inc route; I
  am open to an alternative if anyone has one;
- `SCUDO_TSD_EXCLUSIVE=1` requires ELF TLS support (and not emutls as this uses
  malloc). I haven't found anything to enforce that, so it's currently not
  checked.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: srhines, llvm-commits

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

llvm-svn: 315751
2017-10-13 20:55:31 +00:00
Alex Shlyapnikov 8a8d945df7 [Sanitizers] Add more details to ASan allocator stats report.
Summary: .

Reviewers: cryptoad

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 315730
2017-10-13 18:38:10 +00:00
Kostya Serebryany 51823d3aae [libFuzzer] tweam use_feature_frequency to be less aggressive; run a dummy input before the seed corpus
llvm-svn: 315657
2017-10-13 01:12:23 +00:00
Evgeniy Stepanov 150b7d6f55 [sanitizer] Workaround a Linux kernel bug in hard_rss_limit_mb_test.
llvm-svn: 315632
2017-10-12 22:24:58 +00:00
Michal Gorny 4e9e939b4f [cmake] [asan] Remove unnecessary gtest dep from dynamic tests
Remove the redundant dependency on 'gtest' target from the dynamic tests
in non-MSVC environment. The tests reuse compiled objects
from ASAN_INST_TEST_OBJECTS, and therefore they have been built against
gtest already.

This both fixes the spurious dependency on 'gtest' target that breaks
stand-alone builds, and brings the dynamic tests more in line with
regular tests which do not pass this dependency
to add_compiler_rt_test() through generate_compiler_rt_tests().

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

llvm-svn: 315620
2017-10-12 21:07:43 +00:00
Michal Gorny 007b540feb [cmake] [interception] Remove duplicate gtest from test COMPILE_DEPS
Fix the gtest dependency to be included in DEPS only, rather than
in COMPILE_DEPS + DEPS. The former variable is apparently used to
provide unconditional dependencies, while the latter are only used
for non-standalone builds. Since they are concatenated, specifying gtest
in both is redundant. Furthermore, including it in COMPILE_DEPS causes
build failure for standalone builds where 'gtest' target is not present.

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

llvm-svn: 315605
2017-10-12 18:51:41 +00:00
Michal Gorny 858509cfb3 [cmake] Fix skipping DEPS (typo) in sanitizer_test_compile()
Fix typo in variable assignment inside sanitizer_test_compile() that
resulted in TEST_DEPS parameter not being included in the clang_compile()
call. Spotted by George Karpenkov in D38444.

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

llvm-svn: 315604
2017-10-12 18:51:37 +00:00
Evgeniy Stepanov fe35898b42 [asan] Disable a flaky test on android.
llvm-svn: 315602
2017-10-12 18:34:20 +00:00
Kostya Kortchinsky 8d4ba5fd23 [scudo] Allow for non-Android Shared TSD platforms, part 1
Summary:
This first part just prepares the grounds for part 2 and doesn't add any new
functionality. It mostly consists of small refactors:
- move the `pthread.h` include higher as it will be used in the headers;
- use `errno.h` in `scudo_allocator.cpp` instead of the sanitizer one, update
  the `errno` assignments accordingly (otherwise it creates conflicts on some
  platforms due to `pthread.h` including `errno.h`);
- introduce and use `getCurrentTSD` and `setCurrentTSD` for the shared TSD
  model code;

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: llvm-commits, srhines

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

llvm-svn: 315583
2017-10-12 15:01:09 +00:00
Hans Wennborg eb2218ceae Revert r315533 "Reland "[sanitizer] Introduce ReservedAddressRange to sanitizer_common""
The SanitizerCommon.ReservedAddressRangeUnmap test fails on Windows:

FAIL: SanitizerCommon-Unit :: ./Sanitizer-x86_64-Test.exe/SanitizerCommon.ReservedAddressRangeUnmap (34003 of 35554)
******************** TEST 'SanitizerCommon-Unit :: ./Sanitizer-x86_64-Test.exe/SanitizerCommon.ReservedAddressRangeUnmap' FAILED ********************
Note: Google Test filter = SanitizerCommon.ReservedAddressRangeUnmap
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from SanitizerCommon
[ RUN      ] SanitizerCommon.ReservedAddressRangeUnmap
==3780==ERROR: SanitizerTool failed to deallocate 0x1000 (4096) bytes at address 0x0000000c3000 (error code: 487)
==3780==Sanitizer CHECK failed: E:\b\build\slave\win_upload_clang\build\src\third_party\llvm\projects\compiler-rt\lib\sanitizer_common\sanitizer_win.cc:129 (("unable to unmap" && 0)) != (0) (0, 0)
********************
Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
Testing Time: 299.76s
********************
Failing Tests (1):
    SanitizerCommon-Unit :: ./Sanitizer-x86_64-Test.exe/SanitizerCommon.ReservedAddressRangeUnmap

> In Fuchsia, MmapNoAccess/MmapFixedOrDie are implemented using a global
> VMAR, which means that MmapNoAccess can only be called once. This works
> for the sanitizer allocator but *not* for the Scudo allocator.
>
> Hence, this changeset introduces a new ReservedAddressRange object to
> serve as the new API for these calls. In this changeset, the object
> still calls into the old Mmap implementations.
>
> The next changeset two changesets will convert the sanitizer and scudo
> allocators to use the new APIs, respectively. (ReservedAddressRange will
> replace the SecondaryHeader in Scudo.)
>
> Finally, a last changeset will update the Fuchsia implementation.
>
> Patch by Julia Hansbrough
>
> Differential Revision: https://reviews.llvm.org/D38437

llvm-svn: 315553
2017-10-12 03:23:31 +00:00
Petr Hosek 4f213ae3a7 Reland "[sanitizer] Introduce ReservedAddressRange to sanitizer_common"
In Fuchsia, MmapNoAccess/MmapFixedOrDie are implemented using a global
VMAR, which means that MmapNoAccess can only be called once. This works
for the sanitizer allocator but *not* for the Scudo allocator.

Hence, this changeset introduces a new ReservedAddressRange object to
serve as the new API for these calls. In this changeset, the object
still calls into the old Mmap implementations.

The next changeset two changesets will convert the sanitizer and scudo
allocators to use the new APIs, respectively. (ReservedAddressRange will
replace the SecondaryHeader in Scudo.)

Finally, a last changeset will update the Fuchsia implementation.

Patch by Julia Hansbrough

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

llvm-svn: 315533
2017-10-11 23:41:32 +00:00
Evgeniy Stepanov 1961c6cb2c Disable TSan tests on Android.
They never passed. This change excludes them from 'check-all'.

llvm-svn: 315512
2017-10-11 21:22:45 +00:00
Evgeniy Stepanov 3747b826c4 Disable profile tests on Android.
They never actually worked, but this way they are not included in "check-all".

llvm-svn: 315511
2017-10-11 21:22:32 +00:00
Kostya Kortchinsky 6a45f9ce82 [sanitizer] Move the errno/ENOMEM allocator checks logic to separate .cc
Summary:
This is a new attempt at D38706, which had 2 issues.

The first one was that it broke TSan, because `sanitizer_errno.h` was not
directly included in `tsan_mman.cc`. This fixes the include.

The second one was that it broke the nolibc build, because `__errno_location`
couldn't be found. This adds the new .cc to the libcdep list instead of the
base one.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: kubamracek, mgorny, llvm-commits

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

llvm-svn: 315509
2017-10-11 21:20:04 +00:00
Evgeniy Stepanov 450ae592b4 [ubsan] Support ubsan-minimal tests on Android.
llvm-svn: 315507
2017-10-11 20:46:13 +00:00
Craig Topper 705b969f80 [X86] Add Knights Mill CPU to cpu_indicator support to match libgcc.
llvm-svn: 315505
2017-10-11 20:35:43 +00:00
Kostya Serebryany 75480e3871 [libFuzzer] disable use_feature_frequency as it degrades some of the benchmarks too much :(
llvm-svn: 315503
2017-10-11 20:31:01 +00:00
Petr Hosek c530f497b8 Revert "[sanitizer] Introduce ReservedAddressRange to sanitizer_common"
This reverts commit r315493 which is failing to build on sanitizer-windows.

llvm-svn: 315494
2017-10-11 19:29:14 +00:00
Petr Hosek 2bd0123afc [sanitizer] Introduce ReservedAddressRange to sanitizer_common
In Fuchsia, MmapNoAccess/MmapFixedOrDie are implemented using a global
VMAR, which means that MmapNoAccess can only be called once. This works
for the sanitizer allocator but *not* for the Scudo allocator.

Hence, this changeset introduces a new ReservedAddressRange object to
serve as the new API for these calls. In this changeset, the object
still calls into the old Mmap implementations.

The next changeset two changesets will convert the sanitizer and scudo
allocators to use the new APIs, respectively. (ReservedAddressRange will
replace the SecondaryHeader in Scudo.)

Finally, a last changeset will update the Fuchsia implementation.

Patch by Julia Hansbrough

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

llvm-svn: 315493
2017-10-11 19:17:35 +00:00
Kostya Serebryany 198d385a77 [libFuzzer] make -use_feature_frequency less aggressive and enable by default
llvm-svn: 315490
2017-10-11 19:01:35 +00:00
Evgeniy Stepanov b751082d56 [asan] Tweak test output to diagnose buildbot failures.
llvm-svn: 315479
2017-10-11 17:32:38 +00:00
Kostya Serebryany 4083d54675 [libFuzzer] experimental flag to tweak the corpus distribution. Seems to improve the situation dramatically on the png benchmark and make things worse on a number of micro-puzzles. Needs more A/B testing
llvm-svn: 315407
2017-10-11 01:44:26 +00:00
Evgeniy Stepanov 922973a466 [sanitizer] Re-disable several tests on Android.
The tests have been enabled by accident in r315389.

llvm-svn: 315396
2017-10-11 00:32:03 +00:00
Evgeniy Stepanov 0bf7717a02 Factor out "stable-runtime" feature and enable it on all android.
This is a very poorly named feature. I think originally it meant to cover linux only, but the use of it in msan
seems to be about any aarch64 platform. Anyway, this change should be NFC on everything except Android.

llvm-svn: 315389
2017-10-10 23:37:26 +00:00
Hans Wennborg 4a6ee430bb XFAIL ubsan/TestCases/TypeCheck/Function/function.cpp on Windows
I think it got accidentally enabled in r315105 or thereabouts.

llvm-svn: 315374
2017-10-10 22:11:25 +00:00
Kostya Kortchinsky ea2f800bbc [sanitizer] Revert D38706
Summary:
D38706 breaks tsan and the nolibc build.
Reverting while working on a fix.

Reviewers: alekseyshl

Subscribers: kubamracek, mgorny, llvm-commits

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

llvm-svn: 315320
2017-10-10 15:35:11 +00:00
Kostya Kortchinsky 03f9e76790 [sanitizer] Move the errno/ENOMEM allocator checks logic to separate .cc
Summary:
The fact that `sanitizer_allocator_checks.h` is including `sanitizer_errno.h`
creates complications for future changes, where it would conflict with `errno.h`
definitions on Android and Fuchsia (macro redefinition).

By moving the portion that sets errno in the checks to a separate compilation
unit, we avoid the inclusion of the header there, which solves the issue.

Not that it is not vital to have that function in a header as it is called as a
result of an unlikely event, and doesn't need to be inlined.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: kubamracek, llvm-commits, mgorny

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

llvm-svn: 315319
2017-10-10 14:58:09 +00:00
Dean Michael Berris 9ba7401a7b [XRay][compiler-rt] Fix rdtscp support check for x86_64
Follow-up to D29438.

llvm-svn: 315306
2017-10-10 12:44:20 +00:00
Evgeniy Stepanov cb993304ac [ubsan] Fix Asan internal alloc corruption in PR33221 test.
MAP_FIXED discards the existing mapping at the given address.

llvm-svn: 315247
2017-10-09 22:52:13 +00:00
Petr Hosek 1c0c35d034 [sanitizer] Don't intercept signal and sigaction on Fuchsia
Fuchsia doesn't support signals, so don't use interceptors for signal or
sigaction.

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

llvm-svn: 315227
2017-10-09 18:29:52 +00:00
Evgeniy Stepanov 8804483b05 [ubsan] Disable one test on Android.
llvm-svn: 315220
2017-10-09 17:45:03 +00:00
Vlad Tsyrklevich a0b02833bc Limit CFI blacklist entries to specific CFI mode
Summary:
Since D37924 and D37925 were merged, it's now possible to specify
individual sanitizers or CFI modes in sanitizer blacklists. Update the
CFI blacklist entries to only apply to cfi-unrelated-cast checks.

Reviewers: eugenis, pcc

Reviewed By: eugenis

Subscribers: kcc

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

llvm-svn: 315216
2017-10-09 17:11:44 +00:00
Peter Collingbourne 107a9f624d Make the cfi target available on more platforms.
On non-Linux targets it just installs the blacklist.

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

llvm-svn: 315215
2017-10-09 17:07:47 +00:00
Vedant Kumar 2465e64846 cmake: Fix one more usage of append()
append() isn't available with some cmake versions, so I need to use a
different construct. I missed this case in r315144.

http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA/39355

llvm-svn: 315157
2017-10-07 20:20:42 +00:00
Vedant Kumar 16d41609ab Use list(APPEND) instead of append()
append() seems to be available with the version of cmake I'm using, but
not on the bots:

http://green.lab.llvm.org/green//job/clang-stage1-configure-RA/39354

llvm-svn: 315144
2017-10-07 03:44:46 +00:00
Vedant Kumar 074a997b13 [ubsan] Add a static runtime on Darwin
As a follow-up to r315142, this makes it possible to use ubsan with a
static runtime on Darwin. I've also added a new StandaloneStatic testing
configuration so the new setup can be tested.

llvm-svn: 315143
2017-10-07 01:46:36 +00:00
Evgeniy Stepanov 729bcd1f6e [asan] Disable wcslen test on 32-bit Android.
llvm-svn: 315132
2017-10-07 00:04:24 +00:00
Evgeniy Stepanov 0a4217c14b Factor out default_(a|ub)sanitizer_opts in lit.
Reviewers: vitalybuka

Subscribers: srhines, llvm-commits, kubamracek

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

llvm-svn: 315106
2017-10-06 20:53:40 +00:00
Evgeniy Stepanov f29ee9a050 [sanitizer] Test ubsan and cfi on android.
Summary:
Enable check-cfi and check-ubsan on Android.
Check-ubsan includes standalone and ubsan+asan, but not tsan or msan.
Cross-dso cfi tests are disabled for now.

Reviewers: vitalybuka, pcc

Subscribers: srhines, kubamracek, llvm-commits, mgorny

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

llvm-svn: 315105
2017-10-06 20:51:51 +00:00
Evgeniy Stepanov 505260449e [asan] Use gold linker in android tests.
Replace a partial workaround for ld.bfd strangeness with the ultimate one: -fuse-ld=gold.
Reason: ld.bfd problem gets worse with libc++-based NDK toolchain.

llvm-svn: 315039
2017-10-06 00:00:53 +00:00
Alex Shlyapnikov 84d16165d4 Revert "[LSan] Detect dynamic loader by its base address."
This reverts commit r315024.

Breaks sysconf_interceptor_bypass_test.cc

llvm-svn: 315031
2017-10-05 22:53:17 +00:00
Max Moroz 330496c3fc [libFuzzer] Disable experimental clang coverage support by default.
Summary:
It can be enabled via "-use_clang_coverage=1" flag. Reason for disabling:
libFuzzer resets Clang Counters and makes it impossible to generate coverage
report for a regular fuzz target (i.e. not standalone build).

Reviewers: kcc

Reviewed By: kcc

Subscribers: kcc

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

llvm-svn: 315029
2017-10-05 22:41:03 +00:00
Evgeniy Stepanov 0d0325606b [cfi] Disable tests with lld on i386.
bin/ld.lld: error: ubsan_handlers.cc:(.debug_info+0x80D5D): has non-ABS reloc

Bug pending.

llvm-svn: 315027
2017-10-05 22:07:21 +00:00
Alex Shlyapnikov 44f9376347 [LSan] Detect dynamic loader by its base address.
Summary:
Relanding D33859, which was reverted because it has "broken LOTS of
ARM/AArch64 bots for two days".

If it breaks something again, please provide some pointers to broken
bots, not just revert it, otherwise it's very hard to reason what's
wrong with this commit.

Whenever possible (Linux + glibc 2.16+), detect dynamic loader module by
its base address, not by the module name matching. The current name
matching approach fails on some configurations.

Reviewers: eugenis

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

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

llvm-svn: 315024
2017-10-05 21:38:33 +00:00
Evgeniy Stepanov 1917176d47 [asan] Add --enable-new-dtags in tests on Android.
The dynamic loader does not accept DT_RPATH; it wants DT_RUNPATH.

This is a temporary fix until D38430 lands.

llvm-svn: 315020
2017-10-05 20:45:12 +00:00
Evgeniy Stepanov 4a3e502d5d [asan] Use full binary path in the Android test runner.
Summary:
This prevents the confusion when there are similarly named tests in
different configurations (like in test/sanitizer_common).

Reviewers: vitalybuka

Subscribers: srhines, llvm-commits, kubamracek

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

llvm-svn: 315011
2017-10-05 20:00:19 +00:00
Evgeniy Stepanov 3b87cc910e [sanitizer] Move %ld_flags_rpath_exe to common and use it in more tests.
Reviewers: vitalybuka

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 315010
2017-10-05 20:00:07 +00:00
Evgeniy Stepanov ca6c8e85d1 [cfi] Mark a test as unsupported on darwin.
llvm-svn: 315007
2017-10-05 19:36:15 +00:00
Evgeniy Stepanov f7e14f4c72 [cfi] Test on all available targets.
Summary:
Run CFI tests on all targets current toolchain can target.
On multiarch Linux, this will run all CFI tests with -m32 and -m64.

Reviewers: pcc

Subscribers: mgorny, llvm-commits

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

llvm-svn: 315001
2017-10-05 18:28:04 +00:00
Dean Michael Berris 8dcba551d9 [XRay][compiler-rt] Write out arg1 payload in naive mode logging
Summary:
This change allows the XRay basic (naive) mode logging implementation to
start writing the payload entries through the arg1 logging handler. This
implementation writes out the records that the llvm-xray tool and the
trace reader library will start processing in D38550.

This introduces a new payload record type which logs the data through
the in-memory buffer. It uses the same size/alignment that the normal
XRay record entries use. We use a new record type to indicate these new
entries, so that the trace reader library in LLVM can start reading
these entries.

Depends on D38550.

Reviewers: pelikan

Subscribers: llvm-commits

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

llvm-svn: 314968
2017-10-05 05:45:51 +00:00
Evgeniy Stepanov 928bc08247 [sanitizer] Move cxx-abi library earlier in link flags.
Summary:
This change moves cxx-abi library in asan/ubsan/dd link command line
ahead of other libraries, such as pthread/rt/dl/c/gcc. Given that
cxx-abi may be the full libstdc++/libc++, it makes sense for it to be
ahead of libc and libgcc, at least.

The real motivation is Android, where in the arm32 NDK toolchain
libstdc++.a is actually a linker script that tries to sneak LLVM's
libunwind ahead of libgcc's. Wrong library order breaks unwinding.

Reviewers: srhines, danalbert

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

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

llvm-svn: 314948
2017-10-04 23:35:14 +00:00
Dean Michael Berris f279d9b409 [XRay][compiler-rt] Fix logical failure in BufferQueue::getBuffer()
Follow-up to D38119.

llvm-svn: 314878
2017-10-04 06:02:12 +00:00
Dean Michael Berris d06e917b9e [XRay][compiler-rt] Use a hand-written circular buffer in BufferQueue
Summary:
This change removes the dependency on using a std::deque<...> for the
storage of the buffers in the buffer queue. We instead implement a
fixed-size circular buffer that's resilient to exhaustion, and preserves
the semantics of the BufferQueue.

We're moving away from using std::deque<...> for two reasons:

  - We want to remove dependencies on the STL for data structures.

  - We want the data structure we use to not require re-allocation in
    the normal course of operation.

The internal implementation of the buffer queue uses heap-allocated
arrays that are initialized once when the BufferQueue is created, and
re-uses slots in the buffer array as buffers are returned in order.

We also change the lock used in the implementation to a spinlock
instead of a blocking mutex. We reason that since the release operations
now take very little time in the critical section, that a spinlock would
be appropriate.

This change is related to D38073.

This change is a re-submit with the following changes:

  - Keeping track of the live buffers with a counter independent of the
    pointers keeping track of the extents of the circular buffer.

  - Additional documentation of what the data members are meant to
    represent.

Reviewers: dblaikie, kpw, pelikan

Subscribers: llvm-commits

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

llvm-svn: 314877
2017-10-04 05:20:13 +00:00
Martin Pelikan 68ea360ed1 [XRay] [compiler-rt] make sure single threaded programs get traced too
Summary:
When the XRay user calls the API to finish writing the log, the thread
which is calling the API still hasn't finished and therefore won't get
its trace written.  Add a test for only the main thread to check this.

Reviewers: dberris

Subscribers: llvm-commits

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

llvm-svn: 314875
2017-10-04 05:12:00 +00:00
Eli Friedman 0d586d06a7 [compiler-rt] Add back ARM EABI aliases where legal.
r303188 removed all the uses of aliases for EABI functions from
compiler-rt, because some of them had mismatched calling conventions.
Obviously, we can't use aliases for functions which don't have the same
calling convention, but that's only an issue for floating-point
functions with the hardfloat ABI.  In other cases, the stubs increase
size and reduce performance for no benefit.

This patch adds back the aliases, with appropriate checks to make sure
they're only used in cases where the calling convention matches.

llvm-svn: 314851
2017-10-03 21:25:07 +00:00
Dean Michael Berris 11415ac44e Revert "[XRay][compiler-rt] Use a hand-written circular buffer in BufferQueue"
This reverts r314766 (rL314766). Unit tests fail in multiple bots.

llvm-svn: 314786
2017-10-03 11:40:54 +00:00
Dean Michael Berris a1b8e0352f [XRay][compiler-rt] Use a hand-written circular buffer in BufferQueue
Summary:
This change removes the dependency on using a std::deque<...> for the
storage of the buffers in the buffer queue. We instead implement a
fixed-size circular buffer that's resilient to exhaustion, and preserves
the semantics of the BufferQueue.

We're moving away from using std::deque<...> for two reasons:

  - We want to remove dependencies on the STL for data structures.

  - We want the data structure we use to not require re-allocation in
    the normal course of operation.

The internal implementation of the buffer queue uses heap-allocated
arrays that are initialized once when the BufferQueue is created, and
re-uses slots in the buffer array as buffers are returned in order.

We also change the lock used in the implementation to a spinlock
instead of a blocking mutex. We reason that since the release operations
now take very little time in the critical section, that a spinlock would
be appropriate.

This change is related to D38073.

Reviewers: dblaikie, kpw, pelikan

Subscribers: llvm-commits

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

llvm-svn: 314766
2017-10-03 06:15:34 +00:00
Dean Michael Berris 4204464c76 fixup: use UNUSED, restore alignment for cache-line friendliness, and report on errors found when pthread_create_key fails
llvm-svn: 314765
2017-10-03 06:11:20 +00:00
Dean Michael Berris 1dbf45dc27 [XRay][compiler-rt] Use pthread for initializing thread-local data
Summary:
We avoid using C++11's thread_local keyword on non-trivially
destructible objects because it may introduce deadlocks when the C++
runtime registers destructors calling std::malloc(...). The deadlock may
happen when the allocator implementation is itself XRay instrumented.

To avoid having to call malloc(...) and free(...) in particular, we use
pthread_once, pthread_create_key, and pthread_setspecific to instead
manually register the cleanup implementation we want.

The code this replaces used an RAII type that implements the cleanup
functionality in the destructor, that was then initialized as a
function-local thread_local object. While it works in usual situations,
unfortunately it breaks when using a malloc implementation that itself
is XRay-instrumented.

Reviewers: dblaikie, kpw, pelikan

Subscribers: llvm-commits

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

llvm-svn: 314764
2017-10-03 06:11:13 +00:00
Manoj Gupta e2ff2ba57d [builtins] ARM: Reland fix for assembling builtins in thumb state.
Summary:
clang does not assemble files in thumb mode unless .thumb declaration
is present. Add .thumb/.arm decl to _FUNCTION macros to ensure 	that
files are assembled correctly.

Also add a fix to ensure that armv7k-watchos can assemble the
aeabi_c{f|d}cmp.S files.

Fixes PR 34715.

Reviewers: compnerd, peter.smith, srhines, weimingz, rengolin, efriedma, t.p.northover, fjricci

Reviewed By: compnerd

Subscribers: aemerson, javed.absar, llvm-commits, kristof.beyls

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

llvm-svn: 314718
2017-10-02 20:56:49 +00:00
Francis Ricci daf210f7b6 Add support for custom loaders to the sanitizer symbolizer
Summary:
Adds a fallback mode to procmaps when the symbolizer
fails to locate a module for a given address by using
dl_iterate_phdr.

Reviewers: kubamracek, rnk, vitalybuka, eugenis

Reviewed By: eugenis

Subscribers: srhines, llvm-commits

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

llvm-svn: 314713
2017-10-02 20:22:16 +00:00
Francis Ricci b7055bb813 Revert "Add support for custom loaders to the sanitizer symbolizer"
This reverts commit r314671, which hangs on the gcc sanitizer buildbot.

llvm-svn: 314684
2017-10-02 15:55:11 +00:00
Francis Ricci e2aa5b2ace Add support for custom loaders to the sanitizer symbolizer
Summary:
Adds a fallback mode to procmaps when the symbolizer
fails to locate a module for a given address by using
dl_iterate_phdr.

Reviewers: kubamracek, rnk, vitalybuka, eugenis

Reviewed By: eugenis

Subscribers: srhines, llvm-commits

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

llvm-svn: 314671
2017-10-02 14:30:58 +00:00
Filipe Cabecinhas 3ccd23e116 Use %run for running CFI tests
Reviewers: pcc, krasin, eugenis

Subscribers: llvm-commits

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

llvm-svn: 314659
2017-10-02 10:21:26 +00:00
Michal Gorny 806b8d56a2 [cmake] Add a separate CMake var to control profile runtime
Make it possible to control building profile runtime separately from
other options. Before r313549, the profile runtime building was
controlled along with sanitizers. However, since that commit it is built
unconditionally which results in multiple builds for people building
different runtimes separately.

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

llvm-svn: 314646
2017-10-02 05:03:55 +00:00
Francis Ricci 345187338e Move LoadedModule list to a NoCtor vector and initialize on demand.
Unreverting this patch because llvm-clang-lld-x86_64-debian-fast started
passing again before the revert hit. Must've been just a flake.

llvm-svn: 314556
2017-09-29 20:55:06 +00:00
Francis Ricci 74c93de659 Revert "Move LoadedModule list to a NoCtor vector and initialize on demand."
I think this may have introduced a failure on
llvm-clang-lld-x86_64-debian-fast

This reverts commit r314533

llvm-svn: 314552
2017-09-29 20:04:29 +00:00
Francis Ricci 113708b7cb Move LoadedModule list to a NoCtor vector and initialize on demand.
llvm-svn: 314533
2017-09-29 16:47:02 +00:00
Alex Shlyapnikov 54ea394963 Fix cmake file broken by D38277.
llvm-svn: 314528
2017-09-29 16:02:39 +00:00
Francis Ricci 8fb270c691 Add missing header definition
llvm-svn: 314521
2017-09-29 15:17:23 +00:00
Francis Ricci c48e9487a5 Remove recursion from FindModuleForAddress. NFC.
llvm-svn: 314520
2017-09-29 15:14:31 +00:00
Francis Ricci 5207630d7e Refactor android fallback procmaps init. NFC.
llvm-svn: 314518
2017-09-29 15:06:47 +00:00
Jonas Hahnfeld ddbb0926a0 [CMake] Fix configuration on PowerPC with sanitizers
TEST_BIG_ENDIAN() performs compile tests that will fail with
-nodefaultlibs when building under LLVM_USE_SANITIZER.

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

llvm-svn: 314512
2017-09-29 13:32:39 +00:00
Dean Michael Berris fc064af181 [XRay][compiler-rt][NFC] Remove loggingInitialized() convenience function
The function was introduced as a convenience that used to be called in
multiple places. Recent refactorings have removed the need to call this
function in multiple places, so inlined the implementation in the single
place it's defined.

Broken out from D38119.

llvm-svn: 314489
2017-09-29 04:28:11 +00:00
Francis Ricci 052ec5f92a Revert "Add support for custom loaders to the sanitizer symbolizer"
This causes the gcc sanitizer buildbot to timeout.

This reverts commit 81f388fe570e5b6460dd5bc9b9a36b72714eeb68.

llvm-svn: 314453
2017-09-28 19:37:17 +00:00
Evgeniy Stepanov a41b578635 [asan] Fix the bug number in the error message.
The link in the "Shadow memory range interleaves with an existing
memory mapping" error message was pointing to the wrong bug.

llvm-svn: 314441
2017-09-28 18:19:44 +00:00
Francis Ricci b9a32d470a Add support for custom loaders to the sanitizer symbolizer
Summary:
Adds a fallback mode to procmaps when the symbolizer
fails to locate a module for a given address by using
dl_iterate_phdr.

Reviewers: kubamracek, rnk, vitalybuka, eugenis

Reviewed By: eugenis

Subscribers: srhines, llvm-commits

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

llvm-svn: 314431
2017-09-28 16:58:35 +00:00
Benjamin Kramer c4e652f3aa [asan] Unpoison global metadata on dlclose.
dlclose itself might touch it, so better return it to the state it was
before. I don't know how to create a test for this as it would require
chaning dlclose itself.

llvm-svn: 314415
2017-09-28 13:38:58 +00:00
Dmitry Vyukov 47ad1ef2db tsan: handle signals in pause call
llvm-svn: 314384
2017-09-28 07:32:00 +00:00
Martin Pelikan 2e9cd5693f [XRay] [compiler-rt] FDR logging arg1 handler
Summary:
Write out records about logged function call first arguments. D32840
implements the reading of this in llvm-xray.

Reviewers: dberris

Subscribers: llvm-commits

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

llvm-svn: 314378
2017-09-28 05:29:59 +00:00
Evgeniy Stepanov d122381288 [ubsan] Merge ubsan_standalone_cxx shared library.
Summary:
Link everything, including the C++ bits, in the single
ubsan_standalone SHARED library. This matches ASan setup.

Reviewers: vitalybuka

Subscribers: kubamracek, llvm-commits, mgorny

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

llvm-svn: 314369
2017-09-28 00:31:09 +00:00
Dmitry Mikulin d2224e17c3 ASan allocates a global data initialization array at the tail end of each
compunit's .data section. This vector is not poisoned. Because of this the
first symbol of the following section has no left red zone. As a result, ASan
cannot detect underflow for such symbols.

Poison ASan allocated metadata, it should not be accessible to user code.

This fix does not eliminate the problem with missing left red zones but it
reduces the set of vulnerable symbols from first symbols in each input data
section to first symbols in the output section of the binary.

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

llvm-svn: 314365
2017-09-27 23:32:01 +00:00
Francis Ricci cb15e22b3b Revert "Add support for custom loaders to symbolizer"
This broke the windows buildbots, revert for now.

This reverts commit 24050b5ddef42f6f3306aa94d4a1f42a7893a9a7.

llvm-svn: 314347
2017-09-27 21:35:33 +00:00
Kostya Kortchinsky fa1ae3e862 [scudo] Temporary disabling the valloc test on armhf
Summary:
Weird failure where `errno != ENOMEM` on valloc failure. The returned pointer
is null since it passes the previous assert, so this shouldn't happen.

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/10931
http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15-full-sh/builds/2469

Disabling until we figure out what's going on.

Reviewers: alekseyshl

Reviewed By: alekseyshl

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

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

llvm-svn: 314344
2017-09-27 21:10:25 +00:00
Francis Ricci f80c42e589 Add support for custom loaders to symbolizer
Change-Id: I5594bd6b216deca2c73cf0a7001f9aec1e803c60
llvm-svn: 314342
2017-09-27 20:56:04 +00:00
Manoj Gupta bfa662ae4e [builtins] ARM: Revert r314284, r314285 and r314289
Revert r314284, r314285 and r314289 because of a reported
breakage in armv7k watchos builder.

llvm-svn: 314333
2017-09-27 19:06:47 +00:00
Manoj Gupta a2eacb3bfc [ARM] builtins: Replace abort by assert in clear_cache.
Summary:
__builtion___clear_cache maps to clear_cache function. On Linux,
clear_cache functions makes a syscall and does an abort if syscall fails.
Replace the abort by an assert so that non-debug builds do not abort
if the syscall fails.

Fixes PR34588.

Reviewers: rengolin, compnerd, srhines, peter.smith, joerg

Reviewed By: rengolin

Subscribers: aemerson, kristof.beyls, llvm-commits

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

llvm-svn: 314322
2017-09-27 17:36:25 +00:00
Alex Shlyapnikov fb238e5907 [Sanitizer] Disable compact size class tests on Android
Fixing test failure on Android introduced in D38245. Compact size class
maps defined there are not to be used on Android.

llvm-svn: 314318
2017-09-27 17:10:49 +00:00
Alex Shlyapnikov 04ce5ac306 [Sanitizers] Allocator: new "release memory to OS" implementation
Summary:
The current implementation of the allocator returning freed memory
back to OS (controlled by allocator_release_to_os_interval_ms flag)
requires sorting of the free chunks list, which has two major issues,
first, when free list grows to millions of chunks, sorting, even the
fastest one, is just too slow, and second, sorting chunks in place
is unacceptable for Scudo allocator as it makes allocations more
predictable and less secure.

The proposed approach is linear in complexity (altough requires quite
a bit more temporary memory). The idea is to count the number of free
chunks on each memory page and release pages containing free chunks
only. It requires one iteration over the free list of chunks and one
iteration over the array of page counters. The obvious disadvantage
is the allocation of the array of the counters, but even in the worst
case we support (4T allocator space, 64 buckets, 16 bytes bucket size,
full free list, which leads to 2 bytes per page counter and ~17M page
counters), requires just about 34Mb of the intermediate buffer (comparing
to ~64Gb of actually allocated chunks) and usually it stays under 100K
and released after each use. It is expected to be a relatively rare event,
releasing memory back to OS, keeping the buffer between those runs
and added complexity of the bookkeeping seems unnesessary here (it can
always be improved later, though, never say never).

The most interesting problem here is how to calculate the number of chunks
falling into each memory page in the bucket. Skipping all the details,
there are three cases when the number of chunks per page is constant:
  1) P >= C, P % C == 0 --> N = P / C
  2) C > P , C % P == 0 --> N = 1
  3) C <= P, P % C != 0 && C % (P % C) == 0 --> N = P / C + 1
where P is page size, C is chunk size and N is the number of chunks per
page and the rest of the cases, where the number of chunks per page is
calculated on the go, during the page counter array iteration.

Among the rest, there are still cases where N can be deduced from the
page index, but they require not that much less calculations per page
than the current "brute force" way and 2/3 of the buckets fall into
the first three categories anyway, so, for the sake of simplicity,
it was decided to stick to those two variations. It can always be
refined and improved later, should we see that brute force way slows
us down unacceptably.

Reviewers: eugenis, cryptoad, dvyukov

Subscribers: kubamracek, mehdi_amini, llvm-commits

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

llvm-svn: 314311
2017-09-27 15:38:05 +00:00
Manoj Gupta 92c21d54a4 [builtins] fix build error on non-ARM for r314285.
llvm-svn: 314289
2017-09-27 09:49:32 +00:00
Manoj Gupta 6992817a0e [Builtins] ARM: Fix assembling files in thumb mode.
Summary:
clang does not assemble files in thumb mode unless .thumb declaration
is present. Add .thumb/.arm decl to _FUNCTION macros to ensure that
files are assembled correctly.

Fixes PR 34715.

Reviewers: compnerd, peter.smith, srhines, weimingz, rengolin

Reviewed By: compnerd

Subscribers: aemerson, javed.absar, llvm-commits, kristof.beyls

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

llvm-svn: 314285
2017-09-27 09:33:14 +00:00
Manoj Gupta 9c277321e3 [Builtins] ARM: Fix msr assembly instruction use for Thumb2.
Summary:
MSR instruction in Thumb2 does not support immediate operand.
Fix this by moving the condition for V7-M to Thumb2 since V7-M support
Thumb2 only. With this change, aeabi_cfcmp.s and aeabi_cdcmp.S files can
be assembled in Thumb2 mode. (This is split out from the review D38227).

Reviewers: compnerd, peter.smith, srhines, weimingz, rengolin, kristof.beyls

Reviewed By: compnerd

Subscribers: aemerson, javed.absar, llvm-commits

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

llvm-svn: 314284
2017-09-27 09:29:57 +00:00
Manoj Gupta 347ff633f7 [Builtins] Use 4 byte alignment for __aeabi_memclr.
Summary:
Align __aeabi_memclr to 4 bytes. All other ARM functions are already aligned to
4-bytes in compiler-rt.
(Split off from review D38227)

Reviewers: compnerd, peter.smith, srhines, weimingz, rengolin, kristof.beyls

Reviewed By: compnerd

Subscribers: aemerson, javed.absar, llvm-commits

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

llvm-svn: 314255
2017-09-26 22:37:08 +00:00
Kostya Kortchinsky b59abb2590 [scudo] Scudo thread specific data refactor, part 3
Summary:
Previous parts: D38139, D38183.

In this part of the refactor, we abstract the Linux vs Android TSD dissociation
in favor of a Exclusive vs Shared one, allowing for easier platform introduction
and configuration.

Most of this change consist of shuffling the files around to reflect the new
organization.

We introduce `scudo_platform.h` where platform specific definition lie. This
involves the TSD model and the platform specific allocator parameters. In an
upcoming CL, those will be configurable via defines, but we currently stick
with conservative defaults.

Reviewers: alekseyshl, dvyukov

Reviewed By: alekseyshl, dvyukov

Subscribers: srhines, llvm-commits, mgorny

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

llvm-svn: 314224
2017-09-26 17:20:02 +00:00
Francis Ricci b4f6c0eca2 Invalidate symbolizer module list from dlopen/dlclose interceptors
Summary:
The module list should only be invalidated by dlopen and dlclose,
so the symbolizer should only re-generate it when we've hit one of those functions.

Reviewers: kubamracek, rnk, vitalybuka

Subscribers: llvm-commits

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

llvm-svn: 314219
2017-09-26 16:12:56 +00:00
Simon Dardis 5a14bc84e1 [mips][asan] Fix preinstalled_signal.cc test for mips
Linux for mips has a non-standard layout for the kernel sigaction struct.
Adjust the layout by the minimally amount to get the test to pass, as we
don't require the usage of the restorer function.

llvm-svn: 314200
2017-09-26 11:49:04 +00:00
Francis Ricci 92fa15d01c Add missing include to sanitizer procmaps
llvm-svn: 314162
2017-09-25 21:51:04 +00:00
Francis Ricci 7bde17f3ec Fix style in sanitizer_procmaps.h
llvm-svn: 314157
2017-09-25 21:26:34 +00:00
Francis Ricci 6e4dfccc31 [sanitizer_common] Don't provide sanitizer_procmaps API functions where not defined
Summary:
Platforms that don't implement procmaps (primarily fuchsia and windows) still expose
the procmaps API when including sanitizer_procmaps.h, despite not implementing the functions
provided by that header. Ensure that the API is only exposed on platforms that implement it.

Reviewers: vitalybuka, alekseyshl, kubamracek

Subscribers: llvm-commits, krytarowski

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

llvm-svn: 314149
2017-09-25 20:48:51 +00:00
Kostya Kortchinsky 22396c2f47 [scudo] Scudo thread specific data refactor, part 2
Summary:
Following D38139, we now consolidate the TSD definition, merging the shared
TSD definition with the exclusive TSD definition. We introduce a boolean set
at initializaton denoting the need for the TSD to be unlocked or not. This
adds some unused members to the exclusive TSD, but increases consistency and
reduces the definitions fragmentation.

We remove the fallback mechanism from `scudo_allocator.cpp` and add a fallback
TSD in the non-shared version. Since the shared version doesn't require one,
this makes overall more sense.

There are a couple of additional cosmetic changes: removing the header guards
from the remaining `.inc` files, added error string to a `CHECK`.

Question to reviewers: I thought about friending `getTSDAndLock` in `ScudoTSD`
so that the `FallbackTSD` could `Mutex.Lock()` directly instead of `lock()`
which involved zeroing out the `Precedence`, which is unused otherwise. Is it
worth doing?

Reviewers: alekseyshl, dvyukov, kcc

Reviewed By: dvyukov

Subscribers: srhines, llvm-commits

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

llvm-svn: 314110
2017-09-25 15:12:08 +00:00
Simon Dardis 46f5df1a20 [mips][compiler-rt] Disable sem_init_glibc.cc for MIPS64.
This test can't pass on MIPS64 due to the lack of versioned interceptors
for asan and company. The interceptors bind to the earlier version of
sem_init rather than the latest version. For MIPS64el this causes an
accidental pass while MIPS64 big endian fails due reading back a
different 32bit word to what sem_init wrote when the test is corrected
to use 64bit atomics.

llvm-svn: 314100
2017-09-25 13:25:34 +00:00
Vitaly Buka dcbae8631f [ubsan] Fix assert.cc test by compiling it as C++
llvm-svn: 314057
2017-09-23 05:09:45 +00:00
Vitaly Buka 5b81dfc76e [ubsan] Replace CommonSanitizerReportMutex with ScopedErrorReportLock
Reviewers: eugenis, alekseyshl

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 314053
2017-09-23 02:47:21 +00:00
Vitaly Buka c3f431fba3 [ubsan] Support signal specific options in ubsan
Summary:
Part of https://github.com/google/sanitizers/issues/637

Standalone ubsan needs signal and sigaction handlers and interceptors.
Plugin mode should rely on parent tool.

Reviewers: eugenis, alekseyshl

Subscribers: kubamracek, llvm-commits, mgorny

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

llvm-svn: 314052
2017-09-23 02:47:11 +00:00
Vitaly Buka 1b73bde182 [lsan] Add __lsan_default_options
For consistency with asan, msan, tsan and ubsan.

llvm-svn: 314048
2017-09-22 23:49:49 +00:00
Vitaly Buka 15d7e604d9 [lsan] Deadly signal handler for lsan
Summary: Part of https://github.com/google/sanitizers/issues/637

Reviewers: eugenis, alekseyshl

Subscribers: llvm-commits, dberris, kubamracek, krytarowski

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

llvm-svn: 314041
2017-09-22 22:57:48 +00:00
Vitaly Buka a33e156f81 [sanitizer] Replace thread id with GetThreadSelf
This allows to avoid constructor parameter

llvm-svn: 314040
2017-09-22 22:36:21 +00:00
Vitaly Buka a18f2ebdea [sanitizer] Move ScopedErrorReportLock into libcdep version
llvm-svn: 314039
2017-09-22 22:36:11 +00:00
Francis Ricci 3aae099702 Fix fuchsia builds broken by r313999
llvm-svn: 314021
2017-09-22 19:22:08 +00:00
Vitaly Buka 1c06f9a127 [sanitizer] Replace AddressSanitizer with correct tool name
llvm-svn: 314015
2017-09-22 18:50:18 +00:00
Kuba Mracek 0e68358cbf Deflake the "xpc-race.mm" test.
llvm-svn: 314014
2017-09-22 18:49:56 +00:00
Vitaly Buka d8e18a4cf6 [sanitizer] Move report locking code from asan into common
llvm-svn: 314008
2017-09-22 18:32:05 +00:00
Vitaly Buka 03ac15fffb [asan] Fix unlocking order for CommonSanitizerReportMutex and reporting_thread_tid_
llvm-svn: 314007
2017-09-22 18:31:51 +00:00
Vitaly Buka 4a98c85008 [sanitizer] Move CommonSanitizerReportMutex from _print.cc to _common.cc
llvm-svn: 314006
2017-09-22 18:31:37 +00:00
Francis Ricci c007c42ee9 Fix windows buildbot broken by r313999
llvm-svn: 314001
2017-09-22 18:17:26 +00:00
Francis Ricci fbccb0a8d2 Removed platform-specific ifdefs from sanitizer_procmaps.h
Summary: Removed platform-specific ifdefs for linux, mac, freebsd and netbsd from sanitizer_procmaps.h

Patch by Yicheng Wang <yichengfb@fb.com>

Reviewers: kcc, kubamracek, alekseyshl, fjricci, vitalybuka

Reviewed By: fjricci, vitalybuka

Subscribers: vitalybuka, emaste, krytarowski, llvm-commits

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

llvm-svn: 313999
2017-09-22 17:48:24 +00:00
Kostya Kortchinsky 392480952c [scudo] Scudo thread specific data refactor, part 1
Summary:
We are going through an overhaul of Scudo's TSD, to allow for new platforms
to be integrated more easily, and make the code more sound.

This first part is mostly renaming, preferring some shorter names, correcting
some comments. I removed `getPrng` and `getAllocatorCache` to directly access
the members, there was not really any benefit to them (and it was suggested by
Dmitry in D37590).

The only functional change is in `scudo_tls_android.cpp`: we enforce bounds to
the `NumberOfTSDs` and most of the logic in `getTSDAndLockSlow` is skipped if we
only have 1 TSD.

Reviewers: alekseyshl, dvyukov, kcc

Reviewed By: dvyukov

Subscribers: llvm-commits, srhines

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

llvm-svn: 313987
2017-09-22 15:35:37 +00:00
Maxim Ostapenko d0d900d850 [asan/lsan] Trying to fix PPC64 and x380x buildbots after r313966
llvm-svn: 313974
2017-09-22 10:44:28 +00:00
Maxim Ostapenko c1f0b0ecab [asan/lsan] Trying to fix buildbots after r313966
llvm-svn: 313967
2017-09-22 08:23:16 +00:00
Maxim Ostapenko 9d016b773b [asan/lsan] Make LSan compliant with recovery mode when running on top of ASan
Don't overwrite exit code in LSan when running on top of ASan in recovery mode
to avoid breakage of users code due to found leaks.

Patch by Slava Barinov.

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

llvm-svn: 313966
2017-09-22 07:11:43 +00:00
Akira Hatanaka 475a38fc5c [tsan] Annotate function parameters with attribute 'noescape'.
This commit annotates the block parameters of the following functions
declared in compiler-rt with 'noescape':

- dispatch_sync
- dispatch_barrier_sync
- dispatch_once
- dispatch_apply

This is needed to commit the patch that adds support for 'noescape' in
clang (see https://reviews.llvm.org/D32210) since these functions are
annotated with 'noescape' in the SDK header files.

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

llvm-svn: 313929
2017-09-21 22:16:50 +00:00
Dean Michael Berris c14b5f210f [XRay][compiler-rt] Remove non-trivial globals from xray_log_interface.cc
Summary:
Remove dependency on std::unique_ptr<...> for the global representing
the installed XRay implementation.

Reviewers: dblaikie, kpw, pelikan

Subscribers: llvm-commits

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

llvm-svn: 313871
2017-09-21 10:16:56 +00:00
Vitaly Buka be88ae0eb0 [ubsan] Split ubsan_init_standalone
Summary:
On Linux we may need preinit_array in static lib and
ubsan_standalone_initializer in shared lib.

Reviewers: eugenis

Subscribers: kubamracek, llvm-commits, mgorny

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

llvm-svn: 313851
2017-09-21 00:35:22 +00:00
Vitaly Buka 08706542e9 [asan] Remove trailing spaces
llvm-svn: 313845
2017-09-21 00:14:17 +00:00
Vitaly Buka d0d025ef62 [asan] Remove "COLLISION" workaround for datarace in asan
"nested bug in the same thread" is not expected in case like this and was caused
by https://github.com/google/sanitizers/issues/858

llvm-svn: 313844
2017-09-21 00:11:30 +00:00
Vitaly Buka d7f0361ab1 [asan] Remove "rm -f" in tests where it was needed only because of >>
llvm-svn: 313843
2017-09-21 00:06:08 +00:00
Vitaly Buka 3191a2ac1f [asan] Fix nested error detection
Summary: Fixes https://github.com/google/sanitizers/issues/858

Reviewers: eugenis, dvyukov

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 313835
2017-09-20 23:27:38 +00:00
Vitaly Buka 8a65209d0b [asan] Try to fix windows test by fflush(stderr)
llvm-svn: 313728
2017-09-20 07:16:08 +00:00
Vitaly Buka cf096c2af3 [asan] Resolve FIXME by converting gtest into lit test
llvm-svn: 313727
2017-09-20 07:01:19 +00:00
Francis Ricci d327254b1b Set ANDROID when any android abi is used, not just androideabi
Reviewers: compnerd, beanz

Subscribers: srhines, mgorny, llvm-commits

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

Change-Id: Idab521f187aba18977818d91503763e0e9d3aa0e
llvm-svn: 313652
2017-09-19 17:56:27 +00:00
Francis Ricci ba064be7af Ensure that armhf builtins library is created when using an hf abi
Reviewers: beanz, compnerd

Reviewed By: compnerd

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

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

llvm-svn: 313650
2017-09-19 17:54:11 +00:00
Simon Dardis 3efb88695f [mips][compiler-rt] UnXFAIL test.
lsan and asan were reporting leaks caused by a glibc configuration issue.

llvm-svn: 313645
2017-09-19 17:26:02 +00:00
Petr Hosek 5995e71a37 [sanitizer] Don't define common ReportDeadlySignal on Fuchsia
This causes a linker error because of duplicate symbol since
ReportDeadlySignal is defined both in sanitizer_common_libcdep and
sanitizer_fuchsia.

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

llvm-svn: 313641
2017-09-19 17:00:22 +00:00
Vedant Kumar 515cffb8f6 [ubsan-minimal] Test exported symbol set against RTUBsan
Check that the symbol sets exported by the minimal runtime and the full
runtime match (making exceptions for special cases as needed).

This test uses some possibly non-standard nm options, and needs to
inspect the symbols in runtime dylibs. I haven't found a portable way to
do this, so it's limited to x86-64/Darwin for now.

llvm-svn: 313615
2017-09-19 06:46:36 +00:00
Vedant Kumar c539795bc3 [ubsan-minimal] Make the interface more compatible with RTUBSan
This eliminates a few inconsistencies between the symbol sets exported
by RTUBSan and RTUBSan_minimal:

  * Handlers for nonnull_return were missing from the minimal RT, and
    are now added in.

  * The minimal runtime exported recoverable handlers for
    builtin_unreachable and missing_return. These are not supposed to
    exist, and are now removed.

llvm-svn: 313614
2017-09-19 06:46:36 +00:00
Vedant Kumar 648752ab14 [profile] Update Linux-only tests after r313597
Addresses bot failure:
http://lab.llvm.org:8011/builders/clang-ppc64le-linux/builds/9803

llvm-svn: 313602
2017-09-19 00:15:18 +00:00
Vedant Kumar 4265d16d45 [profile] Update InstrProfData.inc
llvm-svn: 313599
2017-09-18 23:37:32 +00:00
Vitaly Buka 6863972b48 Revert "[ubsan] Split ubsan_init_standalone"
Breaks build.

This reverts commit r313583 and r313584.

llvm-svn: 313585
2017-09-18 22:47:36 +00:00
Vitaly Buka 3c1c34d5c5 [ubsan] Add file missing from r313583
llvm-svn: 313584
2017-09-18 22:43:28 +00:00
Vitaly Buka eb0c26168f [ubsan] Split ubsan_init_standalone
On Linux we may need preinit_array in static lib and
ubsan_standalone_initializer in shared lib.

llvm-svn: 313583
2017-09-18 22:38:18 +00:00
Vitaly Buka 59a1275be1 [ubsan] Fix conflict with previous declaration on Mac
llvm-svn: 313572
2017-09-18 21:35:49 +00:00
Kostya Kortchinsky 58c9a79bc2 [scudo] Additional modifications for Android tests support
Summary:
With the recent move of `android_commands` to `sanitizer_common`, some things
have to be updated with regard to Scudo on Android.

Notably:
- `config.android` is dealt with in the common code
- `config.compile_wrapper` can be prepended to allow for the use of the android
  commands
- `SCUDO_OPTIONS` must be passed with the environment when running a test
- `preinit.cpp` fails with some API levels, not sure why, I will have to dig
  into this later.

Note that `check-scudo` is not enabled yet in the bots. It's all local testing
for now until everything looks good.

Reviewers: alekseyshl, vitalybuka

Reviewed By: vitalybuka

Subscribers: srhines, kubamracek, llvm-commits

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

llvm-svn: 313561
2017-09-18 20:31:57 +00:00
Vitaly Buka a4f62c62d3 [ubsan] Fix interface_symbols_windows test
Summary:
1. Update ubsan_interface.inc to make the test happy.
2. Switch interface_symbols_linux and interface_symbols_darwin to C++ to import __ubsan_handle_dynamic_type_cache_miss
3. Switch interface_symbols_windows to C++ for consistency.

Reviewers: rnk, zturner

Subscribers: llvm-commits, kubamracek

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

llvm-svn: 313551
2017-09-18 18:46:19 +00:00
Vedant Kumar 4a10504e1f [cmake] Make it possible to build and test profile without sanitizers
This should fix an issue which arises when running check-compiler-rt on
the coverage bot:
http://green.lab.llvm.org/green/job/clang-stage2-coverage-R_build/1590/

The bot doesn't build the sanitizers, but the check-compiler-rt target
always expects the profile runtime to exist.

llvm-svn: 313549
2017-09-18 18:13:47 +00:00
Kostya Kortchinsky 8a0b40a8b3 [scudo] Android build support
Summary:
Mark Android as supported in the cmake configuration for Scudo.

Scudo is not added yet in the Android build bots, but code builds and tests
pass locally. It is for a later CL. I also checked that Scudo builds as part
of the Android toolchain.

A few modifications had to be made:
- Android defaults to `abort_on_error=1`, which doesn't work well with the
  current tests. So change the default way to pass `SCUDO_OPTIONS` to the tests
  to account for this, setting it to 0 by default;
- Disable the `valloc.cpp` & `random_shuffle.cpp` tests on Android;
- There is a bit of gymnatic to be done with the `SCUDO_TEST_TARGET_ARCH`
  string, due to android using the `-android` suffix, and `i686` instead of
  `i386`;
- Android doesn't need `-lrt`.

Reviewers: alekseyshl, eugenis

Reviewed By: alekseyshl

Subscribers: srhines, mgorny, llvm-commits

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

llvm-svn: 313538
2017-09-18 15:40:53 +00:00
Vitaly Buka e66dc01bbf Revert "[ubsan] Add RTUbsan_standalone into UBSAN standalone shared"
Error: .preinit_array section is not allowed in DSO

This reverts commit r313519.

llvm-svn: 313520
2017-09-18 08:15:00 +00:00
Vitaly Buka d2b4022c0b [ubsan] Add RTUbsan_standalone into UBSAN standalone shared
Same as for Apple.
This also fixes flags related tests on Android as without this flags are not
initialized.

llvm-svn: 313519
2017-09-18 08:04:03 +00:00
Vitaly Buka 7119b57a9d [sanitizer] Move StartReportDeadlySignal into sanitizer_common_libcdep
llvm-svn: 313518
2017-09-18 07:36:32 +00:00
Vitaly Buka 86dd088f4d [asan] Remove ScopedDeadlySignal
This is used only to make fast = true in GetStackTraceWithPcBpAndContext
on SANITIZER_FREEBSD and SANITIZER_NETBSD and can be done explicitly.

llvm-svn: 313517
2017-09-18 06:56:57 +00:00
Dean Michael Berris 484fe0a9fb [XRay][compiler-rt] Handle tail-call exits in the XRay runtime
Summary:
This change starts differentiating tail exits from normal exits. We also
increase the version number of the "naive" log to version 2, which will
be the starting version where these records start appearing. In FDR mode
we treat the tail exits as normal exits, and are thus subject to the
same treatment with regard to record unwriting.

Updating the version number is important to signal older builds of the
llvm-xray tool that do not deal with the tail exit records must fail
early (and that users should only use the llvm-xray tool built after
the support for tail exits to get accurate handling of these records).

Depends on D37964.

Reviewers: kpw, pelikan

Subscribers: llvm-commits

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

llvm-svn: 313515
2017-09-18 06:18:03 +00:00
Vitaly Buka 9b7657fbc4 [sanitizer] Use SI_ instead of SANITIZER_ in sanitizer_platform_interceptors
llvm-svn: 313505
2017-09-18 00:12:12 +00:00
Kuba Mracek 8db966a097 Mark various failing tests with "UNSUPPORTED: ios".
llvm-svn: 313498
2017-09-17 20:00:43 +00:00
Ulrich Weigand 6a38d4c7c7 [compiler-rt] Fix build break after r313277 on s390x
Commit r313277 moved IsStackOverflow to inside the SignalContext
class, but didn't update a code block in #ifdef s390x accordingly.

llvm-svn: 313480
2017-09-17 09:38:55 +00:00
Vitaly Buka 9f1c0d4970 [sanitizer] Fix check for i386 Android in lit tests
llvm-svn: 313452
2017-09-16 07:56:06 +00:00
Vitaly Buka 6c196978eb [sanitizer] Move signal interceptors from asan to sanitizer_common
Summary: Part of https://github.com/google/sanitizers/issues/637

Reviewers: eugenis, alekseyshl

Subscribers: srhines, kubamracek, llvm-commits

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

llvm-svn: 313449
2017-09-16 07:16:29 +00:00
Vitaly Buka 6979b85b79 [sanitizer] Disable sanitizer test which already fails on Android i386
llvm-svn: 313447
2017-09-16 07:08:23 +00:00