Commit Graph

13533 Commits

Author SHA1 Message Date
Matt Morehouse 3bd2ad5a08 [DFSan] Add several math functions to ABI list.
These are all straightforward functional entries.

Reviewed By: stephan.yichao.zhao

Differential Revision: https://reviews.llvm.org/D92791
2020-12-08 10:51:05 -08:00
Jeroen Dobbelaere d7e71b5db8 [compiler-rt santizer] Use clock_gettime instead of timespec_get
On RH66, timespec_get is not available. Use clock_gettime instead.

This problem was introduced with D87120

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D91687
2020-12-08 10:10:17 -08:00
Adhemerval Zanella db61b1844e [compiler-rt] [builtins] Support conversion between fp16 and fp128
This patch adds both extendhftf2 and trunctfhf2 to support
conversion between half-precision and quad-precision floating-point
values. They are built iff the compiler supports _Float16.

Some notes on ARM plaforms: while fp16 is supported on all
architectures, _Float16 is supported only for 32-bit ARM, 64-bit ARM,
and SPIR (as indicated by clang/docs/LanguageExtensions.rst). Also,
fp16 is a storage format and 64-bit ARM supports floating-point
convert precision to half as base armv8-a instruction.

This patch does not change the ABI for 32-bit ARM, it will continue
to pass _Float16 as uint16.

This re-enabled revert done by https://reviews.llvm.org/rGb534beabeed3ba1777cd0ff9ce552d077e496726

Differential Revision: https://reviews.llvm.org/D92242
2020-12-08 11:51:55 -03:00
Hafiz Abid Qadeer deec343bfd [compiler-rt] Allow appending to 'target_cflags' value from lit_config.
This patch is similar to D84708. When testing compiler-rt on different
baremetal targets, it helps to have the ability to pass some more parameters
at test time that allows you to build the test executable for a
given target. For an example, you may need a different linker command
file for different targets.

This patch will allows to do things like

$ llvm-lit --param=append_target_cflags="-T simulator.ld"
or
$ llvm-lit --param=append_target_cflags="-T hardware.ld"

In this way, you can run tests on different targets without having to run
cmake again.

Reviewed By: delcypher

Differential Revision: https://reviews.llvm.org/D91783
2020-12-08 11:46:36 +00:00
Mitch Phillips 1d03a54d94 Revert "[test] Fix asan/TestCases/Linux/globals-gc-sections-lld.cpp with -fsanitize-address-globals-dead-stripping"
This reverts commit 140808768d.

Reason: Broke the upstream bots - discussed offline.
2020-12-07 14:30:53 -08:00
Kazushi (Jam) Marukawa 414d3dc62c [VE][compiler-rt] Support VE in clear_cache.c
Support SX Aurora VE by __clear_cache() function.  This modification
allows VE to run written data, e.g. clear_cache_test.c under compiler-rt
test.  We still have code alignment problem in enable_execute_stack_test.c,
though.

Reviewed By: simoll

