Commit Graph

9451 Commits

Author SHA1 Message Date
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
Vitaly Buka cd2d9a6b98 [sanitizer] Support check-asan on Android
This patch enabled asan tests from sanitizer_common.

llvm-svn: 313444
2017-09-16 05:14:05 +00:00
Vitaly Buka 0dc3ef3734 [sanitizer] Move android_commoands from asan into sanitizer_common
llvm-svn: 313443
2017-09-16 05:13:56 +00:00
Vitaly Buka 011aec2cf1 [builtins] Remove one more missed not-android
llvm-svn: 313441
2017-09-16 03:47:19 +00:00
Vitaly Buka 20d78186c2 [asan] Remove not-android
Replaced with !android

llvm-svn: 313440
2017-09-16 03:41:16 +00:00
Vitaly Buka 3d8c362f94 Revert "[ubsan] Update ubsan_interface.inc"
This brakes interface_symbols_linux.c test.

This reverts commit r313432.

llvm-svn: 313439
2017-09-16 03:26:12 +00:00
Vitaly Buka 581fbc61b2 [asan] Enable asan_and_llvm_coverage_test.cc on Android
Test just needs profile.

llvm-svn: 313438
2017-09-16 03:26:03 +00:00
Vitaly Buka 3ab63e34f6 [ubsan] Update ubsan_interface.inc
llvm-svn: 313432
2017-09-16 01:21:04 +00:00
Peter Collingbourne 823bb7eff6 Try to fix check-asan.
llvm-svn: 313423
2017-09-15 23:37:22 +00:00
Kostya Serebryany 80e9a6ccd1 [libFuzzer] add linux-specific test for gc-sections
llvm-svn: 313421
2017-09-15 23:07:18 +00:00
Kostya Serebryany ad66fefdca [libFuzzer] test fix
llvm-svn: 313411
2017-09-15 22:29:20 +00:00
Zachary Turner ce92db13ea Resubmit "[lit] Force site configs to run before source-tree configs"
This is a resubmission of r313270.  It broke standalone builds of
compiler-rt because we were not correctly generating the llvm-lit
script in the standalone build directory.

The fixes incorporated here attempt to find llvm/utils/llvm-lit
from the source tree returned by llvm-config.  If present, it
will generate llvm-lit into the output directory.  Regardless,
the user can specify -DLLVM_EXTERNAL_LIT to point to a specific
lit.py on their file system.  This supports the use case of
someone installing lit via a package manager.  If it cannot find
a source tree, and -DLLVM_EXTERNAL_LIT is either unspecified or
invalid, then we print a warning that tests will not be able
to run.

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

llvm-svn: 313407
2017-09-15 22:10:46 +00:00
Kostya Serebryany bcd78491ef [libFuzzer] minor refactoring, NFC
llvm-svn: 313406
2017-09-15 22:10:36 +00:00
Kostya Serebryany 97b8b2daff [libFuzzer] reduce the size of the merge control file by not dumping redundant features into it
llvm-svn: 313403
2017-09-15 22:02:26 +00:00
Peter Collingbourne d13d61fdb4 ubsan: Unbreak ubsan_cxx runtime library on Windows.
This was originally broken by r258744 which introduced a weak reference
from ubsan to ubsan_cxx. This reference does not work directly on
Windows because COFF has no direct concept of weak symbols. The fix is
to use /alternatename to create a weak external reference to ubsan_cxx.

Also fix the definition (and the name, so that we drop cached values)
of the cmake flag that controls whether to build ubsan_cxx. Now the
user-controllable flag is always on, and we turn it off internally
depending on whether we support building it.

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

llvm-svn: 313391
2017-09-15 20:24:12 +00:00
Peter Collingbourne a02c2eaf52 cfi: Enable ThinLTO tests on Windows.
We now avoid using absolute symbols on Windows (D37407 and D37408),
so this should work.

Fixes PR32770.

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

llvm-svn: 313379
2017-09-15 18:55:35 +00:00
Peter Collingbourne 7d218f7532 ubsan: Stop building the DLL version of the runtime library on Windows.
As far as I know we never use it.

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

llvm-svn: 313378
2017-09-15 18:54:37 +00:00
Petar Jovanovic 16807db3d4 [sanitizer][mips64] fix MIPS64 kernel_stat_to_stat()
This patch tackles with two issues:

