Commit Graph

1976 Commits

Author SHA1 Message Date
Kostya Serebryany 99259ee40c [asan] fix __sanitizer_cov_with_check to get the correct caller PC. Before this fix the code relied on the fact that the other function (__sanitizer_cov) is inlined. This was true with clang builds on x86, but not true with gcc builds on x86 and on PPC. This caused bot redness after r292862
llvm-svn: 292998
2017-01-25 01:14:24 +00:00
Kostya Serebryany d843cd55b5 [asan] temporarily disable parts of a test that fail after r292862
llvm-svn: 292994
2017-01-24 23:58:21 +00:00
Kuba Mracek e4c1dd2c08 [tsan] Enable ignore_noninstrumented_modules=1 on Darwin by default
TSan recently got the "ignore_noninstrumented_modules" flag, which disables tracking of read and writes that come from noninstrumented modules (via interceptors). This is a way of suppressing false positives coming from system libraries and other noninstrumented code. This patch turns this on by default on Darwin, where it's supposed to replace the previous solution, "ignore_interceptors_accesses", which disables tracking in *all* interceptors. The new approach should re-enable TSan's ability to find races via interceptors on Darwin.

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

llvm-svn: 292981
2017-01-24 21:37:50 +00:00
Greg Parker 200ead56c6 [test] Prevent false detection of an `UNSUPPORTED:` directive by lit.
llvm-svn: 292902
2017-01-24 09:20:50 +00:00
Evgeniy Stepanov 0f550c8176 Revert "[lsan] Enable LSan for x86 Linux."
Breaks tests on i686/Linux due to missing clang driver support:
  error: unsupported option '-fsanitize=leak' for target 'i386-unknown-linux-gnu'

