Commit Graph

13363 Commits

Author SHA1 Message Date
Zhuojia Shen 0c0eeb78eb [builtins] Add support for single-precision-only-FPU ARM targets.
This patch enables building compiler-rt builtins for ARM targets that
only support single-precision floating point instructions (e.g., those
with -mfpu=fpv4-sp-d16).

This fixes PR42838

Differential Revision: https://reviews.llvm.org/D90698
2020-11-12 15:10:48 +00:00
Jianzhou Zhao 3597fba4e5 Add a simple stack trace printer for DFSan
Reviewed-by: morehouse
Differential Revision: https://reviews.llvm.org/D91235
2020-11-11 19:00:59 +00:00
Nico Weber 6ab31eeb62 Revert "[hwasan] Fix Thread reuse."
This reverts commit e1eeb026e6.
Test fails: https://reviews.llvm.org/D91208#2388613
2020-11-11 09:56:21 -05:00
Evgenii Stepanov e1eeb026e6 [hwasan] Fix Thread reuse.
HwasanThreadList::DontNeedThread clobbers Thread::next_, breaking the
freelist. As a result, only the top of the freelist ever gets reused,
and the rest of it is lost.

Since the Thread object its associated ring buffer is only 8Kb, this is
typically only noticable in long running processes, such as fuzzers.

Fix the problem by switching from an intrusive linked list to a vector.

Differential Revision: https://reviews.llvm.org/D91208
2020-11-10 17:24:24 -08:00
Peter Collingbourne 0ae2ea8f83 hwasan: Bring back operator {new,delete} interceptors on Android.
It turns out that we can't remove the operator new and delete
interceptors on Android without breaking ABI, so bring them back
as forwards to the malloc and free functions.

Differential Revision: https://reviews.llvm.org/D91219
2020-11-10 16:05:24 -08:00
Ayshe Kuran 55ec2ba4bc Fix PR47973: Addressing integer division edge case with INT_MIN
Adjustment to integer division in int_div_impl.inc to avoid undefined behaviour that can occur as a result of having INT_MIN as one of the parameters.

Reviewed By: sepavloff

Differential Revision: https://reviews.llvm.org/D90218
2020-11-10 15:57:06 +00:00
Kostya Kortchinsky c955989046 [scudo][standalone] Simplify populateFreelist
`populateFreelist` was more complicated that it needed to be. We used
to call to `populateBatches` that would do some internal shuffling and
add pointers one by one to the batches, but ultimately this was not
needed. We can get rid of `populateBatches`, and do processing in
bulk. This doesn't necessarily make things faster as this is not on the
hot path, but it makes the function cleaner.

Additionally clean up a couple of items, like `UNLIKELY`s and setting
`Exhausted` to `false` which can't happen.

Differential Revision: https://reviews.llvm.org/D90700
2020-11-06 09:44:36 -08:00
Leonard Chan 71b0ee72bb [NFC] Add InitializePlatformCommonFlags for Fuchsia
https://reviews.llvm.org/D90811 is breaking our CI builders because
InitializePlatformCommonFlags is not defined. This just adds an empty definition.

This would've been caught on our upstream buildbot, but it's red at the moment
and most likely won't be sending out alert emails for recent failures.

Differential Revision: https://reviews.llvm.org/D90864
2020-11-05 10:39:51 -08:00
Peter Collingbourne ee7b629df2 scudo: Don't memset previously released cached pages in the secondary allocator.
There is no need to memset released pages because they are already
zero. On db845c, before:

BM_stdlib_malloc_free_default/131072      34562 ns        34547 ns        20258 bytes_per_second=3.53345G/s

after:

BM_stdlib_malloc_free_default/131072      29618 ns        29589 ns        23485 bytes_per_second=4.12548G/s

Differential Revision: https://reviews.llvm.org/D90814
2020-11-05 09:24:50 -08:00
Vy Nguyen 5cb378fab3 [sanitizers] Remove the test case involving `new int[0]`
Bionic doesn't acutally allocate any memory in this case, so there won't be a leak on Android.

Differential Revision: https://reviews.llvm.org/D90821
2020-11-05 09:16:45 -05:00
Adhemerval Zanella d025df3c1d [lsan] Disable some LSAN tests for arm-linux-gnueabi{hf}
The tests do not report the expected leak when issued with use_stack
or use_tls option equal to 0 on arm-linux-gnueabihf (ubuntu 18.04,
glibc 2.27).

This issue is being tracked by https://bugs.llvm.org/show_bug.cgi?id=48052
2020-11-05 08:32:53 -03:00
Adhemerval Zanella 0ad3cb8c26 [sanitizer] Assume getrandom might not be supported by the kernel
It was added on kernel 3.17.
2020-11-05 08:32:53 -03:00
Vitaly Buka 230efefdbc [NFC] Fix cpplint warnings 2020-11-04 22:56:08 -08:00
Vitaly Buka fbf7ccec02 [LSAN] Fix compilation error on MSVC 2020-11-04 22:32:49 -08:00
Vitaly Buka e62e0b1675 Revert "[LSAN] Fix preprocessor condition for MSVC"
Missread the error message. It was not the reason.