Output stat st_[a|m|c]time fields were holding wrong values.
st_[a|m|c]time fields should have contained value of seconds and instead
these are filled with st_[a|m|c]time_nsec fields which hold nanoseconds.
Build fails for MIPS64 if SANITIZER_ANDROID. Recently <sys/stat.h> from
bionic introduced st_[a|m|c]time_nsec macros for compatibility with old NDKs
and those clashed with the field names of the <asm/stat.h> kernel_stat
structure.
To fix both issues and make sure sanitizer builds on all platforms, we must
un-define all compatibility macros and access the fields directly when
copying the 'time' fields.

Patch by Miodrag Dinic <miodrag.dinic@imgtec.com>

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

llvm-svn: 313360
2017-09-15 15:18:51 +00:00
Vitaly Buka 5fbd91df56 [ubsan] Extract GetStackTraceWithPcBpAndContext similar to asan version
llvm-svn: 313350
2017-09-15 08:11:53 +00:00
Dmitry Vyukov b63a3ab5bf tsan: respect LDFLAGS when build Go test
Reported at:
https://bugs.llvm.org/show_bug.cgi?id=27597

Some platforms need additional LDFLAGS when building the test
(e.g. -no-pie). Respect LDFLAGS.

llvm-svn: 313347
2017-09-15 06:51:37 +00:00
Vitaly Buka 3e45e10819 [sanitizer] Simplify checks in allow_user_segv.cc
llvm-svn: 313342
2017-09-15 04:48:02 +00:00
Vitaly Buka 461e8c1de8 [sanitizer] Use __sanitizer:: in CHECK_IMPL on both sides of assignment
llvm-svn: 313338
2017-09-15 04:05:15 +00:00
Zachary Turner 83dcb68468 Revert "[lit] Force site configs to run before source-tree configs"
This patch is still breaking several multi-stage compiler-rt bots.
I already know what the fix is, but I want to get the bots green
for now and then try re-applying in the morning.

llvm-svn: 313335
2017-09-15 02:56:40 +00:00
Vitaly Buka f716931bb2 [lsan] Disable clang-format on few RUN: statements
llvm-svn: 313321
2017-09-15 00:02:30 +00:00
Vitaly Buka 21ddc6219b [sanitizer] Move stack overflow and signal reporting from Asan into common.
Summary: Part of https://github.com/google/sanitizers/issues/637

Reviewers: eugenis, alekseyshl

Subscribers: kubamracek

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

llvm-svn: 313310
2017-09-14 22:44:03 +00:00
Vitaly Buka 846a217bfc [asan] Remove ErrorStackOverflow
Summary:
The only difference from ErrorDeadlySignal is reporting code and it lives in
sanitizer common.

Part of https://github.com/google/sanitizers/issues/637

Reviewers: eugenis, alekseyshl, filcab

Subscribers: llvm-commits, kubamracek

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

llvm-svn: 313309
2017-09-14 22:43:53 +00:00
Eric Fiselier 4aa0ecf86b [ASAN] Revert r313303 - Add macro denoting availability of new `__asan_handle_no_return()` function.
It was pointed out that compiler-rt has always defined the symbol, but only
recently added it to the public headers. Meaning that libc++abi can re-declare
it instead of needing this macro.

llvm-svn: 313306
2017-09-14 22:31:34 +00:00
Eric Fiselier 6892062f7c [ASAN] Add macro denoting availability of new `__asan_handle_no_return()` function.
Summary:
Libc++abi attempts to use the newly added `__asan_handle_no_return()` when built under ASAN. Unfortunately older versions of compiler-rt do not provide this symbol, and so libc++abi needs a way to detect if `asan_interface.h` actually provides the function.

This patch adds the macro `SANITIZER_ASAN_INTERFACE_HAS_HANDLE_NO_RETURN` which can be used to detect the availability of the new function.

Reviewers: phosek, kcc, vitalybuka, alekseyshl

Reviewed By: phosek

Subscribers: mclow.lists, cfe-commits

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

llvm-svn: 313303
2017-09-14 22:19:10 +00:00
Kostya Kortchinsky 26e689f0c5 [scudo] Fix bad request handling when allocator has not been initialized
Summary:
In a few functions (`scudoMemalign` and the like), we would call
`ScudoAllocator::FailureHandler::OnBadRequest` if the parameters didn't check
out. The issue is that if the allocator had not been initialized (eg: if this
is the first heap related function called), we would use variables like
`allocator_may_return_null` and `exitcode` that still had their default value
(as opposed to the one set by the user or the initialization path).