Differential Revision: https://reviews.llvm.org/D92703
2020-12-07 17:38:23 +09:00
Pavel Iliin 377ba7be93 [compiler-rt][AArch64] Put outline atomic helpers into dedicated dir.
Differential Revision: https://reviews.llvm.org/D92724
2020-12-07 00:28:09 +00:00
Fangrui Song 140808768d [test] Fix asan/TestCases/Linux/globals-gc-sections-lld.cpp with -fsanitize-address-globals-dead-stripping
r302591 dropped -fsanitize-address-globals-dead-stripping for ELF platforms
(to work around a gold<2.27 bug: https://sourceware.org/bugzilla/show_bug.cgi?id=19002)

Upgrade REQUIRES: from lto (COMPILER_RT_TEST_USE_LLD (set by Android, but rarely used elsewhere)) to lto-available.
2020-12-06 11:11:15 -08:00
Fangrui Song dde44f488c [test] Fix asan/TestCases/Posix/lto-constmerge-odr.cpp when 'binutils_lto' is avaiable
If COMPILER_RT_TEST_USE_LLD is not set, config.use_lld will be False.
However, if feature 'binutils_lto' is available, lto_supported can still be True,
but config.target_cflags will not get -fuse-ld=lld from config.lto_flags

As a result, we may use clang -flto with system 'ld' which may not support the bitcode file, e.g.

  ld: error: /tmp/lto-constmerge-odr-44a1ee.o: Unknown attribute kind (70) (Producer: 'LLVM12.0.0git' Reader: 'LLVM 12.0.0git')
  // The system ld+LLVMgold.so do not support ATTR_KIND_MUSTPROGRESS (70).

Just require lld-available and add -fuse-ld=lld.
2020-12-06 10:31:40 -08:00
Fangrui Song b00f345acd [asan][test] Fix odr-vtable.cpp 2020-12-05 19:30:41 -08:00
Benjamin Kramer 2a136a7a9c [X86] Autodetect znver3 2020-12-05 19:08:20 +01:00
Zhuojia Shen 24333481cb [builtins][ARM] Check __ARM_FP instead of __VFP_FP__.
This patch fixes builtins' CMakeLists.txt and their VFP tests to check
the standard macro defined in the ACLE for VFP support. It also enables
the tests to be built and run for single-precision-only targets while
builtins were built with double-precision support.

Differential revision: https://reviews.llvm.org/D92497
2020-12-04 20:53:23 -08:00
Fangrui Song 190b4374c0 [asan][test] Improve -asan-use-private-alias tests
In preparation for D92078
2020-12-04 15:05:59 -08:00
Jianzhou Zhao 80e326a8c4 [dfsan] Support passing non-i16 shadow values in TLS mode
This is a child diff of D92261.

It extended TLS arg/ret to work with aggregate types.

For a function
  t foo(t1 a1, t2 a2, ... tn an)
Its arguments shadow are saved in TLS args like
  a1_s, a2_s, ..., an_s
TLS ret simply includes r_s. By calculating the type size of each shadow
value, we can get their offset.

This is similar to what MSan does. See __msan_retval_tls and __msan_param_tls
from llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp.

Note that this change does not add test cases for overflowed TLS
arg/ret because this is hard to test w/o supporting aggregate shdow
types. We will be adding them after supporting that.

Reviewed-by: morehouse

Differential Revision: https://reviews.llvm.org/D92440
2020-12-04 02:45:07 +00:00
Adhemerval Zanella c288715e95 [compiler-rt] [builtins] Use _Float16 on extendhfsf2, truncdfhf2 __truncsfhf2 if available
On AArch64 it allows use the native FP16 ABI (although libcalls are
not emitted for fptrunc/fpext lowering), while on other architectures
the expected current semantic is preserved (arm for instance).

For testing the _Float16 usage is enabled by architecture base,
currently only for arm, aarch64, and arm64.

This re-enabled revert done by https://reviews.llvm.org/rGb534beabeed3ba1777cd0ff9ce552d077e496726

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D92241
2020-12-03 16:08:55 -03:00
Stella Stamenova 1410b72be3 [compiler-rt] Fix a bug in the cmakelists file when CMAKE_CXX_FLAGS are empty
Right now, the regex expression will fail if the flags were not set. Instead, we should follow the pattern of other llvm projects and quote the expression, so that it can work even when the flags are not set.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D92586
2020-12-03 10:25:52 -08:00
Martin Storsjö d3fef7a7c2 [compiler-rt] Fix building the aarch64 out-of-line atomics assembly for non-ELF platforms
Move the two different definitions of FUNC_ALIGN out of the ELF
specific block. Add the missing CFI_END in
END_COMPILERRT_OUTLINE_FUNCTION, to go with the corresponding CFI_START
in DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED.

Differential Revision: https://reviews.llvm.org/D92549
2020-12-03 15:31:06 +02:00
Vitaly Buka 20a2b1bf6b [NFC][sanitizer] Another attempt to fix test on arm 2020-12-02 18:36:02 -08:00
Kostya Kortchinsky 0a09c1cc9d [scudo][standalone] Add missing va_end() in ScopedString::append
In ScopedString::append va_list ArgsCopy is created but never cleanuped
which can lead to undefined behaviour, like stack corruption.

Reviewed By: cryptoad

Differential Revision: https://reviews.llvm.org/D92383
2020-12-02 16:10:50 -08:00
Jianzhou Zhao 6fa06628a7 [dfsan] Add test cases for struct/pair
This is a child diff of D92261.

This locks down the behavior before the change.
2020-12-02 21:25:23 +00:00
Pavel Iliin a4ac434c47 [AArch64] Compiler-rt interface for out-of-line atomics.
Out-of-line helper functions to support LSE deployment added.
This is a port of libgcc implementation:
https://gcc.gnu.org/git/?p=gcc.git;h=33befddcb849235353dc263db1c7d07dc15c9faa

Differential Revision: https://reviews.llvm.org/D91156
2020-12-02 20:07:12 +00:00
Roland McGrath 827e075676 [lsan] Use final on Fuchsia ThreadContext declaration
This is consistent with other platforms' versions and
eliminates a compiler warning.

Reviewed By: leonardchan

Differential Revision: https://reviews.llvm.org/D92442
2020-12-02 11:58:03 -08:00
Kostya Kortchinsky c904c32b9c [GWP-ASan] Fix flaky test on Fuchsia
The LateInit test might be reusing some already initialized thread
specific data if run within the main thread. This means that there
is a chance that the current value will not be enough for the 100
iterations, hence the test flaking.

Fix this by making the test run in its own thread.

Differential Revision: https://reviews.llvm.org/D92415
2020-12-02 09:00:51 -08:00
Vitaly Buka 1f3def16f6 [NFC][sanitizer] Fix test on 32bit platform 2020-12-02 07:32:40 -08:00
Ahsan Saghir 5045b831a3 [PowerPC] Mark sanitizer test case unsupported for powerpc64
The author of "https://reviews.llvm.org/D92428" marked
'resize_tls_dynamic.cpp' with XFAIL for powerpc64 since
it fails on a bunch of PowerPC buildbots. However, the
original test case passes on clang-ppc64le-rhel bot. So
marking this as XFAIL makes this bot to fail as the test
case passes unexpectedly. We are marking this unsupported
on all PowerPC64 for now until it is fixed for all the
PowerPC buildbots.
2020-12-02 09:03:28 -06:00
Vitaly Buka 3f0c4bfc64 [NFC][sanitizer] Fix ppc -> powerpc64 in XFAIL 2020-12-01 17:57:42 -08:00
Vitaly Buka bdd6718bef [NFC] Disable new test from D92428 on PPC TSAN 2020-12-01 16:54:14 -08:00
Vitaly Buka 8a300deb3e [sanitizer] Make DTLS_on_tls_get_addr signal safer
Avoid relocating DTV table and use linked list of mmap-ed pages.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D92428
2020-12-01 16:16:04 -08:00
Vitaly Buka adfefa5553 [NFC] Extract ForEachDVT 2020-12-01 16:15:32 -08:00
Alexey Baturo 17427ec3f3 [RISCV][crt] support building without init_array
Reviewed By: luismarques, phosek, kito-cheng

Differential Revision: https://reviews.llvm.org/D87997
2020-12-01 17:17:50 +03:00
Martin Storsjö 2e5aaf65a3 [compiler-rt] [emutls] Handle unused parameters in a compiler agnostic way
The MSVC specific pragmas disable this warning, but the pragmas themselves
(when not guarded by any _MSC_VER ifdef) cause warnings for other targets,
e.g. when targeting mingw.

Instead silence the MSVC warnings about unused parameters by casting
the parameters to void.

Differential Revision: https://reviews.llvm.org/D91851
2020-12-01 10:07:53 +02:00
Reid Kleckner b5af5787b3 [WinASan] Improve exception reporting accuracy
Previously, ASan would produce reports like this:
ERROR: AddressSanitizer: breakpoint on unknown address 0x000000000000 (pc 0x7fffdd7c5e86 ...)

This is unhelpful, because the developer may think this is a null
pointer dereference, and not a breakpoint exception on some PC.

The cause was that SignalContext::GetAddress would read the
ExceptionInformation array to retreive an address for any kind of
exception. That data is only available for access violation exceptions.
This changes it to be conditional on the exception type, and to use the
PC otherwise.

I added a variety of tests for common exception types:
- int div zero
- breakpoint
- ud2a / illegal instruction
- SSE misalignment

I also tightened up IsMemoryAccess and GetWriteFlag to check the
ExceptionCode rather than looking at ExceptionInformation[1] directly.

Differential Revision: https://reviews.llvm.org/D92344
2020-11-30 16:39:22 -08:00
Vy Nguyen 1b723a955d [sanitizer] Disable use_tls_dynamic on on-Android x86 Linux.
https://bugs.chromium.org/p/chromium/issues/detail?id=1153421

Differential Revision: https://reviews.llvm.org/D92273
2020-11-30 11:45:36 -05:00
Reid Kleckner b534beabee Revert builtins fp16 support: tests do not pass on Mac
Revert "[compiler-rt] [builtins] Support conversion between fp16 and fp128" & dependency

Revert "[compiler-rt] [builtins] Use _Float16 on extendhfsf2, truncdfhf2 __truncsfhf2 if available"

This reverts commit 7a94829881.

This reverts commit 1fb91fcf9c.
2020-11-25 16:12:49 -08:00
Luís Marques 1bc85cbbb8 [Sanitizer][RISCV] Fix redefinition of REG_SP
The include header sys/ucontext.h already defines REG_SP as 2, causing
redefinition warnings during compilation. This patch fixes that issue.
(We also can't just use the numerical definition provided by the header,
as REG_SP is used in this file this refers to a struct field.)

Differential Revision: https://reviews.llvm.org/D90934
2020-11-25 00:04:47 +00:00
Evgenii Stepanov 237b024b06 [hwasan] Fix tests when vm.overcommit_memory=1.
Remove an invalid check from sizes.cpp that only passes when overcommit is disabled.

Fixes PR48274.

Differential Revision: https://reviews.llvm.org/D91999
2020-11-23 16:05:56 -08:00
Martin Storsjö 33fb9679ec [compiler-rt] [profile] Silence a warning about an unused function on mingw targets
This function is only used within the ifdef below.

Differential Revision: https://reviews.llvm.org/D91850
2020-11-21 22:14:35 +02:00
Evgenii Stepanov 08d90f72ce [hwasan] Implement error report callback.
Similar to __asan_set_error_report_callback, pass the entire report to a
user provided callback function.

Differential Revision: https://reviews.llvm.org/D91825
2020-11-20 16:48:19 -08:00
Vitaly Buka 3b947cc8ce [msan] unpoison_file from fclose and fflash
Also unpoison IO_write_base/_IO_write_end buffer

memcpy from fclose and fflash can copy internal bytes without metadata into user memory.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D91858
2020-11-20 13:09:01 -08:00
Rainer Orth 03d593dd7e [sanitizers][test] Test sanitizer_common and ubsan_minimal on Solaris
During the initial Solaris sanitizer port, I missed to enable the
`sanitizer_common` and `ubsan_minimal` testsuites.  This patch fixes this,
correcting a few unportabilities:

- `Posix/getpass.cpp` failed to link since Solaris lacks `libutil`.
  Omitting the library lets the test `PASS`, but I thought adding `%libutil`
  along the lines of `%librt` to be overkill.
- One subtest of `Posix/getpw_getgr.cpp` is disabled because Solaris
  `getpwent_r` has a different signature than expected.
- `/dev/null` is a symlink on Solaris.
- XPG7 specifies that `uname` returns a non-negative value on success.

Tested on `amd64-pc-solaris2.11` and `sparcv9-sun-solaris2.11`.

Differential Revision: https://reviews.llvm.org/D91606
2020-11-20 14:06:25 +01:00
Rainer Orth 0f69cbe269 [sanitizer_common][test] Disable CombinedAllocator32Compact etc. on Solaris/sparcv9
As reported in PR 48202, two allocator tests `FAIL` on Solaris/sparcv9,
presumably because Solaris uses the full 64-bit address space and the
allocator cannot deal with that:

  SanitizerCommon-Unit :: ./Sanitizer-sparcv9-Test/SanitizerCommon.CombinedAllocator32Compact
  SanitizerCommon-Unit :: ./Sanitizer-sparcv9-Test/SanitizerCommon.SizeClassAllocator32Iteration

This patch disables the tests.

Tested on `sparcv9-sun-solaris2.11`.

Differential Revision: https://reviews.llvm.org/D91622
2020-11-20 13:02:15 +01:00
Rainer Orth ce6524d127 [sanitizer_common][test] Disable FastUnwindTest.* on SPARC
Many of the `FastUnwindTest.*` tests `FAIL` on SPARC, both Solaris and
Linux.  The issue is that the fake stacks used in those tests don't match
the requirements of the SPARC unwinder in `sanitizer_stacktrace_sparc.cpp`
which has to look at the register window save area.

I'm disabling the failing tests.

Tested on `sparcv9-sun-solaris2.11`.
Differential Revision: https://reviews.llvm.org/D91618
2020-11-20 12:52:18 +01:00
Jianzhou Zhao b4ac05d763 Replace the equivalent code by UnionTableAddr
UnionTableAddr is always inlined.

Reviewed-by: morehouse

Differential Revision: https://reviews.llvm.org/DD91758
2020-11-19 20:15:25 +00:00
Teresa Johnson a75b2e87e6 [MemProf] Add interface to dump profile
Add an interface so that the profile can be dumped on demand.

Differential Revision: https://reviews.llvm.org/D91768
2020-11-19 10:21:53 -08:00
Adhemerval Zanella 7a94829881 [compiler-rt] [builtins] Use _Float16 on extendhfsf2, truncdfhf2 __truncsfhf2 if available
On AArch64 it allows use the native FP16 ABI (although libcalls are
not emitted for fptrunc/fpext lowering), while on other architectures
the expected current semantic is preserved (arm for instance).

Differential Revision: https://reviews.llvm.org/D91733
2020-11-19 15:14:50 -03:00
Adhemerval Zanella 1fb91fcf9c [compiler-rt] [builtins] Support conversion between fp16 and fp128
This patch adds both extendhftf2 and trunctfhf2 to support
conversion between half-precision and quad-precision floating-point
values. They are enabled iff the compiler supports _Float16.

Some notes on ARM plaforms: while __fp16 is supported on all
architectures, _Float16 is supported only for 32-bit ARM, 64-bit ARM,
and SPIR (as indicated by clang/docs/LanguageExtensions.rst).  Also,
__fp16 is a storage format and promoted to 'float' for argument passing
and 64-bit ARM supports floating-point convert precision to half as
base armv8-a instruction.

It means that although extendhfsf2, truncdfhf2 __truncsfhf2 will be
built for 64-bit ARM, they will be never used in practice (compiler
won't emit libcall to them). This patch does not change the ABI for
32-bit ARM, it will continue to pass _Float16 as uint16.

Differential Revision: https://reviews.llvm.org/D91732
2020-11-19 15:14:50 -03:00
Teresa Johnson 8f778b283d [sanitizer_common] Add facility to get the full report path
Add a new interface __sanitizer_get_report_path which will return the
full path to the report file if __sanitizer_set_report_path was
previously called (otherwise it returns null). This is useful in
particular for memory profiling handlers to access the path which
was specified at compile time (and passed down via
__memprof_profile_filename), including the pid added to the path when
the file is opened.

There wasn't a test for __sanitizer_set_report_path, so I added one
which additionally tests the new interface.

Differential Revision: https://reviews.llvm.org/D91765
2020-11-19 09:19:12 -08:00
Evgenii Stepanov 523cc097fd [hwasan] Fix Thread reuse (try 2).
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 with 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/D91392
2020-11-18 16:04:08 -08:00
Vitaly Buka 0e2585c804 [tsan] Add pthread_cond_clockwait interceptor
Disable the test on old systems.
pthread_cond_clockwait is supported by glibc-2.30.
It also supported by Android api 30 even though we
do not run tsan on Android.

Fixes https://github.com/google/sanitizers/issues/1259

Reviewed By: dvyukov
2020-11-18 14:39:19 -08:00
Kostya Kortchinsky 5556616b5b [GWP-ASan] Port tests to Fuchsia
This modifies the tests so that they can be run on Fuchsia:
- add the necessary includes for `set`/`vector` etc
- do the few modifications required to use zxtest instead og gtest

`backtrace.cpp` requires stacktrace support that Fuchsia doesn't have
yet, and `enable_disable.cpp` currently uses `fork()` which Fuchsia
doesn't support yet. I'll revisit this later.

I chose to use `harness.h` to hold my "platform-specific" include and
namespace, and using this header in tests rather than `gtest.h`,
which I am open to change if someone would rather go another direction.

Differential Revision: https://reviews.llvm.org/D91575
2020-11-18 13:36:12 -08:00
Wolfgang Pieb 87369c6261 Revert "[tsan] Add pthread_cond_clockwait interceptor"
This reverts commit 16eb853ffd.

The test is failing on some Linux build bots. See the review for
an example.
2020-11-18 11:58:45 -08:00
Roland McGrath 7810d83786 [GWP-ASan] Respect GWP_ASAN_DEFAULT_ENABLED compile-time macro
If the containing allocator build uses -DGWP_ASAN_DEFAULT_ENABLED=false
then the option will default to false.  For e.g. Scudo, this is simpler
and more efficient than using -DSCUDO_DEFAULT_OPTIONS=... to set gwp-asan
options that have to be parsed from the string at startup.

Reviewed By: hctim

Differential Revision: https://reviews.llvm.org/D91463
2020-11-18 10:34:42 -08:00
Seonghyun Park 096bd9b293 [sanitizer] Fix typo in log messages
Fix typo in log messages

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D91492
2020-11-18 03:42:38 -08:00
Vitaly Buka 16eb853ffd [tsan] Add pthread_cond_clockwait interceptor
Fixes https://github.com/google/sanitizers/issues/1259

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D91684
2020-11-18 03:01:58 -08:00
Vitaly Buka 1c0ef2984d [NFC][tsan] Prepepare for more interceptors which use cond_wait() 2020-11-18 00:03:00 -08:00
Robert Underwood 16de50895e honor Python2_EXECUTABLE and Python3_EXECUTABLE when they are passed to cmake
CMake's find_package(Python3) and find_package(Python2) packages have a PYTHON_EXECUTABLE, Python2_EXECUTABLE, and Python3_EXECUTABLE cmake variables which control which version of python is built against.  As far as I can tell, the rest of LLVM honors these variables. This can cause the build process to fail when  if the automatically selected version of Python can't run due to modifications of LD_LIBRARY_PATH when using spack.  The corresponding Spack issue is https://github.com/spack/spack/issues/19908.  The corresponding LLVM issue is 48180

I believe an appropriate fix is to add the variables to the list of PASSTHROUGH_VARIABLES in cmake/Modules/AddCompilerRT.cmake, and this fixed compilation errors for me.

This bug affects distributions like Gentoo and package managers like Spack which allow for combinatorial versioning.

Reviewed By: Meinersbur

Differential Revision: https://reviews.llvm.org/D91536
2020-11-17 17:49:14 -06:00
Amy Huang bc98034040 [llvm-symbolizer] Add inline stack traces for Windows.
This adds inline stack frames for symbolizing on Windows.

Differential Revision: https://reviews.llvm.org/D88988
2020-11-17 13:19:13 -08:00
Vy Nguyen b16e4d3fc1 [sanitizers-test]add definition for %device_rm on android so it stops complaining
Differential Revision: https://reviews.llvm.org/D91570
2020-11-16 19:57:54 -05:00
Kostya Kortchinsky f0703cb1b2 [scudo][standalone] Correct min/max region indices
The original code to keep track of the minimum and maximum indices
of allocated 32-bit primary regions was sketchy at best.

`MinRegionIndex` & `MaxRegionIndex` were shared between all size
classes, and could (theoretically) have been updated concurrently. This
didn't materialize anywhere I could see, but still it's not proper.

This changes those min/max indices by making them class specific rather
than global: classes are locked when growing, so there is no
concurrency there. This also allows to simplify some of the 32-bit
release code, that now doesn't have to go through all the regions to
get the proper min/max. Iterate and unmap will no longer have access to
the global min/max, but they aren't used as much so this is fine.

Differential Revision: https://reviews.llvm.org/D91106
2020-11-16 12:43:10 -08:00
Jonathan Metzman 91703085f5 [fuzzer] Disable uncaught-exception on non-Win+undo bad fix
Test is failing on non-Windows platforms. Also undo speculative
fix since it causes failures on Windows.
2020-11-16 09:35:35 -08:00
Jonathan Metzman a3be128709 [fuzzer] Add allocator_may_return_null to uncaught-exception.test.
Speculative fix for failing unittest.
2020-11-16 09:13:25 -08:00
Matthew Malcomson 83ac18205e Hwasan reporting check for dladdr failing
In `GetGlobalSizeFromDescriptor` we use `dladdr` to get info on the the
current address.  `dladdr` returns 0 if it failed.
During testing on Linux this returned 0 to indicate failure, and
populated the `info` structure with a NULL pointer which was
dereferenced later.

This patch checks for `dladdr` returning 0, and in that case returns 0
from `GetGlobalSizeFromDescriptor` to indicate failure of identifying
the address.

This occurs when `GetModuleNameAndOffsetForPC` succeeds for some address
not in a dynamically loaded library.  One example is when the found
"module" is '[stack]' having come from parsing /proc/self/maps.

Differential Revision: https://reviews.llvm.org/D91344
2020-11-16 12:25:27 +00:00
Vitaly Buka 2ec25bae5a [NFC][tsan] Simplify call_pthread_cancel_with_cleanup 2020-11-16 04:21:27 -08:00
Vitaly Buka 7006738131 [sanitizer] Fix StackDepotPrint testing
Make test order agnostic as it can change with platform.
2020-11-16 03:07:29 -08:00
Vitaly Buka 581ebf44d2 [sanitizer] Fix setup of android-thread-properties-api 2020-11-14 23:23:10 -08:00
Vitaly Buka dd0b8b94d0 [sanitizer] Add timeouts for adb calls 2020-11-14 18:43:45 -08:00
Vitaly Buka e51631ca4c [sanitizer] Fix Android API level parsing on arm 2020-11-14 01:54:45 -08:00
Vitaly Buka c8f4e06b29
[sanitizer] Fix test on arm 32bit
Make test values suitable for PC alignment arithmetic used
in StackTrace::Print().
2020-11-14 00:02:29 -08:00
Roland McGrath 6ef07111a4 [scudo/standalone] Fix leak in ThreadedGlobalQuarantine test
This unit test code was using malloc without a corresponding free.
When the system malloc is not being overridden by the code under
test, it might an asan/lsan allocator that notices leaks.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D91472
2020-11-13 22:24:44 -08:00
Joe Pletcher f897e82bfd [fuzzer] Add Windows Visual C++ exception intercept
Adds a new option, `handle_winexcept` to try to intercept uncaught
Visual C++ exceptions on Windows. On Linux, such exceptions are handled
implicitly by `std::terminate()` raising `SIBABRT`. This option brings the
Windows behavior in line with Linux.

Unfortunately this exception code is intentionally undocumented, however
has remained stable for the last decade. More information can be found
here: https://devblogs.microsoft.com/oldnewthing/20100730-00/?p=13273

Reviewed By: morehouse, metzman

Differential Revision: https://reviews.llvm.org/D89755
2020-11-12 13:11:14 -08:00
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
Petr Hosek 11efd002b1 [CMake] Avoid accidental C++ standard library dependency in sanitizers
While sanitizers don't use C++ standard library, we could still end
up accidentally including or linking it just by the virtue of using
the C++ compiler. Pass -nostdinc++ and -nostdlib++ to avoid these
accidental dependencies.

Reviewed By: smeenai, vitalybuka

Differential Revision: https://reviews.llvm.org/D88922
2020-10-31 02:37:38 -07:00
Arthur Eubanks 5c31b8b94f Revert "Use uint64_t for branch weights instead of uint32_t"
This reverts commit 10f2a0d662.

More uint64_t overflows.
2020-10-31 00:25:32 -07:00
Petr Hosek d11710dae6 [NFC][CMake] Move some COMPILER_RT variables setup
Part of D88922
2020-10-30 20:09:50 -07:00
Petr Hosek 59d5031591 [CMake] Add -fno-rtti into tsan unittests
And some other NFC parts of D88922
2020-10-30 20:03:38 -07:00
Petr Hosek 6db314e86b [CMake] Remove cxx-headers from runtime deps
Part of D88922
2020-10-30 20:03:38 -07:00
Petr Hosek ed4fbe6d9c [CMake] Replace ctime with time.h in memprof
Part of D88922
2020-10-30 20:02:53 -07:00
Peter Collingbourne 3859fc653f AArch64: Switch to x20 as the shadow base register for outlined HWASan checks.
From a code size perspective it turns out to be better to use a
callee-saved register to pass the shadow base. For non-leaf functions
it avoids the need to reload the shadow base into x9 after each
function call, at the cost of an additional stack slot to save the
caller's x20. But with x9 there is also a stack size cost, either
as a result of copying x9 to a callee-saved register across calls or
by spilling it to stack, so for the non-leaf functions the change to
stack usage is largely neutral.

It is also code size (and stack size) neutral for many leaf functions.
Although they now need to save/restore x20 this can typically be
combined via LDP/STP into the x30 save/restore. In the case where
the function needs callee-saved registers or stack spills we end up
needing, on average, 8 more bytes of stack and 1 more instruction
but given the improvements to other functions this seems like the
right tradeoff.

Unfortunately we cannot change the register for the v1 (non short
granules) check because the runtime assumes that the shadow base
register is stored in x9, so the v1 check still uses x9.

Aside from that there is no change to the ABI because the choice
of shadow base register is a contract between the caller and the
outlined check function, both of which are compiler generated. We do
need to rename the v2 check functions though because the functions
are deduplicated based on their names, not on their contents, and we
need to make sure that when object files from old and new compilers
are linked together we don't end up with a function that uses x9
calling an outlined check that uses x20 or vice versa.

With this change code size of /system/lib64/*.so in an Android build
with HWASan goes from 200066976 bytes to 194085912 bytes, or a 3%
decrease.

Differential Revision: https://reviews.llvm.org/D90422
2020-10-30 12:51:30 -07:00
Dmitry Vyukov 00da38ce2d tsan: add Go race detector support for macOS/ARM64
Add Go race detector support for macOS/ARM64. The Go counterpart is https://golang.org/cl/266373 .

Author: cherry (Cherry Zhang)
Reviewed-in: https://reviews.llvm.org/D90435
2020-10-30 19:42:48 +01:00
Arthur Eubanks 10f2a0d662 Use uint64_t for branch weights instead of uint32_t
CallInst::updateProfWeight() creates branch_weights with i64 instead of i32.
To be more consistent everywhere and remove lots of casts from uint64_t
to uint32_t, use i64 for branch_weights.

Reviewed By: davidxl

Differential Revision: https://reviews.llvm.org/D88609
2020-10-30 10:03:46 -07:00
Louis Dionne 75a1f52c1a [compiler-rt] Don't include libc++ headers from the source tree in MSAN
We shouldn't be including the libc++ headers from the source tree directly, since those headers are not configured (i.e. they don't use the __config_site) header like they should, which could mean up to ABI differences

Reviewed By: vitalybuka, phosek, ldionne

Differential Revision: https://reviews.llvm.org/D89915
2020-10-30 02:36:02 -07:00
Dmitry Vyukov 26c1ced41c [sanitizer] Use __atomic_load/store() built-ins for generic 32-bit targets
Simplifies the code and fixes the build on SPARC.
See discussion in: http://lists.llvm.org/pipermail/llvm-dev/2020-October/145937.html

Author: glaubitz (John Paul Adrian Glaubitz)
Reviewed-in: https://reviews.llvm.org/D89940
2020-10-30 09:17:46 +01:00
Kostya Kortchinsky 3591721ada [GWP-ASan] Add mutexes for Fuchsia
Mitch expressed a preference to not have `#ifdef`s in platform agnostic
code, this change tries to accomodate this.

I am not attached to the method this CL proposes, so if anyone has a
suggestion, I am open.

We move the platform specific member of the mutex into its own platform
specific class that the main `Mutex` class inherits from. Functions are
implemented in their respective platform specific compilation units.

For Fuchsia, we use the sync APIs, as those are also the ones being
used in Scudo.

Differential Revision: https://reviews.llvm.org/D90351
2020-10-29 15:51:13 -07:00
Adhemerval Zanella f93c2b64ed [sanitizer] Disable ASLR for release_shadow_space
On aarch64 with kernel 4.12.13 the test sporadically fails with

RSS at start: 1564, after mmap: 103964, after mmap+set label: 308768, \
after fixed map: 206368, after another mmap+set label: 308768, after \
munmap: 206368
release_shadow_space.c.tmp: [...]/release_shadow_space.c:80: int \
main(int, char **): Assertion `after_fixed_mmap <= before + delta' failed.

It seems on some executions the memory is not fully released, even
after munmap.  And it also seems that ASLR is hurting it by adding
some fragmentation, by disabling it I could not reproduce the issue
in multiple runs.
2020-10-29 16:09:03 -03:00
Teresa Johnson d124ac0c22 [MemProf] Temporarily disable test failing on a couple bots
I finally see why this test is failing (on now 2 bots). Somehow the path
name is getting messed up, and the "linux" converted to "1". I suspect
there is something in the environment causing the macro expansion in the
test to get messed up:

http://lab.llvm.org:8011/#/builders/112/builds/555/steps/5/logs/FAIL__MemProfiler-x86_64-linux__log_path_test_cpp
http://lab.llvm.org:8011/#/builders/37/builds/275/steps/31/logs/stdio

On the avr bot:
-DPROFILE_NAME_VAR="/home/buildbot/llvm-avr-linux/llvm-avr-linux/stage1/projects/compiler-rt/test/memprof/X86_64LinuxConfig/TestCases/Output/log_path_test.cpp.tmp.log2"

after macros expansions becomes:
/home/buildbot/llvm-avr-1/llvm-avr-1/stage1/projects/compiler-rt/test/memprof/X86_64LinuxConfig/TestCases/Output/log_path_test.cpp.tmp.log2

Similar (s/linux/1/) on the other bot.

Disable it while I investigate
2020-10-29 11:26:21 -07:00
Jody Sankey 5a3077f3a7 [sanitizer][fuchsia] Avoid deprecated syscall.
The zx_clock_get syscall on Fuchsia is deprecated - ref
https://fuchsia.dev/fuchsia-src/reference/syscalls/clock_get
This changes to the recommended replacement; calling zx_clock_read on
the userspace UTC clock.

Reviewed By: mcgrathr, phosek

Differential Revision: https://reviews.llvm.org/D90169
2020-10-29 10:51:59 -07:00
Teresa Johnson 240b421738 [MemProf] Augment test to debug avr bot failure
After 81f7b96ed0, I can see that the
reason this test is failing on llvm-avr-linux is that it doesn't think
the directory exists (error comes during file open for write command).
Not sure why since this is the main test Output directory and we created
a different file there earlier in the test from the same file open
invocation. Print directory contents in an attempt to debug.
2020-10-29 10:04:43 -07:00
Teresa Johnson 81f7b96ed0 [sanitizer] Print errno for report file open failure
To help debug failures, specifically the llvm-avr-linux bot failure from
5c20d7db9f2791367b9311130eb44afecb16829c:

http://lab.llvm.org:8011/#/builders/112/builds/407/steps/5/logs/FAIL__MemProfiler-x86_64-linux-dynamic__log_path_t

Also re-enable the failing test which I temporarily disabled, to
see if this change will help identify why that particular log file can't
be opened for write on that bot (when another log file in the same
directory could earlier in the test).

Differential Revision: https://reviews.llvm.org/D90120
2020-10-29 08:47:30 -07:00
Vitaly Buka 20a3931f8f Revert "[NFC][TSAN] Logs to debug test script on bot"
Done with debugging. Script didn't work because of low limit on open
files on the bot.

This reverts commit 220293da53.
2020-10-29 01:11:16 -07:00
Cameron Finucane 6777919d5a [libFuzzer] Remove InterruptHandler from Fuchsia implementation
As implemented, the `InterruptHandler` thread was spinning trying to
`select()` on a null "stdin", wasting a significant amount of CPU for no
benefit. As Fuchsia does not have a native concept of stdin (or POSIX
signals), this commit simply removes this feature entirely.

Reviewed By: aarongreen

Differential Revision: https://reviews.llvm.org/D89266
2020-10-29 00:02:31 -07:00
Peter Collingbourne 864b3a336b Reland "hwasan: Disable operator {new,delete} interceptors when interceptors are disabled."
There was a discrepancy in the gn build which is now fixed.

Differential Revision: https://reviews.llvm.org/D89827
2020-10-28 15:42:23 -07:00
Kostya Kortchinsky 90678f65ae [GWP-ASan] Abstract the thread local variables access
In a similar fashion to D87420 for Scudo, this CL introduces a way to
get thread local variables via a platform-specific reserved TLS slot,
since Fuchsia doesn't support ELF TLS from the libc itself.

If needing to use this, a platform will have to define
`GWP_ASAN_HAS_PLATFORM_TLS_SLOT` and provide `gwp_asan_platform_tls_slot.h`
which will define a `uint64_t *getPlatformGwpAsanTlsSlot()` function
that will return the TLS word of storage.

I snuck in a couple of cleanup items as well, moving some static
functions to anonymous namespace for consistency.

Differential Revision: https://reviews.llvm.org/D90195
2020-10-28 15:06:38 -07:00
Vitaly Buka 220293da53 [NFC][TSAN] Logs to debug test script on bot 2020-10-28 11:40:16 -07:00
Ulrich Weigand a998cae021 [compiler-rt][SystemZ] Skip fuzzer/full-coverage.test
This test is currently marked as XFAIL on s390x, but it is randomly
passing, causing build bot issues.  Setting as UNSUPPORTED for now.
2020-10-28 16:39:46 +01:00
Vitaly Buka d1b9c0fd1d [NFC][Sanitizer] format sanitizer_platform_interceptors.h 2020-10-28 00:39:58 -07:00
Vitaly Buka 48bc38f254 [NFC][Asan] Fix cpplint warning in test 2020-10-28 00:38:50 -07:00
Vitaly Buka 2a6b156311 [NFC][Asan] Fix cpplint warnings in tests 2020-10-28 00:32:44 -07:00
Vitaly Buka 8ecf1c4969 [NFC][UBSAN] Try to re-enable tests on IOS
Looks like the reason they were disabled is the same as for Android
and it's fixed by 776a15d8ae
2020-10-27 23:49:31 -07:00
Vitaly Buka 58828f6a93 [NFC][UBSAN] Remove XFAIL from fixed tests 2020-10-27 23:43:50 -07:00
Nico Weber 2a4e704c92 Revert "Use uint64_t for branch weights instead of uint32_t"
This reverts commit e5766f25c6.
Makes clang assert when building Chromium, see https://crbug.com/1142813
for a repro.
2020-10-27 09:26:21 -04:00
Alex Richardson 89031cffd1 Fix sancov.py when objdump is llvm-objdump
The sanitizer-coverage.cpp test case was always failing for me. It turns
out the reason for this is that I was building with
-DLLVM_INSTALL_BINUTILS_SYMLINKS=ON and sancov.py's grep regex does not
handle llvm-objdump's disassembly format (hex immediates have a leading "0x").
While touching those lines also change them to use raw string literals since
invalid escape sequnces will become an error in future python versions.
Also simplify the code by using subprocess.check_output() instead of Popen().
This also works with python2.

Fixes https://bugs.llvm.org/show_bug.cgi?id=44504

Reviewed By: #sanitizers, vitalybuka

Differential Revision: https://reviews.llvm.org/D89648
2020-10-27 12:16:46 +00:00