Commit Graph

8511 Commits

Author SHA1 Message Date
Evgeniy Stepanov 0b11403d55 [cfi] Fix wrong CMake condition for WIN32.
llvm-svn: 301257
2017-04-24 21:27:47 +00:00
Evgeniy Stepanov 2c201068dd [asan] Remove asanwrapper from Android test harness.
It is only necessary for pre-L and creates problems on newer builds.

llvm-svn: 301256
2017-04-24 21:27:45 +00:00
Evgeniy Stepanov ed8c47477f [asan] Use posix strerror_r interceptor on android.
This fixes a regression in r297315.

llvm-svn: 301243
2017-04-24 20:25:39 +00:00
Evgeniy Stepanov 5d7633f75d [cfi] Disable ThinLTO + CFI tests on Windows.
PR32770.

llvm-svn: 301235
2017-04-24 19:52:51 +00:00
Kuba Mracek dd13e4e0b0 [tsan] Include __tsan_external_* API from a header file instead of declaring them manually. NFC.
Differential Revision: https://reviews.llvm.org/D32384

llvm-svn: 301190
2017-04-24 16:48:30 +00:00
Kuba Mracek 264b6de4b0 [tsan] Remove the extra word "object" from description of external races
Differential Revision: https://reviews.llvm.org/D32383

llvm-svn: 301189
2017-04-24 16:42:29 +00:00
Kostya Kortchinsky 38199b2a30 [sanitizer] Cache SizeClassForTransferBatch in the 32-bit local cache
Summary:
`SizeClassForTransferBatch` is expensive and is called for every `CreateBatch`
and `DestroyBatch`. Caching it means `kNumClasses` calls in `InitCache`
instead. This should be a performance gain if more than `kNumClasses / 2`
batches are created and destroyed during the lifetime of the local cache.

I have chosen to fully remove the function and putting the code in `InitCache`,
which is a debatable choice.

In single threaded benchmarks leveraging primary backed allocations, this turns
out to be a sizeable gain in performances (greater than 5%). In multithreaded
benchmarks leveraging everything, it is less significant but still an
improvement (about 1%).

Reviewers: kcc, dvyukov, alekseyshl

Reviewed By: dvyukov

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 301184
2017-04-24 14:53:38 +00:00
Sagar Thakur a37c0d99c9 Revert [scudo] Enabling MIPS support for Scudo
This patch broke the buildbot clang-cmake-mips. Investigating the issue.

llvm-svn: 301173
2017-04-24 11:02:36 +00:00
Sagar Thakur 4bac44c805 [scudo] Enabling MIPS support for Scudo
Adding MIPS 32-bit and 64-bit support for Scudo.

Reviewed by cryptoad
Differential: D31803

llvm-svn: 301158
2017-04-24 04:29:44 +00:00
Frederich Munch 5de7f2d7b8 [builtins] Implement emulated TLS on Windows.
Summary:
LLVM JIT needs to be able to use emulated TLS on all platforms, and this provides a reference one can compile to enable emutls for Linux/Mac/Windows.

Reviewers: chh, howard.hinnant

Reviewed By: chh

Subscribers: mgorny, llvm-commits

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

llvm-svn: 301089
2017-04-22 18:45:17 +00:00
Ahmed Bougacha ea84c1687c [cfi] Disable thinlto tests on Darwin.
These were added in r301016, but they're failing, because
-fsanitize=cfi seemingly causes -flto=thin to emit raw bitcode objects,
rather than the mach-o-wrapped bitcode we emit with -flto=thin alone.

That causes all tests to fail with ld64 errors.

Filed PR32741.

llvm-svn: 301065
2017-04-22 00:07:47 +00:00
Alex Shlyapnikov 342586d728 [lsan] Enable LSan on PowerPC64.
Summary: Re-landing reverted D31995 with suppressions defined in D32303 and D32377.

Reviewers: eugenis

Subscribers: nemanjai, llvm-commits

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

llvm-svn: 301048
2017-04-21 21:59:53 +00:00
Alex Shlyapnikov a3417bc4dd Suppress DTLS leak happening in some glibc versions.
Summary: Refer to https://sourceware.org/bugzilla/show_bug.cgi?id=12650 for the context.