To solve this, we introduce `handleBadRequest` that will call `initThreadMaybe`,
allowing the options to be correctly initialized.

Unfortunately, the tests were passing because `exitcode` was still 0, so the
results looked like success. Change those tests to do what they were supposed
to.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: llvm-commits

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

llvm-svn: 313294
2017-09-14 20:34:32 +00:00
Simon Dardis b2388c52e8 Revert "[mips] Fix sem_init_glibc test for MIPS."
The commit did not fix the failing test and instead exposed an inconsistency
between lsan and (t|m|a)san. I'm reverting the patch as it causes more failures
and the original patch had a '||' instead of '&&', which meant that an N32 build
of test would have be incorrect w.r.t. __HAVE_64B_ATOMICS for glibc.

This reverts commit r313248.

llvm-svn: 313291
2017-09-14 19:58:04 +00:00
Vitaly Buka 2cda290ec8 [asan] Disable two dynamic tests on armhf
This is not an regression. Tests are old and we just recently started to
run them on bots with dynamic runtime.

llvm-svn: 313283
2017-09-14 18:19:28 +00:00
Zachary Turner a0e55b6403 [lit] Force site configs to be run before source-tree configs
This patch simplifies LLVM's lit infrastructure by enforcing an ordering
that a site config is always run before a source-tree config.

A significant amount of the complexity from lit config files arises from
the fact that inside of a source-tree config file, we don't yet know if
the site config has been run.  However it is *always* required to run
a site config first, because it passes various variables down through
CMake that the main config depends on.  As a result, every config
file has to do a bunch of magic to try to reverse-engineer the location
of the site config file if they detect (heuristically) that the site
config file has not yet been run.

This patch solves the problem by emitting a mapping from source tree
config file to binary tree site config file in llvm-lit.py. Then, during
discovery when we find a config file, we check to see if we have a
target mapping for it, and if so we use that instead.

This mechanism is generic enough that it does not affect external users
of lit. They will just not have a config mapping defined, and everything
will work as normal.

On the other hand, for us it allows us to make many simplifications:

* We are guaranteed that a site config will be executed first
* Inside of a main config, we no longer have to assume that attributes
  might not be present and use getattr everywhere.
* We no longer have to pass parameters such as --param llvm_site_config=<path>
  on the command line.
* It is future-proof, meaning you don't have to edit llvm-lit.in to add
  support for new projects.
* All of the duplicated logic of trying various fallback mechanisms of
  finding a site config from the main config are now gone.

One potentially noteworthy thing that was required to implement this
change is that whereas the ninja check targets previously used the first
method to spawn lit, they now use the second. In particular, you can no
longer run lit.py against the source tree while specifying the various
`foo_site_config=<path>` parameters.  Instead, you need to run
llvm-lit.py.

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

llvm-svn: 313270
2017-09-14 16:47:58 +00:00
Simon Dardis c720ee5914 [mips] Fix sem_init_glibc test for MIPS.
glibc changed the implementation of semaphores for glibc 2.21 requiring
some target specific changes for this compiler-rt test. Modify the test
to cope with MIPS64 and do some future/correctness work by tying the
define for MIPS64 to exactly the define of __HAVE_64B_ATOMICS in glibc.

Contributions from Nitesh Jain.

Reviewers: eugenis

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

llvm-svn: 313248
2017-09-14 10:36:04 +00:00
Vitaly Buka 561f5408c9 [sanitizer] Mark allow_user_segv as XFAIL instead of UNSUPPORTED
llvm-svn: 313241
2017-09-14 08:15:13 +00:00
Vitaly Buka 62f02d5247 [sanitizer] Add empty Fuchsia and Win versions of StartReportDeadlySignal
llvm-svn: 313240
2017-09-14 08:14:56 +00:00
Vitaly Buka 2b077ecb91 [lsan] Extract GetStackTraceWithPcBpAndContext similar to asan version
llvm-svn: 313239
2017-09-14 08:14:38 +00:00
Vitaly Buka 9a4c73e20c [sanitizer] Move IsStackOverflow into SignalContext
llvm-svn: 313227
2017-09-14 03:23:02 +00:00
Vitaly Buka 5d53e050ca [sanitizer] Add BufferedStackTrace::Reset()
llvm-svn: 313226
2017-09-14 03:06:35 +00:00
Vitaly Buka 9c1fa35e5f [asan] Add const into ScarinessScoreBase::Print
llvm-svn: 313225
2017-09-14 03:06:20 +00:00
Vitaly Buka cd851f8085 [compiler-rt] Fix Windows build
llvm-svn: 313224
2017-09-14 02:58:18 +00:00
Vitaly Buka 73c101613d [compiler-rt] Cleanup SignalContext initialization
Reviewers: eugenis, alekseyshl