llvm-svn: 292844
2017-01-23 22:52:31 +00:00
Maxim Ostapenko 2523faf677 [lsan] Enable LSan for x86 Linux.
People keep asking LSan to be available on 32 bit targets (e.g. https://github.com/google/sanitizers/issues/403)
despite the fact that false negative ratio might be huge (up to 85%). This happens for big real world applications
that may contain random binary data (e.g. browser), but for smaller apps situation is not so terrible and LSan still might be useful.
This patch adds initial support for x86 Linux (disabled by default), ARM32 is in TODO list.
We used this patch (well, ported to GCC) on our 32 bit mobile emulators and it worked pretty fine
thus I'm posting it here to initiate further discussion.

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

llvm-svn: 292775
2017-01-23 08:45:17 +00:00
Marcos Pividori 440e641566 Revert "[interception] Check for export table's size before referring to its elements."
This reverts commit r292747 because cmake fails for some archs.

llvm-svn: 292751
2017-01-22 03:30:14 +00:00
Marcos Pividori 4e12600c90 [interception] Check for export table's size before referring to its elements.
This fix a bug, when calling InternalGetProcAddress() for an executable that
doesn't export any symbol. So the table is empty.
If we don't check for this condition, the program fails with Error 0xc0000142.

Also, I add a regression test for Windows.

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

llvm-svn: 292747
2017-01-22 02:14:57 +00:00
Michal Gorny b81980a376 [test] Fix page address logic in clear_cache_test
Fix the logic used to calculate page boundaries in clear_cache_test to
use correct masks -- e.g. -4096 rather than -4095. The latter gives
incorrect result since:

  -4095 -> 0xfffff001
  -4096 -> 0xfffff000 (== ~4095)

The issue went unnoticed so far because the array alignment caused
the last bit not to be set. However, on 32-bit x86 no such alignment is
enforced and the wrong page address caused the test to fail.

Furthermore, obtain the page size from the system instead of hardcoding
4096.

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

llvm-svn: 292729
2017-01-21 21:55:00 +00:00
Kostya Kortchinsky a00b9229c3 [scudo] Replacing std::atomic with Sanitizer's atomics
Summary:
In an effort to getting rid of dependencies to external libraries, we are
replacing atomic PackedHeader use of std::atomic with Sanitizer's
atomic_uint64_t, which allows us to avoid -latomic.

Reviewers: kcc, phosek, alekseyshl

Reviewed By: alekseyshl

Subscribers: llvm-commits

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

llvm-svn: 292630
2017-01-20 18:32:18 +00:00
Kuba Mracek 245318cb05 [lit] Limit parallelism of sanitizer tests on Darwin [compiler-rt part, take 2]
Running lit tests and unit tests of ASan and TSan on macOS has very bad performance when running with a high number of threads. This is caused by xnu (the macOS kernel), which currently doesn't handle mapping and unmapping of sanitizer shadow regions (reserved VM which are several terabytes large) very well. The situation is so bad that increasing the number of threads actually makes the total testing time larger. The macOS buildbots are affected by this. Note that we can't easily limit the number of sanitizer testing threads without affecting the rest of the tests.

This patch adds a special "group" into lit, and limits the number of concurrently running tests in this group. This helps solve the contention problem, while still allowing other tests to run in full, that means running lit with -j8 will still with 8 threads, and parallelism is only limited in sanitizer tests.

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

llvm-svn: 292549
2017-01-20 00:25:01 +00:00
Alex Shlyapnikov a8ba9c8e66 Whenever reasonable, merge ASAN quarantine batches to save memory.
Summary:
There are cases when thread local quarantine drains almost empty
quarantine batches into the global quarantine. The current approach leaves
them almost empty, which might create a huge memory overhead (each batch
is 4K/8K, depends on bitness).

Reviewers: eugenis

Subscribers: kubabrecka, llvm-commits

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

llvm-svn: 292525
2017-01-19 22:15:54 +00:00
Serge Rogatch 9bce1e7553 [XRay][Arm] Enable back XRay testing on Arm32 and fix the failing tests
Summary:
Testing of XRay was occasionally disabled on 32-bit Arm targets (someone assumed that XRay was supported on 64-bit targets only). This patch should fix that problem. Also here the instruction&data cache incoherency problem is fixed, because it may be causing a test to fail.
This patch is one of a series: see also
- https://reviews.llvm.org/D28624

Reviewers: dberris, rengolin

Reviewed By: rengolin

Subscribers: llvm-commits, aemerson, rengolin, dberris, iid_iunknown

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

llvm-svn: 292517
2017-01-19 20:27:11 +00:00
Renato Golin 8f03fbe678 Revert "[XRay][Arm] Enable back XRay testing on Arm32 and fix the failing tests"
This reverts commit r292211, as it broke the Thumb buldbot with:

clang-5.0: error: the clang compiler does not support '-fxray-instrument
on thumbv7-unknown-linux-gnueabihf'

llvm-svn: 292356
2017-01-18 09:07:35 +00:00
Michal Gorny 7b97bf233f [test] [builtins] Remove obsolete/UB tests in __fixuns?fdi based
Remove the failing tests for __fixunssfdi() and __fixunsdfdi() that
relied on undefined (and most likely obsolete in terms of compiler-rt
implementation behavior).

Both tests presumed that 0x1.p+64 would be converted to
0xFFFFFFFFFFFFFFFFLL, that is the largest value in uint64 range.
However, the C/C++ standards do not specify the behavior for converting
a floating-point value to an integer of smaller range, and in this case
both libgcc and compiler-rt implementations return 0 instead.

Since the current behavior is correct with regards to standards
and there is no good way of expressing 0xFFFFFFFFFFFFFFFFLL in single-
or double-precision float, I've removed the failing test altogether.

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

llvm-svn: 292257
2017-01-17 21:08:25 +00:00
Kuba Mracek 5da6f6db9a Revert r292232.
llvm-svn: 292236
2017-01-17 18:06:07 +00:00
Kuba Mracek a802a50963 [lit] Limit parallelism of sanitizer tests on Darwin [compiler-rt part]
Running lit tests and unit tests of ASan and TSan on macOS has very bad performance when running with a high number of threads. This is caused by xnu (the macOS kernel), which currently doesn't handle mapping and unmapping of sanitizer shadow regions (reserved VM which are several terabytes large) very well. The situation is so bad that increasing the number of threads actually makes the total testing time larger. The macOS buildbots are affected by this. Note that we can't easily limit the number of sanitizer testing threads without affecting the rest of the tests.

This patch adds a special "group" into lit, and limits the number of concurrently running tests in this group. This helps solve the contention problem, while still allowing other tests to run in full, that means running lit with -j8 will still with 8 threads, and parallelism is only limited in sanitizer tests.

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

llvm-svn: 292232
2017-01-17 17:18:18 +00:00
Serge Rogatch 1bcd53f0e7 [XRay][Arm] Enable back XRay testing on Arm32 and fix the failing tests
Summary:
Testing of XRay was occasionally disabled on 32-bit Arm targets (someone assumed that XRay was supported on 64-bit targets only). This patch should fix that problem. Also here the instruction&data cache incoherency problem is fixed, because it may be causing a test to fail.
This patch is one of a series: see also
- https://reviews.llvm.org/D28624

Reviewers: dberris, rengolin

Reviewed By: rengolin

Subscribers: llvm-commits, aemerson, rengolin, dberris, iid_iunknown

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

llvm-svn: 292211
2017-01-17 11:53:38 +00:00
Alex Shlyapnikov c4427a3976 ASAN activate/deactive controls thread_local_quarantine_size_kb option.
Summary:
Bypass quarantine altogether when quarantine size is set ot zero.
Also, relax atomic load/store of quarantine parameters, the
release/acquire semantics is an overkill here.

Reviewers: eugenis

Subscribers: kubabrecka, llvm-commits, mehdi_amini

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

llvm-svn: 291791
2017-01-12 18:51:25 +00:00
Alex Shlyapnikov c83efa85e2 Repoison the entire ASan chunk if it is not in active use.
Summary:
Repoisoning just the minimal redzones might leave an unpoisoned
gap of the size of the actual redzone minus minimal redzone size.
After ASan activation the actual redzone might be bigger than the minimal
size and ASan allocator assumes that the chunk returned by the common
allocator is either entirely poisoned or entirely not poisoned (it's too
expensive to check the entire chunk or always poison one).

Reviewers: eugenis

Subscribers: kubabrecka, llvm-commits

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

llvm-svn: 291714
2017-01-11 22:10:35 +00:00
Kuba Mracek e7709560ea [tsan] Implement a 'ignore_noninstrumented_modules' flag to better suppress false positive races
On Darwin, we currently use 'ignore_interceptors_accesses', which is a heavy-weight solution that simply turns of race detection in all interceptors. This was done to suppress false positives coming from system libraries (non-instrumented code), but it also silences a lot of real races. This patch implements an alternative approach that should allow us to enable interceptors and report races coming from them, but only if they are called directly from instrumented code.

The patch matches the caller PC in each interceptors. For non-instrumented code, we call ThreadIgnoreBegin.

The assumption here is that the number of instrumented modules is low. Most likely there's only one (the instrumented main executable) and all the other modules are system libraries (non-instrumented).

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

llvm-svn: 291631
2017-01-11 00:54:26 +00:00
Rong Xu af2f1dbde8 [PGO] Update the test cases after r291588.
llvm-svn: 291594
2017-01-10 20:07:01 +00:00
Serge Rogatch 4ab7a30538 [XRay][AArch64] An attempt to fix test patching-unpatching.cc by flushing the instruction cache after code modification
Summary: This patch attempts to fix test patching-unpatching.cc . The new code flushes the instruction cache after modifying the program at runtime.

Reviewers: dberris, rengolin, pelikan, rovka

Subscribers: rovka, llvm-commits, iid_iunknown, aemerson

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

llvm-svn: 291568
2017-01-10 16:16:33 +00:00
Diana Picus c1e2ab3626 Revert r291509, 291510 and 291511
Revert "ASAN activate/deactive controls thread_local_quarantine_size_kb option."
Revert "Bypass quarantine when quarantine size is set ot zero."
Revert "ASAN activate/deactive controls thread_local_quarantine_size_kb option."

One of these commits broke some of the ARM / AArch64 buildbots:
TEST 'AddressSanitizer-aarch64-linux :: TestCases/Posix/start-deactivated.cc' FAILED

Command Output (stderr):
--
/home/buildslave/buildslave/clang-cmake-aarch64-42vma/llvm/projects/compiler-rt/test/asan/TestCases/Posix/start-deactivated.cc:85:12: error: expected string not found in input
 // CHECK: WARNING: AddressSanitizer failed to allocate 0xfff{{.*}} bytes
           ^
<stdin>:1:1: note: scanning from here
start-deactivated.cc.tmp: /home/buildslave/buildslave/clang-cmake-aarch64-42vma/llvm/projects/compiler-rt/test/asan/TestCases/Posix/start-deactivated.cc:40: void test_malloc_shadow(char *, size_t, bool): Assertion `(char *)__asan_region_is_poisoned(p - 1, sz + 1) == (expect_redzones ? p - 1 : nullptr)' failed.
^
<stdin>:2:1: note: possible intended match here
Error: Aborted (core dumped)
^

llvm-svn: 291560
2017-01-10 11:14:44 +00:00
Francis Ricci 17781c71b0 Make cmake link flag naming consistent
Summary:
The build system was inconsistent in its naming conventions for
link flags. This patch changes all uses of LINKFLAGS to LINK_FLAGS,
for consistency with cmake's LINK_FLAGS property.

This patch should make it easier to search the source code for
uses of link flags, as well as providing the benefit of improved
style and consistency.

Reviewers: compnerd, beanz

Subscribers: kubabrecka, llvm-commits, mgorny

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

llvm-svn: 291539
2017-01-10 04:33:04 +00:00
Alex Shlyapnikov 0e93c3932a ASAN activate/deactive controls thread_local_quarantine_size_kb option.
Summary: Also, bypass quarantine altogether when quarantine size is set ot zero.

Reviewers: eugenis

Subscribers: kubabrecka, llvm-commits, mehdi_amini

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

llvm-svn: 291511
2017-01-09 23:49:17 +00:00
Kuba Mracek 3f499b6825 Follow-up for r291277: Redirect otool output to stderr.
Tests need to output everything into a single stream, or FileCheck is sometimes confused (buffering can cause stdout/stderr to be interleaved randomly).

llvm-svn: 291339
2017-01-07 07:41:47 +00:00
Kuba Mracek b81857a9e0 Follow-up for r291277: Increase buffer size in uuid.cc testcase.
2048 should be enough for everyone.

llvm-svn: 291305
2017-01-06 23:39:29 +00:00
Kuba Mracek b38f1ca2d5 [sanitizer] Use architecture/slice information when symbolizing fat Mach-O files on Darwin
This patch starts passing architecture information about a module to llvm-symbolizer and into text reports. This fixes the longstanding x86_64/x86_64h mismatch issue on Darwin.

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

llvm-svn: 291287
2017-01-06 21:45:05 +00:00
Kuba Mracek b6c6eaf226 [sanitizer] Add a 'print_module_map' flag which prints modules with UUIDs on Darwin
This patch add a new sanitizer flag, print_module_map, which enables printing a module map when the process exits, or after each report (for TSan). The output format is very similar to what Crash Reporter produces on Darwin (e.g. the format of module UUIDs). This enables users to use the existing symbol servers to offline symbolicate and aggregate reports.

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

llvm-svn: 291277
2017-01-06 20:57:47 +00:00
Mike Aizatsky fb96e04efb [sancov] introducing SANCOV_OPTIONS
Reintroducing https://reviews.llvm.org/rL291068
Define options function everywhere but linux.

llvm-svn: 291267
2017-01-06 19:22:50 +00:00
Michal Gorny 42af8da4c8 [builtins] Implement __floattitf() & __floatuntitf()
Implement the missing __floattitf() and __floatuntitf() functions, to
convert 128-bit (unsigned) integers to quad-precision floating-point
types. This is needed e.g. on AArch64 where 'long double' is
a quad-precision type.

The code is based on the existing code for __floattixf()
and __floatuntixf(), updated to account for different bit field lengths
of quad-precision float. The tests are also copied, with the rounding
tests adjusted for longer significand.

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

llvm-svn: 291259
2017-01-06 18:46:35 +00:00
Mike Aizatsky dc58a7d618 Revert "[sancov] introducing SANCOV_OPTIONS"
and related changes

https://llvm.org/svn/llvm-project/compiler-rt/trunk@291068

llvm-svn: 291141
2017-01-05 16:55:56 +00:00
Mike Aizatsky 2ced0edd1c [sancov] enabling tests on ppc and s390
The reason they should have failed: absent sancov.
In this test (vs the trace_pc_guard test) sancov is not
yet called (not implemented).

llvm-svn: 291080
2017-01-05 04:46:19 +00:00
Mike Aizatsky 4ae2e0c386 [sancov] introducing SANCOV_OPTIONS
Summary:
At this point SANCOV_OPTIONS are not functional but it is our intent
to move here sanitizer coverage flags from various sanitizers _OPTIONS.

Reviewers: kcc

Subscribers: kubabrecka, mgorny

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

llvm-svn: 291068
2017-01-05 03:14:35 +00:00
Dean Michael Berris 7c030a2d91 [XRay] [compiler-rt] Include argv[0] in the log file name.
Summary:
If you decide to recompile parts of your Linux distro with XRay, it may
be useful to know which trace belongs to which binary.  While there, get
rid of the incorrect strncat() usage; it always returns a pointer to the
start which makes that if() always true.  Replace with snprintf which is
bounded so that enough from both strings fits nicely.

Reviewers: dberris

Subscribers: danalbert, srhines, kubabrecka, mgorny, llvm-commits

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

llvm-svn: 290861
2017-01-03 04:35:24 +00:00
Dean Michael Berris 0aba35710f Revert "[XRay][compiler-rt] XRay Flight Data Recorder Mode"
This reverts rL290852 as it breaks aarch64 and arm.

llvm-svn: 290854
2017-01-03 04:04:00 +00:00
Dean Michael Berris 33d305b54b [XRay][compiler-rt] XRay Flight Data Recorder Mode
Summary:
In this change we introduce the notion of a "flight data recorder" mode
for XRay logging, where XRay logs in-memory first, and write out data
on-demand as required (as opposed to the naive implementation that keeps
logging while tracing is "on"). This depends on D26232 where we
implement the core data structure for holding the buffers that threads
will be using to write out records of operation.

This implementation only currently works on x86_64 and depends heavily
on the TSC math to write out smaller records to the inmemory buffers.

Also, this implementation defines two different kinds of records with
different sizes (compared to the current naive implementation): a
MetadataRecord (16 bytes) and a FunctionRecord (8 bytes). MetadataRecord
entries are meant to write out information like the thread ID for which
the metadata record is defined for, whether the execution of a thread
moved to a different CPU, etc. while a FunctionRecord represents the
different kinds of function call entry/exit records we might encounter
in the course of a thread's execution along with a delta from the last
time the logging handler was called.

While this implementation is not exactly what is described in the
original XRay whitepaper, this one gives us an initial implementation
that we can iterate and build upon.

Reviewers: echristo, rSerge, majnemer

Subscribers: mehdi_amini, llvm-commits, mgorny

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

llvm-svn: 290852
2017-01-03 03:38:17 +00:00
Evgeniy Stepanov 8988ebb435 Fix unit test broken by D27873.
Summary:
Reduce RSS size treshold in the unit test to accomodate for the smaller
ASAN quarantine size on Android (see D27873).

Reviewers: eugenis

Patch by Alex Shlyapnikov.

Subscribers: danalbert, kubabrecka, llvm-commits

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

llvm-svn: 290643
2016-12-28 01:41:24 +00:00
Evgeniy Stepanov ddf0c26b6a [asan] Mark printf-m test as unsupported on windows.
llvm-svn: 290635
2016-12-27 22:22:32 +00:00
Evgeniy Stepanov f787cf7ee6 [asan] Fix handling of %m in printf interceptor.
llvm-svn: 290632
2016-12-27 22:14:03 +00:00
Saleem Abdulrasool c1861d86e1 test: filter out -fPIE/-pie on Windows
Use some new substitutions to avoid duplicating the tests for just
dropped flags.  -fPIC/-fPIE/-fpic/-fpie do not make sense on Windows as
they can cause ELF-style PIC.  Substitute away the flag on Windows.
This should repair the windows buildbots.

llvm-svn: 290571
2016-12-27 03:16:20 +00:00
Renato Golin ece8de7c23 Revert "[XRay][AArch64] An attempt to fix test patching-unpatching.cc by flushing the instruction cache after code modification"
This reverts commit r290452, not quite there yet. We need to test this
offline.

llvm-svn: 290453
2016-12-23 21:58:39 +00:00
Serge Rogatch 4ee228bf73 [XRay][AArch64] An attempt to fix test patching-unpatching.cc by flushing the instruction cache after code modification
Summary: This patch attempts to fix test patching-unpatching.cc . The new code flushes the instruction cache after modifying the program at runtime.

Reviewers: dberris, rengolin

Subscribers: llvm-commits, iid_iunknown, aemerson

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

llvm-svn: 290452
2016-12-23 21:21:01 +00:00
Kostya Kortchinsky 524c035a4a [scudo] Use the macro get_test_cc_for_arch for the tests
Summary: The macro was introduced with D26929, use it in Scudo as well.

Reviewers: kcc, alekseyshl, kubabrecka

Subscribers: llvm-commits, danalbert, srhines, mgorny

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

llvm-svn: 290439
2016-12-23 18:40:47 +00:00
Michal Gorny f344a51369 [tests] Add missing "int_lib.h" includes and extend guards
Fix missing "int_lib.h" includes in ARM negdf2vfp and subdf3vfp tests.
Additionally, extend the __arm__ guard to cover the builtin definition
in the former. This is mostly intended to prevent build failures
and allow those tests to be properly skipped on other targets.

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

llvm-svn: 290422
2016-12-23 11:18:24 +00:00
Evgeniy Stepanov 37db58e9eb Expose thread local quarantine size as ASAN option.
Summary: Make thread local quarantine size an option so it can be turned off to save memory.

Reviewers: eugenis

Patch by Alex Shlyapnikov.

Subscribers: kubabrecka, llvm-commits

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

llvm-svn: 290373
2016-12-22 21:43:22 +00:00
Renato Golin fe8bbb2333 Revert "[XRay][AArch64] An attempt to fix test patching-unpatching.cc by flushing the instruction cache after code modification"
This reverts commit r290354, as it broke the build. We need to make sure
this builds on AArch64 before committing again.

llvm-svn: 290362
2016-12-22 19:38:04 +00:00
Serge Rogatch 93fb15788a [XRay][AArch64] An attempt to fix test patching-unpatching.cc by flushing the instruction cache after code modification
Summary: This patch attempts to fix test patching-unpatching.cc . The new code flushes the instruction cache after modifying the program at runtime.

Reviewers: dberris, rengolin

Subscribers: llvm-commits, iid_iunknown, aemerson

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

llvm-svn: 290354
2016-12-22 18:48:36 +00:00
Kostya Kortchinsky e3be61c139 [scudo] ARM32 support
Summary:
With the previous modifications, the code works on ARM32. The random shuffle
test is unsupported on 32-bit platforms for the moment and being marked as
such. There is no hardware support for the checksum computation yet, this will
come at a later point.

Reviewers: kcc, alekseyshl

Subscribers: llvm-commits, aemerson, rengolin, mgorny

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

llvm-svn: 290201
2016-12-20 21:17:58 +00:00