Reviewers: eugenis

Subscribers: llvm-commits

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

llvm-svn: 301043
2017-04-21 21:34:37 +00:00
Vitaly Buka 9703df2b36 [asan] Optimize strchr for strict_string_checks=false
Summary:
strchr interceptor does not need to call strlen if strict_string_checks is not
enabled. Unnecessary strlen calls affect python parser performance.

Reviewers: eugenis, kcc

Subscribers: llvm-commits, kubamracek

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

llvm-svn: 301027
2017-04-21 19:39:46 +00:00
Evgeniy Stepanov f608a0a778 [cfi] Replace elif with elseif in cmake.
Apparently, elif() is deprecated.

llvm-svn: 301022
2017-04-21 19:22:15 +00:00
Evgeniy Stepanov ca32b682f6 [cfi] Run tests with and without lld and thinlto.
Run tests in all configurations:
(standalone, with devirtualization) * (gold, lld) * (lto, thinlto)

llvm-svn: 301016
2017-04-21 18:11:23 +00:00
Kostya Kortchinsky f1a54fdfd6 [scudo] Bypass Quarantine if its size is set to 0
Summary:
In the current state of things, the deallocation path puts a chunk in the
Quarantine whether it's enabled or not (size of 0). When the Quarantine is
disabled, this results in the header being loaded (and checked) twice, and
stored (and checksummed) once, in `deallocate` and `Recycle`.

This change introduces a `quarantineOrDeallocateChunk` function that has a
fast path to deallocation if the Quarantine is disabled. Even though this is
not the preferred configuration security-wise, this change saves a sizeable
amount of processing for that particular situation (which could be adopted by
low memory devices). Additionally this simplifies a bit `deallocate` and
`reallocate`.

Reviewers: dvyukov, kcc, alekseyshl

Reviewed By: dvyukov

Subscribers: llvm-commits

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

llvm-svn: 301015
2017-04-21 18:10:53 +00:00
Kuba Mracek 276e94eb74 [tsan] Add a test for "external" API that checks the dup suppression is based on the caller PC
We need to make sure that the "external" API isn't dup'ing all data races into a single one (because the stack might look the same) and suppressing all external races. This works now, so just adding a test for that.

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

llvm-svn: 301011
2017-04-21 17:49:19 +00:00
Kuba Mracek 428b36671c [tsan] Refactor __tsan_external_read/__tsan_external_write to avoid code duplication
Let's introduce a ExternalAccess function that has the shared code only once.

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

llvm-svn: 301008
2017-04-21 17:41:01 +00:00
Kuba Mracek d1be869744 [tsan] Publish the TSan external API in tsan_interface.h
Let's make the TSan external API available and commented in the public header:

    void *__tsan_external_register_tag(const char *object_type);
    void __tsan_external_assign_tag(void *addr, void *tag);
    void __tsan_external_read(void *addr, void *caller_pc, void *tag);
    void __tsan_external_write(void *addr, void *caller_pc, void *tag);

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

llvm-svn: 301003
2017-04-21 17:25:47 +00:00
Kuba Mracek 676d008198 [tsan] Track external API accesses as 1-byte accesses (instead of 8-byte)
It doesn't really make sense to track them as 8-byte accesses.

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

llvm-svn: 301001
2017-04-21 17:21:18 +00:00
Kuba Mracek 2e4e7d04d2 [tsan] Ignore memory accesses for libignored modules for "external" races
On Darwin, the setting ignore_noninstrumented_modules is used to suppress false positives in code that users don't have control of. The recently added "external" API (which can be used to detect races on objects provided by system libraries, but the race is actually user's fault) ignores this flag and it can report issues in non-instrumented modules. This patch fixes that.

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