Subscribers: kubamracek, dberris

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

llvm-svn: 313223
2017-09-14 02:48:41 +00:00
Vedant Kumar afe2bdd773 [ubsan-minimal] Filter targets to test by host arch on Darwin
This reverts r313189, and adds a use of darwin_filter_host_archs() for
ubsan-minimal.

llvm-svn: 313206
2017-09-13 21:57:47 +00:00
Zachary Turner 1929ffd452 Revert "Determine up front which projects are enabled."
This was intended to be a generic CMake solution to a problem
shared across several projects.  It turns out it doesn't interact
very well certain CMake configurations, and furthermore the
"problem" is actually not a problem, as the problematic code
is never executed to begin with.  So this really isn't solving
anything.

llvm-svn: 313191
2017-09-13 20:49:25 +00:00
Vedant Kumar cb835d3fdb [ubsan-minimal] Temporarily disable x86_64h testing on Darwin
We're seeing strange issues on the public GreenDragon Darwin bots which
we don't understand. x86_64h tests are still being run on pre-Haswell
bots despite the added checks in test/ubsan_minimal/lit.common.cfg,
which were verified on our internal bots.

I'm unable to ssh into the affected public bot, so for now am trying a
more aggressive check which disables all x86_64h testing for
ubsan-minimal on Darwin.

rdar://problem/34409349

llvm-svn: 313189
2017-09-13 20:46:26 +00:00
Vitaly Buka 72e8b55bab [asan] Fix Windows build
llvm-svn: 313177
2017-09-13 19:39:06 +00:00
Vitaly Buka dbde6f337c [compiler-rt] Use SignalContext in ErrorStackOverflow and ErrorDeadlySignal
Summary: Part of https://github.com/google/sanitizers/issues/637

Reviewers: eugenis, alekseyshl, filcab

Subscribers: kubamracek, llvm-commits, dberris

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

llvm-svn: 313168
2017-09-13 18:30:16 +00:00
Vitaly Buka b215e90fb0 [compiler-rt] Add siginfo into SignalContext
Summary:
Information stored there is often been passed along with SignalContext.

Part of https://github.com/google/sanitizers/issues/637

Reviewers: eugenis, alekseyshl

Subscribers: kubamracek, llvm-commits, dberris

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

llvm-svn: 313167
2017-09-13 18:30:06 +00:00
Vitaly Buka c40f5ceca0 [compiler-rt] Compile signal specific functions only for !SANITIZER_GO
llvm-svn: 313130
2017-09-13 08:10:16 +00:00
Vitaly Buka 6570c1d8b8 [compiler-rt] Add test for not fully implemented dump_registers
Reviewers: eugenis, alekseyshl

Subscribers: kubamracek, dberris, llvm-commits

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

llvm-svn: 313120
2017-09-13 06:33:43 +00:00
Vitaly Buka 20562abc1c Fix line breaks.
llvm-svn: 313118
2017-09-13 06:25:09 +00:00
Vitaly Buka ecc44ecdbc [compiler-rt] Move dump_instruction_bytes and dump_registers into sanitizer_common
Summary: Part of https://github.com/google/sanitizers/issues/637

Reviewers: eugenis, alekseyshl

Subscribers: kubamracek, llvm-commits, dberris

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

llvm-svn: 313117
2017-09-13 06:24:59 +00:00
Vitaly Buka d9d2a89e50 [compiler-rt] Move *Sanitizer:DEADLYSIGNAL printing into common part
Summary: Part of https://github.com/google/sanitizers/issues/637

Reviewers: eugenis, alekseyshl

Subscribers: kubamracek, llvm-commits, dberris

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

llvm-svn: 313115
2017-09-13 04:46:37 +00:00
Petr Hosek d8328f13ac [Fuchsia] Magenta -> Zircon
Fuchsia's lowest API layer has been renamed from Magenta to Zircon.

Patch by Roland McGrath

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

