Commit Graph

7204 Commits

Author SHA1 Message Date
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
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
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
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
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 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 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 cf096c2af3 [asan] Resolve FIXME by converting gtest into lit test
llvm-svn: 313727
2017-09-20 07:01:19 +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 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 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
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
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