llvm-svn: 301000
2017-04-21 17:18:14 +00:00
Kuba Mracek 894da66320 [tsan] Don't report bugs from interceptors called from libignored modules
This patch make sure we don't report deadlocks and other bug types when we're inside an interceptor that was called from a noninstrumented module (when ignore_noninstrumented_modules=1 is set). Adding a testcase that shows that deadlock detection still works on Darwin (to make sure we're not silencing too many reports).

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

llvm-svn: 300998
2017-04-21 16:44:27 +00:00
Diana Picus 1f043e1c55 Revert r300889, r300906, r300935, r300939
At least one of the ARM bots is still broken:
Command Output (stderr):
--
/home/buildslave/buildslave/clang-cmake-armv7-a15-full/llvm/projects/compiler-rt/test/asan/TestCases/Posix/strchr.c:31:12: error: expected string not found in input
 // CHECK: strchr.c:[[@LINE-2]]
           ^
<stdin>:3:59: note: scanning from here
==16297==ERROR: AddressSanitizer: SEGV on unknown address 0xb5add000 (pc 0xb6dccaa4 bp 0xbe8c19c8 sp 0xbe8c1570 T0)
                                                          ^
<stdin>:3:59: note: with expression "@LINE-2" equal to "29"
==16297==ERROR: AddressSanitizer: SEGV on unknown address 0xb5add000 (pc 0xb6dccaa4 bp 0xbe8c19c8 sp 0xbe8c1570 T0)
                                                          ^
<stdin>:5:57: note: possible intended match here
 #0 0xb6dccaa3 in strlen /build/glibc-f8FFOS/glibc-2.23/string/../sysdeps/arm/armv6t2/strlen.S:82

Try to fix by reverting r300889 and subsequent fixes:
Revert "[asan] Fix test by removing "The signal is caused" check."
Revert "[asan] Fix test on ppc64le-linux by checking "UNKNOWN memory access""
Revert "[asan] Match BUS and SIGV to fix test on Darwin"
Revert "[asan] Optimize strchr for strict_string_checks=false"

llvm-svn: 300955
2017-04-21 08:21:56 +00:00
Vitaly Buka a232323ff7 [asan] Fix test by removing "The signal is caused" check.
llvm-svn: 300939
2017-04-21 01:16:58 +00:00
Vitaly Buka e03dc7d754 [asan] Fix test on ppc64le-linux by checking "UNKNOWN memory access"
llvm-svn: 300935
2017-04-21 00:48:43 +00:00
Alex Shlyapnikov c426666b4d Disable LSan on ppc64, some tests are failing.
llvm-svn: 300933
2017-04-21 00:36:29 +00:00
Ahmed Bougacha c6422fed85 Revert "Enable lsan test suite on Darwin x86_64 builds"
This reverts commit r300897.

Most LSan/ASan tests are failing on darwin bots.

llvm-svn: 300929
2017-04-21 00:00:59 +00:00
Kostya Serebryany 2500d1e35d [asan] move textdomain.c to Linux dir, as the test is Linux-specific
llvm-svn: 300926
2017-04-20 23:57:44 +00:00
Kostya Serebryany b2d291eb9b sanitizer: fix crash with textdomain(NULL) interceptor
Summary:
The textdomain function accepts a NULL parameter (and should then return the
current message domain). Add a check for this and include ASAN tests.

Link: https://github.com/google/sanitizers/issues/787

Reviewers: m.guseva, kcc

Reviewed By: kcc

Subscribers: kubamracek

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

llvm-svn: 300924
2017-04-20 23:38:10 +00:00
Vitaly Buka 70197c55b0 [asan] Match BUS and SIGV to fix test on Darwin
llvm-svn: 300906
2017-04-20 21:58:18 +00:00
Alex Shlyapnikov 906ffb7b8f Enable LSan on PowerPC64.
Summary: Re-landing reverted D31995 with suppressions defined in D32303.

Reviewers: eugenis

Subscribers: nemanjai, llvm-commits

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

llvm-svn: 300903
2017-04-20 21:56:36 +00:00
Evgeniy Stepanov b9cb969d9c [cfi] Add explicit -flto in create-derivers test.
This is necessary to run the test suite in ThinLTO mode - otherwise
opt complains about an input file containing several modules.

llvm-svn: 300901
2017-04-20 21:44:37 +00:00
Evgeniy Stepanov a32c3e5b18 [cfi] Move one test under cross-dso/icall.
The test is using indirect calls.

llvm-svn: 300900
2017-04-20 21:44:35 +00:00
Francis Ricci dcaf4e2139 Enable lsan test suite on Darwin x86_64 builds
Reviewers: kubamracek, alekseyshl

Subscribers: mgorny, llvm-commits

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

llvm-svn: 300897
2017-04-20 21:27:25 +00:00
Francis Ricci 6b494d9edc make detect_leaks=1 the default for the lsan test suite
Summary:
This already appears to be the case in all .cc test files,
it was probably left out of the .c test files accidentally. Make it a global
default, instead of manually adding it to each individual test.

This is needed to force leak detection for Darwin tests, where leak detection
is disabled by default.

Reviewers: m.ostapenko, kubamracek, alekseyshl

Subscribers: llvm-commits

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

llvm-svn: 300890
2017-04-20 21:00:02 +00:00
Vitaly Buka f50f97c9dd [asan] Optimize strchr for strict_string_checks=false
Summary:
strchr interceptor does not need to call strlen if strict_string_checks is not
enabled. Unnecessary strlen calls affect python parser performance.

Reviewers: eugenis, kcc

Subscribers: llvm-commits, kubamracek

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

llvm-svn: 300889
2017-04-20 20:59:37 +00:00
Alex Shlyapnikov 3106fc476c Define standard suppressions for LSan, start with this one.
llvm-svn: 300887
2017-04-20 20:54:22 +00:00
Alex Shlyapnikov bdbb894a52 Define a suppression for known leaks on pthread_exit call.
Summary: Refer to D32194 for the context.

Reviewers: eugenis

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 300886
2017-04-20 20:54:19 +00:00
Kostya Kortchinsky fff8e0620b [scudo] Remove GetActuallyAllocatedSize calls from the fast path
Summary:
GetActuallyAllocatedSize is actually expensive. In order to avoid calling this
function in the malloc/free fast path, we change the Scudo chunk header to
store the size of the chunk, if from the Primary, or the amount of unused
bytes if from the Secondary. This way, we only have to call the culprit
function for Secondary backed allocations (and still in realloc).

The performance gain on a singly threaded pure malloc/free benchmark exercising
the Primary allocator is above 5%.

Reviewers: alekseyshl, kcc, dvyukov

Reviewed By: dvyukov

Subscribers: llvm-commits

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

llvm-svn: 300861
2017-04-20 18:07:17 +00:00
Kostya Kortchinsky 006805d146 [scudo] Minor changes and refactoring
Summary:
This is part of D31947 that is being split into several smaller changes.

This one deals with all the minor changes, more specifically:
- Rename some variables and functions to make their purpose clearer;
- Reorder some code;
- Mark the hot termination incurring checks as `UNLIKELY`; if they happen, the
  program will die anyway;
- Add a `getScudoChunk` method;
- Add an `eraseHeader` method to ScudoChunk that will clear a header with 0s;
- Add a parameter to `allocate` to know if the allocated chunk should be filled
  with zeros. This allows `calloc` to not have to call
  `GetActuallyAllocatedSize`; more changes to get rid of this function on the
  hot paths will follow;
- reallocate was missing a check to verify that the pointer is properly
  aligned on `MinAlignment`;
- The `Stats` in the secondary have to be protected by a mutex as the `Add`
  and `Sub` methods are actually not atomic;
- The software CRC32 function was moved to the header to allow for inlining.

Reviewers: dvyukov, alekseyshl, kcc

Reviewed By: dvyukov

Subscribers: llvm-commits

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

llvm-svn: 300846
2017-04-20 15:11:00 +00:00
Keith Wyss dd11cf9022 [XRay] [compiler-rt] - Fix standalone and non-deterministic test issue
Summary:
The thread order test fails sometimes my machine independently of standalone
build.

From testing both standalone and in-tree build, I see I configured it wrong.

The other hypothesis for an issue is that cold starts can interfere with whether
record unwriting happens. Once this happens more than once, we can naively
FileCheck on the wrong test output, which compounds the issue.

While "rm blah.* || true" will print to stderr if the glob can't expand, this is
mostly harmless and makes sure earlier failing tests don't sabotage us.

Example failure:

---
header:
  version:         1
  type:            1
  constant-tsc:    true
  nonstop-tsc:     true
  cycle-frequency: 3800000000
records:
  - { type: 0, func-id: 1, function: 'f1()', cpu: 9, thread: 21377, kind: function-enter, tsc: 2413745203147228 }
  - { type: 0, func-id: 1, function: 'f1()', cpu: 9, thread: 21377, kind: function-exit, tsc: 2413745203304238 }
...

The CMAKE related change fixes the expectation that COMPILER_RT_STANDALONE_BUILD will be explicitly FALSE instead
of empty string when it is not "TRUE".

Reviewers: dberris

Subscribers: llvm-commits

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

llvm-svn: 300822
2017-04-20 05:59:26 +00:00
Dean Michael Berris 9df8ef5538 [XRay][compiler-rt] Cleanup CFI/CFA annotations on trampolines
Summary:
This is a follow-up to D32202.

While the previous change (D32202) did fix the stack alignment issue, we
were still at a weird state in terms of the CFI/CFA directives (as the
offsets were wrong). This change cleans up the SAVE/RESTORE macros for
the trampoline, accounting the stack pointer adjustments with less
instructions and with some clearer math. We note that the offsets will
be different on the exit trampolines, because we don't typically 'call'
into this trampoline and we only ever jump into them (i.e. treated as a
tail call that's patched in at runtime).

Reviewers: eugenis, kpw, pelikan

Subscribers: llvm-commits

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

llvm-svn: 300815
2017-04-20 03:26:04 +00:00
Kostya Serebryany 1838561dfe [sanitizer-coverage] remove more unused code
llvm-svn: 300780
2017-04-19 23:05:53 +00:00
Kostya Serebryany d32bc3ee38 [sanitizer-coverage] remove run-time support for -fsanitize-coverage=indirect-calls
llvm-svn: 300775
2017-04-19 22:24:03 +00:00
Kostya Serebryany a2a0d2d3fc [sanitizer-coverage] remove run-time support for -fsanitize-coverage=trace-bb
llvm-svn: 300766
2017-04-19 21:30:46 +00:00
Francis Ricci 6e2b22f929 Fixup style from r300760
llvm-svn: 300765
2017-04-19 21:25:06 +00:00
Francis Ricci 9be010f0d0 Make sure to scan mmap'd memory regions for root pointers on OS X
Summary:
In the general case, we only need to check for root regions inside
the memory map returned by procmaps. However, on Darwin,
we also need to check inside mmap'd regions, which aren't returned
in the list of modules we get from procmaps.

This patch refactors memory region scanning on darwin to reduce
code duplication with the kernel alloc once page scan.

Reviewers: kubamracek, alekseyshl

Subscribers: llvm-commits

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

llvm-svn: 300760
2017-04-19 21:11:08 +00:00
Francis Ricci eb930609e8 Implement StopTheWorld for Darwin
Reviewers: kubamracek, alekseyshl

Subscribers: llvm-commits

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

llvm-svn: 300759
2017-04-19 21:11:07 +00:00
Alex Shlyapnikov 87276d68cd Turn symbolization on for ASan unit test.
Summary:
On PowerPC and ARM (possibly, need to verify), couple tests involving
pthread_exit fail due to leaks detected by LSan. pthread_exit tries
to perform unwinding that leads to dlopen'ing libgcc_s.so. dlopen
mallocs "libgcc_s.so" string which confuses LSan, it fails to
realize that this allocation happens in dynamic linker and should
be ignored.
Symbolized leak report is required to define a suppression for this
known problem.

Reviewers: eugenis

Subscribers: aemerson, rengolin, kubamracek, llvm-commits

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

Turn symbolization on for PPC and Thumb only to do not slow down other platforms.

llvm-svn: 300748
2017-04-19 20:39:09 +00:00