This reverts commit 2d041554d1.
2020-11-04 22:31:36 -08:00
Vitaly Buka 2d041554d1 [LSAN] Fix preprocessor condition for MSVC 2020-11-04 22:29:09 -08:00
Vitaly Buka 61e59ebfa6 [LSAN] Enabled only with __ANDROID_API__ >= 28
Code does not work as-is with emulated tls even if
lsan is disabled with runtime flag.
2020-11-04 22:18:05 -08:00
Vy Nguyen 9f9077d7d1 [sanitizers] Add missing definition
Fix breakages from https://reviews.llvm.org/D90811

http://lab.llvm.org:8011/#/builders/37/builds/471/steps/8/logs/stdio

Differential Revision: https://reviews.llvm.org/D90818
2020-11-05 00:24:36 -05:00
Vitaly Buka 234857f730 [sanitizer] Fix -fno-emulated-tls setup
COMPILER_RT_TEST_COMPILER_CFLAGS is a string
2020-11-04 19:23:28 -08:00
Vitaly Buka 6c164d6080 [NFC] Extract InitializePlatformCommonFlags
And move some Android specifi declarations from headers

Differential Revision: https://reviews.llvm.org/D90811
2020-11-04 19:23:28 -08:00
Vy Nguyen 796650d990 [lsan] Remove unnecessary elf-tls condition
Differential Revision: https://reviews.llvm.org/D90808
2020-11-04 22:21:40 -05:00
Vitaly Buka bbd4ebffd4 [sanitizer] Quick fix for non-Linux build 2020-11-04 18:35:04 -08:00
Vitaly Buka e15f424cf9 [LSAN] Fix CAN_SANITIZE_LEAKS on Android 2020-11-04 18:35:04 -08:00
Vy Nguyen 484ec6be30 Reland [lsan] Enable LSAN for Android
Reland: a2291a58bf.

New fixes for the breakages reported in D85927 include:
 - declare a weak decl for `dl_iterate_phdr`, because it does not exist on older  APIs
 - Do not enable leak-sanitizer if api_level is less than 29, because of  `ld.lld: error: undefined symbol: __aeabi_read_tp` for armv7, API level 16.
 - Put back the interceptor for `memalign` but still opt out intercepting `__libc_memalign` and `cfree` because both of these don't exist in Bionic.

Reviewed By: srhines, vitalybuka

Differential Revision: https://reviews.llvm.org/D89251
2020-11-04 18:00:25 -08:00
Vy Nguyen 678edfc1f3 [sanitizer] Allow preinit array on Android
Extracted from D89251
2020-11-04 16:46:10 -08:00
Vitaly Buka a52852f694 [NFC][sanitizer] Reformat some code
Extracted from D89251
2020-11-04 15:37:48 -08:00
Vitaly Buka 09ec07827b [sanitizer] Get Android API from --target
Depends on D90792.

Differential Revision: https://reviews.llvm.org/D90793
2020-11-04 14:05:44 -08:00
Vitaly Buka 7960ba3c49 [NFC][LSAN] Remove unused variable
Depends on D90791.

Differential Revision: https://reviews.llvm.org/D90792
2020-11-04 14:02:28 -08:00
Vitaly Buka 90e5b7b8be [NFC] Fix comment in test
Differential Revision: https://reviews.llvm.org/D90790
2020-11-04 14:02:28 -08:00
Vy Nguyen 6b67e22ea3 Fix breakage in D89615 (due to cmake version 3.16.5)
Differential Revision: https://reviews.llvm.org/D90764
2020-11-04 11:19:01 -05:00
Vy Nguyen 6855a60fd6 [NFC]Remove unused variable
Accidentally committed in D89615
2020-11-04 09:54:07 -05:00
Vy Nguyen aa662f61de Disable emulated-tls for compiler-rt+tests on Android if ELF_TLS is presence.
This is necessary for enabling LSAN on Android (D89251) because:
 - LSAN will have false negatives if run with emulated-tls.
 - Bionic ELF-TLS is not compatible with Gold (hence the need for LLD)

Differential Revision: https://reviews.llvm.org/D89615
2020-11-04 09:49:45 -05:00
Vitaly Buka 985a5d970a [NFC][UBSAN] Replace "count 0" with FileCheck
Unrelated system warnings may confuse "check 0"
2020-11-04 02:36:13 -08:00
Vitaly Buka e86205680e [sanitizer] Remove ANDROID_NDK_VERSION 2020-11-04 01:15:25 -08:00
Vitaly Buka 9c31e12609 [sanitizer] Remove -Wno-non-virtual-dtor
Warning should be fixed with d48f2d7c02
2020-11-04 00:51:33 -08:00
Vy Nguyen 707d69ff32 Use LLD for Android compiler-rt
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D90720
2020-11-04 00:51:18 -08:00
Petr Hosek e0b5e5a9d8 [compiler-rt] Use empty SuspendedThreadsList for Fuchsia
d48f2d7 made destructor of SuspendedThreadsList protected, so we need
an empty subclass to pass to the callback now.