llvm-svn: 313106
2017-09-13 01:18:15 +00:00
Vitaly Buka 97ec1451a8 [compiler-rt] Move IsStackOverflow into sanitizer_posix_libcdep.cc to the rest
of instrumentation code.

llvm-svn: 313100
2017-09-13 00:24:44 +00:00
Vedant Kumar 5fb5094a4a [ubsan] Enable -fsanitize=function test on Darwin
Differential Revision: https://reviews.llvm.org/D37598

llvm-svn: 313097
2017-09-13 00:04:35 +00:00
Zachary Turner c7fc93946c Determine up front which projects are enabled.
Some projects need to add conditional dependencies on other projects.
compiler-rt is already doing this, and I attempted to add this to
debuginfo-tests when I ran into the ordering problem, that you can't
conditionally add a dependency unless that dependency's CMakeLists.txt
has already been run (which would allow you to say if (TARGET foo).

The solution to this seems to be to determine very early on the entire
set of projects which is enabled. This is complicated by the fact that
there are multiple ways to enable projects, and different tree layouts
(e.g. mono-repo, out of -tree, external, etc). This patch attempts to
centralize all of this into one place, and then updates compiler-rt to
demonstrate as a proof of concept how this can simplify code.

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

llvm-svn: 313091
2017-09-12 23:32:34 +00:00
Kostya Serebryany 93679be037 [libFuzzer] factor out some code into GetSizedFilesFromDir; NFC
llvm-svn: 313081
2017-09-12 21:58:07 +00:00
Vitaly Buka 2890105eab [tsan] Disable user_malloc test which fails glibc 2.24
llvm-svn: 313069
2017-09-12 20:03:39 +00:00
Vedant Kumar 57e8a2e504 [ubsan-minimal] Fix the x86_64h config check
Checking if config.target_arch is x86_64h doesn't work (the 'h' suffix
is dropped here, and I didn't account for that). Instead, check to see
if '-arch x86_64h' is in the cflags.

Tested on a pre-Haswell bot.

rdar://problem/34378605

llvm-svn: 313053
2017-09-12 17:32:25 +00:00
Max Moroz 1a33da2401 [libFuzzer] Fix lit files to make running tests more straightforward on Mac OS.
Summary:
Current implementation does not work if CMAKE_OSX_SYSROOT is not specified.

It silently generates invalid command with the following flags:

`-std=c++11 -lc++ -gline-tables-only -isysroot  -fsanitize=address,fuzzer`

and then fails with the following error:

```
warning: no such sysroot directory: '-fsanitize=address,fuzzer' [-Wmissing-sysroot]"
<...>/RepeatedBytesTest.cpp:5:10: fatal error: 'assert.h' file not found
#include <assert.h>
         ^~~~~~~~~~
1 error generated.
```

However, if you have Command Line Tools installed, you have '/usr/include' dir.
In that case, it is not necessary to specify isysroot path.

Also, with the patch, in case of '/usr/include' does not exist, the '-sysroot'
path would be resolved automatically in compiler-rt/cmake/base-config-ix.cmake.

For more context, see the comment at `compiler-rt/cmake/base-config-ix.cmake#L76`

Reviewers: kcc, george.karpenkov

Reviewed By: kcc, george.karpenkov

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

llvm-svn: 313033
2017-09-12 15:02:10 +00:00
Max Moroz 3f26dac416 [libfuzzer] Compare TotalNumberOfRuns with MaxNumberOfRuns when testing a memory leak.
Summary:
Fuzzer::TryDetectingAMemoryLeak may call ExecuteCallback which would
increment TotalNumberOfRuns, but it doesn't respect Options.MaxNumberOfRuns
value specified by a user.

Context: https://github.com/google/oss-fuzz/issues/822#issuecomment-328153970

Reviewers: kcc

Reviewed By: kcc

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

llvm-svn: 312993
2017-09-12 02:01:54 +00:00
Dean Michael Berris d56b90fb4c [XRay][compiler-rt] Use a single global volatile recursion guard for FDR handlers
Summary:
Before this change, the recursion guard for the flight data recorder
(FDR) mode handlers were independent. This change makes it so that when
a handler is already in the process of running and somehow the same or
another handler starts running -- say in a signal handler, while the
XRay handler is executing -- then we can use the same thread-local
recursion guard to stop the second handler from running.

Reviewers: kpw, eizan

Subscribers: llvm-commits

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

llvm-svn: 312992
2017-09-12 01:37:59 +00:00
Vitaly Buka f6fc68c7d1 [compiler-rt] Move IsStackOverflow from asan into sanitizer_common
Summary: Part of https://github.com/google/sanitizers/issues/637

Reviewers: eugenis, alekseyshl

Subscribers: kubamracek, dberris, llvm-commits

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

llvm-svn: 312987
2017-09-12 00:44:23 +00:00
Vitaly Buka 7af8e4b146 Revert "[compiler-rt] Move IsStackOverflow from asan into sanitizer_common"
Windows is broken.

This reverts commit r312951

llvm-svn: 312984
2017-09-12 00:14:33 +00:00
Vedant Kumar 661e2422d7 [ubsan-minimal] Disable x86_64h tests when not on x86_64h
llvm-svn: 312982
2017-09-12 00:01:13 +00:00
Evgeniy Stepanov 93f2edc215 Runtime detection of android_set_abort_message.
Summary:
Use runtime detection (with a weak-undef symbol) of
android_set_abort_message availability. Android NDK provides a single
version of the ASan runtime library to be used for any target API
level, which makes compile-time feature detection impossible (the
library itself is built at API level 9).

Reviewers: vitalybuka

Subscribers: srhines, llvm-commits, kubamracek

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

llvm-svn: 312973
2017-09-11 23:27:58 +00:00
Vedant Kumar 7669679e82 [ubsan-minimal] Enable on Darwin
Testing: check-ubsan-minimal

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

llvm-svn: 312959
2017-09-11 21:37:53 +00:00
Vitaly Buka 54cc3603de [ubsan] Make ubsan version of __sanitizer_print_stack_trace consistent with other sanitizers
Summary: Other sanitizers include __sanitizer_print_stack_trace into stack trace.

Reviewers: eugenis, alekseyshl

Subscribers: llvm-commits, kubamracek

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

llvm-svn: 312954
2017-09-11 21:25:22 +00:00
Vitaly Buka bdcc82d7ed [ubsan] Save binary name before parsing options
Summary: To parser "include" we may need to do binary name substitution.

Reviewers: eugenis, alekseyshl

Subscribers: llvm-commits, kubamracek

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

llvm-svn: 312953
2017-09-11 21:13:06 +00:00
Vitaly Buka 4084a583d9 Revert "[ubsan] Save binary name before parsing options"
Patch was corrupted by rebase.

This reverts commit r312933

llvm-svn: 312952
2017-09-11 21:12:43 +00:00
Vitaly Buka ecba46d0e6 [compiler-rt] Move IsStackOverflow from asan into sanitizer_common
Summary: Part of https://github.com/google/sanitizers/issues/637

Reviewers: eugenis, alekseyshl

Subscribers: kubamracek, dberris, llvm-commits

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

llvm-svn: 312951
2017-09-11 21:00:24 +00:00
Vitaly Buka 36266b6b0d [compiler-rt] Cleanup decorators
Summary:
Removed redundant End*() methods which defined same way.
Removed redundant Warning() methods.

Reviewers: eugenis

Subscribers: kubamracek, llvm-commits, dberris

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

llvm-svn: 312950
2017-09-11 20:55:49 +00:00
Kostya Kortchinsky 040c211bc4 [scudo] Fix improper TSD init after TLS destructors are called
Summary:
Some of glibc's own thread local data is destroyed after a user's thread local
destructors are called, via __libc_thread_freeres. This might involve calling
free, as is the case for strerror_thread_freeres.
If there is no prior heap operation in the thread, this free would end up
initializing some thread specific data that would never be destroyed properly
(as user's pthread destructors have already been called), while still being
deallocated when the TLS goes away. As a result, a program could SEGV, usually
in __sanitizer::AllocatorGlobalStats::Unregister, where one of the doubly linked
list links would refer to a now unmapped memory area.

To prevent this from happening, we will not do a full initialization from the
deallocation path. This means that the fallback cache & quarantine will be used
if no other heap operation has been called, and we effectively prevent the TSD
being initialized and never destroyed. The TSD will be fully initialized for all
other paths.

In the event of a thread doing only frees and nothing else, a TSD would never
be initialized for that thread, but this situation is unlikely and we can live
with that.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: llvm-commits

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

llvm-svn: 312939
2017-09-11 19:59:40 +00:00
Vitaly Buka 87d1f9ce93 [asan] Include asan-dynamic into check-all
Summary: It's adds just 1k to about 45k tests.

Reviewers: eugenis, alekseyshl

Subscribers: kubamracek, mgorny, llvm-commits

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

llvm-svn: 312937
2017-09-11 19:41:17 +00:00
Vitaly Buka 57ff314368 [ubsan] Save binary name before parsing options
Summary: To parser "include" we may need to do binary name substitution.

Reviewers: eugenis, alekseyshl

Subscribers: llvm-commits, kubamracek

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

llvm-svn: 312933
2017-09-11 18:32:51 +00:00
Vitaly Buka f8e944121e [asan] Fix tests broken by r312858
llvm-svn: 312872
2017-09-09 20:07:45 +00:00
Vitaly Buka fd5960a653 [ubsan] Enable UBsan in sanitizer_common tests
Summary:
Failing tests just marked as UNSUPPORTED or XFAIL.
Some of them can be easily supported, but I'll do this in separate patches.

Reviewers: eugenis, alekseyshl

Subscribers: srhines, kubamracek, llvm-commits, mgorny

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

llvm-svn: 312860
2017-09-09 06:10:58 +00:00
Vitaly Buka b4f2d13dc6 [compiler-rt] Move allow_user_segv.cc into sanitizer_common
Summary: Part of https://github.com/google/sanitizers/issues/637

Reviewers: eugenis

Subscribers: kubamracek, dberris, llvm-commits

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

llvm-svn: 312859
2017-09-09 06:04:23 +00:00
Vitaly Buka e7e7194a73 [asan] Use more generic string in error message
Summary: Part of https://github.com/google/sanitizers/issues/637

Reviewers: eugenis, alekseyshl

Subscribers: llvm-commits, kubamracek

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

llvm-svn: 312858
2017-09-09 05:58:52 +00:00
Kostya Serebryany 25d6b95679 [libFuzzer] remove a couple of reduntant includes
llvm-svn: 312848
2017-09-09 00:56:34 +00:00
Francis Ricci f36d34a4d4 Revert "Prevent DCE on __lsan_is_turned_off and re-enable test case"
This doesn't fix the failing test. Leave in the comment and the
attribute, since the used attribute is still required.

This partially reverts commit r312824

llvm-svn: 312827
2017-09-08 21:09:43 +00:00
Francis Ricci 4a327e1c5c Prevent DCE on __lsan_is_turned_off and re-enable test case
Summary:
-dead_strip in ld64 strips weak interface symbols, which I believe
is most likely the cause of this test failure. Re-enable after marking the interface
function as used.

Reviewers: alekseyshl, kubamracek, kcc

Subscribers: llvm-commits

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

llvm-svn: 312824
2017-09-08 19:43:53 +00:00
Kostya Serebryany 754e584076 [libFuzzer] simplify CustomCrossOverTest even more
llvm-svn: 312697
2017-09-07 05:33:05 +00:00
Kostya Serebryany 57c03648e1 [libFuzzer] simplify CustomCrossOverTest a bit more
llvm-svn: 312695
2017-09-07 05:23:23 +00:00
Kostya Serebryany d0386fac26 [libFuzzer] simplify and re-enable CustomCrossOverTest
llvm-svn: 312689
2017-09-07 02:04:06 +00:00
Vedant Kumar b6d2fe5c88 [cmake] Work around more -Wunused-driver-argument warnings
add_compiler_rt_object_libraries should strip out the -msse3 option on
non-macOS Apple platforms.

llvm-svn: 312688
2017-09-07 01:36:47 +00:00
Evgeniy Stepanov 7d1ab555ae [asan] Add a note to shadow memory setup error.
Point to https://github.com/google/sanitizers/issues/856 as a possible cause of the failed mapping.

llvm-svn: 312687
2017-09-07 01:35:59 +00:00
Kostya Kortchinsky 6bc7b26d18 [scudo] getauxval alternative for Android
Summary:
`getauxval` was introduced with API level 18. In order to get things to work
at lower API levels (for the toolchain itself which is built at 14 for 32-bit),
we introduce an alternative implementation reading directly from
`/proc/self/auxv`.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: srhines, llvm-commits

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

llvm-svn: 312653
2017-09-06 17:51:32 +00:00
Simon Dardis 10d0ae85dd [compiler-rt][xray][mips] Mark some tests as unsupported.
Thesee tests require the integrated assembler which is still in
development / testing for MIPS64. GAS doesn't understand the
section directives produced by XRay, so marking the relevant
tests as unsupported.

llvm-svn: 312628
2017-09-06 10:17:29 +00:00
Evgeniy Stepanov 9566d28997 [msan] Remove a stale fixme (NFC).
It was fixed in 312576.

llvm-svn: 312597
2017-09-06 00:28:52 +00:00
Petr Hosek 4f4bdc3c20 [sanitizer_common][Fuchsia] Update Fuchsia sanitizer markup
Include URLs to the markup format specification in code comments.
Use sanitizer markup in the sancov message about a dump just produced.

Patch by Roland McGrath

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

llvm-svn: 312596
2017-09-06 00:00:46 +00:00
Kostya Serebryany 79cdf36a2c [libFuzzer] remporary disable an unstable test
llvm-svn: 312593
2017-09-05 23:45:54 +00:00
Evgeniy Stepanov 29c7487167 Remove ld.config.txt for Android O.
ld.config.txt defines linker namespaces in a way that is incompatible
with ASan. Remove the file when installing ASan on an Android O
(8.0.x) device.

Patch by Jiyong Park.

llvm-svn: 312581
2017-09-05 21:51:20 +00:00
Evgeniy Stepanov 8b80b328d1 [msan] Check sigset_t and sigaction arguments.
Summary:
Check sigset_t arguments in ppoll, sig*wait*, sigprocmask
interceptors, and the entire "struct sigaction" in sigaction. This
can be done because sigemptyset/sigfullset are intercepted and
signal masks should be correctly marked as initialized.

Reviewers: vitalybuka

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 312576
2017-09-05 21:08:56 +00:00
Evgeniy Stepanov 00dedc208f (NFC) Fix the use of do{}while(0) in a macro.
llvm-svn: 312396
2017-09-02 00:09:57 +00:00
David Blaikie 387d0964ba Fix constant-logical-operand warning.
llvm-svn: 312394
2017-09-01 23:57:34 +00:00
Vedant Kumar f5addb18f2 [cmake] Remove accidentally committed warning messages
llvm-svn: 312393
2017-09-01 23:49:22 +00:00
Vedant Kumar 6b1de0e673 [cmake] Work around -Wunused-driver-argument warnings
Fix the Darwin logic so that -msse3 is only used on macOS, and
-fomit-frame-pointer is not used on armv7/armv7k/armv7s.

llvm-svn: 312390
2017-09-01 23:23:59 +00:00
Kostya Serebryany 07490f8415 [libFuzzer] use more iterations for a test
llvm-svn: 312356
2017-09-01 19:45:08 +00:00
George Karpenkov 2928375cd2 [libFuzzer] Enable 8-bit counters test on macOS
llvm-svn: 312339
2017-09-01 17:13:26 +00:00
Evgeniy Stepanov adfa21087f Revert "[ubsan] Make check-ubsan depend on check-ubsan-minimal."
Breaks buildbot with
CMake Error at projects/compiler-rt/test/CMakeLists.txt:76 (add_dependencies):
  The dependency target "check-ubsan-minimal" of target "check-ubsan" does
  not exist.

llvm-svn: 312295
2017-08-31 23:34:01 +00:00
Evgeniy Stepanov a865658a74 [ubsan] Make check-ubsan depend on check-ubsan-minimal.
Summary: This way we don't need to add check-ubsan-minimal steps to all the bots.

Reviewers: vitalybuka

Subscribers: mgorny, llvm-commits

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

llvm-svn: 312291
2017-08-31 22:26:34 +00:00
Kostya Serebryany 082e9a7528 [libFuzzer] tolerate missing files when loading the seed corpus
llvm-svn: 312269
2017-08-31 19:17:15 +00:00
Alex Lorenz 341317fda4 Revert r312240
The buildbots have shown that -Wstrict-prototypes behaves differently in GCC
and Clang so we should keep it disabled until Clang follows GCC's behaviour

llvm-svn: 312246
2017-08-31 15:51:23 +00:00
Alex Lorenz fbac1ae062 Build LLVM with -Wstrict-prototypes enabled
Clang 5 supports -Wstrict-prototypes. We should use it to catch any C
declarations that declare a non-prototype function.

rdar://33705313

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

llvm-svn: 312240
2017-08-31 13:23:24 +00:00