Differential Revision: https://reviews.llvm.org/D90695
2020-11-03 11:34:13 -08:00
Vitaly Buka 4cd0927306 [memprof] Don't protect destructor in final 2020-11-03 11:33:33 -08:00
etiotto e1af54296c [compiler-rt][profile][AIX]: Enable compiler-rt profile build on AIX
This patch adds support for building the compiler-rt profile library on AIX.

Reviewed by: phosek

Differential Revision: https://reviews.llvm.org/D90619
2020-11-03 11:46:21 -05:00
Martin Storsjö 076d351e8b [compiler-rt] [ubsan] Use the itanium type info lookup for mingw targets
Differential Revision: https://reviews.llvm.org/D90571
2020-11-03 09:59:08 +02:00
Vitaly Buka d48f2d7c02 [sanitizer] Cleanup -Wnon-virtual-dtor warnings 2020-11-02 20:30:50 -08:00
Vitaly Buka 8b37a4e6ca [sanitizer] Make destructors protected 2020-11-02 18:00:43 -08:00
Alex Lorenz 701456b523 [darwin] add support for __isPlatformVersionAtLeast check for if (@available)
The __isPlatformVersionAtLeast routine is an implementation of `if (@available)` check
that uses the _availability_version_check API on Darwin that's supported on
macOS 10.15, iOS 13, tvOS 13 and watchOS 6.

Differential Revision: https://reviews.llvm.org/D90367
2020-11-02 16:28:09 -08:00
Kostya Kortchinsky b3420adf5a [scudo][standalone] Code tidying (NFC)
- we have clutter-reducing helpers for relaxed atomics that were barely
  used, use them everywhere we can
- clang-format everything with a recent version

Differential Revision: https://reviews.llvm.org/D90649
2020-11-02 16:00:31 -08:00
Kostya Kortchinsky 98fe39df93 [GWP-ASan] Stub out backtrace/signal functions on Fuchsia
The initial version of GWP-ASan on Fuchsia doesn't support crash and
signal handlers, so this just adds empty stubs to be able to compile
the project on the platform.

Differential Revision: https://reviews.llvm.org/D90537
2020-11-02 13:49:50 -08:00
Teresa Johnson 7f32ddc99b [MemProf] Reenable test with fix for bot failures
The issue was unexpected macro expansion when the bot's test output
directory contained a token matching a build system macro (e.g.
"linux"). Switch to using a hardcoded path, which is invalid but is
sufficient for ensuring that the path is passed down to the runtime.

Differential Revision: https://reviews.llvm.org/D90466
2020-11-02 09:00:04 -08:00
Jim Lin 1bd433bdff [compiler-rt][NFC] Fix typo in comment 2020-11-02 13:05:03 +08:00
Teresa Johnson 0949f96dc6 [MemProf] Pass down memory profile name with optional path from clang
Similar to -fprofile-generate=, add -fmemory-profile= which takes a
directory path. This is passed down to LLVM via a new module flag
metadata. LLVM in turn provides this name to the runtime via the new
__memprof_profile_filename variable.

Additionally, always pass a default filename (in $cwd if a directory
name is not specified vi the = form of the option). This is also
consistent with the behavior of the PGO instrumentation. Since the
memory profiles will generally be fairly large, it doesn't make sense to
dump them to stderr. Also, importantly, the memory profiles will
eventually be dumped in a compact binary format, which is another reason
why it does not make sense to send these to stderr by default.

Change the existing memprof tests to specify log_path=stderr when that
was being relied on.

Depends on D89086.

Differential Revision: https://reviews.llvm.org/D89087
2020-11-01 17:38:23 -08:00
Kostya Kortchinsky 63ad087656 [GWP-ASan] Fuchsia specific mapping & utilities functions
This CL introduces the Fuchsia versions of the existing platform
specific functions.

For Fuchsia, we need to track the VMAR (https://fuchsia.dev/fuchsia-src/reference/kernel_objects/vm_address_region)
of the Guarded Pool mapping, and for this purpose I added some platform
specific data structure that remains empty on POSIX platforms.

`getThreadID` is not super useful for Fuchsia so it's just left as a
stub for now.

While testing the changes in my Fuchsia tree, I realized that
`guarded_pool_allocator_tls.h` should have closed the namespace before
including `GWP_ASAN_PLATFORM_TLS_HEADER`, otherwise drama ensues.

This was tested in g3, upstream LLVM, and Fuchsia (with local changes).

Differential Revision: https://reviews.llvm.org/D90483
2020-10-31 10:22:58 -07:00
Vitaly Buka f9dd0166f1 [sanitizer] Disabled 2 tests on Android
They block bot upgrade to NDK 21.
2020-10-31 03:56:52 -07:00