Commit Graph

8332 Commits

Author SHA1 Message Date
Bill Seurer fe53fdb873 [PowerPC] mark xray test as unsupported on powerpcle in testsuite
Temporarily mark the test as unsupported so the powerpc le buildbot
testers can get back to work.

There was a brief discussion of this on the mailing list for r296998.

llvm-svn: 297184
2017-03-07 18:52:54 +00:00
Tim Shen 0243eac2d8 [XRay] [compiler-rt] Stub out architectures we don't do arg1 logging on.
rL297000 forgot to include code for three architectures that appeared
since I wrote the first version. This gives them the same treatment as ARMs
have for now - write stubs and wait for someone to actually implement it.

Patched by pelikan (Martin Pelikán)!

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

llvm-svn: 297003
2017-03-06 08:26:21 +00:00
Dean Michael Berris a814c94163 [XRay] [compiler-rt] Allow logging the first argument of a function call.
Summary:
Functions with the LOG_ARGS_ENTRY sled kind at their beginning will be handled
in a way to (optionally) pass their first call argument to your logging handler.

For practical and performance reasons, only the first argument is supported, and
only up to 64 bits.

Reviewers: javed.absar, dberris

Reviewed By: dberris

Subscribers: llvm-commits

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

llvm-svn: 297000
2017-03-06 07:25:41 +00:00
Etienne Bergeron 4edb9fd3c8 [compiler-rt][asan] Turn on ASAN unittests for win64.
Summary:
Asan is now working on windows 64-bit.
This patch is turning on the unittest.

Reviewers: rnk

Reviewed By: rnk

Subscribers: kubamracek, dberris, beanz, mgorny, llvm-commits, chrisha

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

llvm-svn: 296878
2017-03-03 16:35:46 +00:00
Evgeniy Stepanov b6fe13f26b [msan] Test for _mm_getcsr and _mm_setcsr (r296848).
llvm-svn: 296849
2017-03-03 01:13:23 +00:00
Francis Ricci 7cd7d9bc8e Revert "Use pthreads for thread-local lsan allocator cache on darwin"
Reverting due to revert of prerequisite patch r296706

This reverts commit 6e1f23078c1acc44295065d28167043c4d31ddd1.

llvm-svn: 296720
2017-03-02 00:12:58 +00:00
Francis Ricci ddee63ffb2 Revert "Increase stack size for stack-use-after-return test"
Reverting due to failures on aarch64

This reverts commit f8ff7e585134196e8482e4dd8752cd4c22cf027a.

llvm-svn: 296719
2017-03-02 00:12:56 +00:00
Francis Ricci 923a320441 Use pthreads for thread-local lsan allocator cache on darwin
Summary:
This patch allows us to move away from using __thread on darwin,
which is requiring for building lsan for darwin on ios version 7
and on iossim i386.

Reviewers: kubamracek, kcc

Subscribers: llvm-commits

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

llvm-svn: 296707
2017-03-01 23:18:15 +00:00
Francis Ricci bdc963a98c Increase stack size for stack-use-after-return test
Summary:
The current size is flaky, as revealed by checking
the stack size attr after setting it.

Reviewers: kubamracek, rnk

Subscribers: llvm-commits

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

llvm-svn: 296706
2017-03-01 23:18:13 +00:00
Filipe Cabecinhas 9a563daff5 Restrict usage of MemoryMappingLayout to platforms which support it
llvm-svn: 296657
2017-03-01 19:20:13 +00:00
Filipe Cabecinhas 74ad311556 Reapply r296419: [asan] Print a "PC is at a non-executable memory region" message if that's the case
Summary: Points the user to look at function pointer assignments.

Reviewers: kcc, eugenis, kubamracek

Subscribers: llvm-commits

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

llvm-svn: 296653
2017-03-01 18:52:11 +00:00
Dean Michael Berris fbe64b65a8 [XRay] [compiler-rt] [NFC] Annotate unused variables for the compiler.
Summary:
Use a common definition of a "this variable is unused" annotation for useless
variables only present for their lambda global initializers, to silence gcc's
warning.

Reviewers: dberris

Reviewed By: dberris

Subscribers: llvm-commits

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

llvm-svn: 296449
2017-02-28 08:48:46 +00:00
Dean Michael Berris 427215ce5e [XRay][compiler-rt] Switch default XRay 'patch_premain' to false
Summary:
Currently, we assume that applications built with XRay would like to
have the instrumentation sleds patched before main starts. This patch
changes the default so that we do not patch the instrumentation sleds
before main. This default is more helpful for deploying applications in
environments where changing the current default is harder (i.e. on
remote machines, or work-pool-like systems).

This default (not to patch pre-main) makes it easier to selectively run
applications with XRay instrumentation enabled, than with the current
state.

Reviewers: echristo, timshen

Subscribers: mehdi_amini, llvm-commits

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

llvm-svn: 296445
2017-02-28 08:10:01 +00:00
Filipe Cabecinhas 6e36c11d2a Revert r296419 since the strings appear to need some tweaking.
llvm-svn: 296428
2017-02-28 02:45:46 +00:00
Filipe Cabecinhas f1d4ae579d [non-executable-pc.cpp] Try to fix clang-ppc64be buildbot.
llvm-svn: 296424
2017-02-28 02:05:53 +00:00
Filipe Cabecinhas cd643f6324 [asan] Print a "PC is at a non-executable memory region" message if that's the case
Summary: Points the user to look at function pointer assignments.

Reviewers: kcc, eugenis, kubamracek

Subscribers: llvm-commits

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

llvm-svn: 296419
2017-02-28 00:56:43 +00:00
Evgeniy Stepanov acc8ebb8e3 [msan] Test for alloca handling.
llvm-svn: 296051
2017-02-24 00:13:28 +00:00
Filipe Cabecinhas 3f4181db66 [test] Use @LINE macro
llvm-svn: 295995
2017-02-23 17:23:28 +00:00
Benjamin Kramer 782e98e8aa [xray] Unbreak unittest after r295967.
llvm-svn: 295969
2017-02-23 13:13:27 +00:00
Benjamin Kramer 7654191e70 [Xray] fix building the runtime with GCC.
GCC has a warning about enum bitfields that cannot be disabled. Do the
ugly thing and go through uint8_t for all the values.

llvm-svn: 295967
2017-02-23 12:49:41 +00:00
Kuba Mracek c90b79c585 Re-commit of r295318, which was reverted due to AArch64 flakiness. Moving the test to Darwin only.
llvm-svn: 295801
2017-02-22 01:13:34 +00:00
Tim Shen 01fb2c87b9 [XRay] Change the ppc trampoline asm file into a different name, to not collide with the cc file. NFC.
llvm-svn: 295795
2017-02-22 00:19:43 +00:00
Vitaly Buka 5d6631d8b4 [compiler-rt] Prevent symbolizer from starting itself.
Summary:
If symbolizer was instrumented with sanitizer and crash, it may
try to call itself again causing infinite recursion of crashing processes.

Reviewers: eugenis

Subscribers: kubamracek, llvm-commits, dberris

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

llvm-svn: 295771
2017-02-21 21:39:24 +00:00
Anna Zaks aacf7958c5 [asan] Re-enable a test on i386-darwin.
This test has been reverted in r279918 due to flaky atos support in the OS
some machines in the buildbot fleet were running. This should not be a
problem anymore.

llvm-svn: 295766
2017-02-21 20:46:50 +00:00
Etienne Bergeron 0eec53cb41 [compiler-rt][asan] Fix incorrect macro preventing ICF with MSVC
Summary:
The DLL thunks are stubs added to an instrumented DLL to redirect ASAN API calls
to the real ones in the main executable. These thunks must contain dummy
code before __asan_init got called. Unfortunately, MSVC linker is doing ICF and is
merging functions with the same body.


In our case, this two ASAN thunks were incorrectly merged:
```
asan_interface.inc:16
INTERFACE_FUNCTION(__asan_before_dynamic_init)
```
```
sanitizer_common_interface.inc:16
INTERFACE_FUNCTION(__sanitizer_verify_contiguous_container)
```

The same thunk got patched twice. After the second patching, calls to
`__asan_before_dynamic_init` are redirected to `__sanitizer_verify_contiguous_container`
and trigger a DCHECK on incorrect operands/

The problem was caused by the macro that is only using __LINE__ to prevent
collapsing code.
```
 #define INTERCEPT_SANITIZER_FUNCTION(name)
   extern "C" __declspec(noinline) void name() {
   volatile int prevent_icf = (__LINE__ << 8); (void)prevent_icf;
```

The current patch is adding __COUNTER__ which is safer than __LINE__.

Also, to precent ICF (guarantee that code is different), we are using a unique attribute:
  - the name of the function

Reviewers: rnk

Reviewed By: rnk

Subscribers: llvm-commits, kubamracek, chrisha, dberris

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

llvm-svn: 295761
2017-02-21 20:04:47 +00:00
Renato Golin fc1ccec9bb [RT ARM] Avoid Linux include with a redefinition
To avoid depending on kernel headers, we just repeat the single define
we need, which is likely never going to change.

Patch by Joakim Sindholt <opensource@zhasha.com>

llvm-svn: 295738
2017-02-21 17:40:26 +00:00
Etienne Bergeron fc68c2c777 [compiler-rt][asan] Add support for desallocation of unhandled pointers
Summary: On windows 10, the ucrt DLL is performing allocations before the function hooking and there are multiple allocations not handled by Asan. When a free occur at the end of the process, asan is reporting desallocations not malloc-ed.

Reviewers: rnk, kcc

Reviewed By: rnk, kcc

Subscribers: kcc, llvm-commits, kubamracek, chrisha, dberris

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

llvm-svn: 295730
2017-02-21 16:09:38 +00:00
Diana Picus 99141cc7ca Revert "[tsan] Provide external tags (object types) via debugging API"
This reverts commit r295318 as the test is flaky on AArch64.

llvm-svn: 295667
2017-02-20 15:26:12 +00:00
Renato Golin 18342e39e6 Revert "[PGO] Suspend SIGKILL for PR_SET_PDEATHSIG in profile-write"
Revert "[PGO] remove unintended debug trace. NFC"

This reverts commit r295469, r295364, as they are unstable on ARM/AArch64.

llvm-svn: 295664
2017-02-20 15:03:12 +00:00
Dean Michael Berris 773c2ab9d6 [XRay][compiler-rt] Allow for defining defaults at compile-time
Summary:
Currently, defaulted options cannot be overriden easily. As an example,
we always patch the binary pre-main unless the user defines the option
at the commandline to inhibit this behaviour. This change allows for
building different versions of the XRay archive with different defaults
(whether to patch pre-main, or whether to use FDR mode by default, etc.)
and giving that choice at link-time.

For now we don't create different archives that have different defaults,
but those could be added in later revisions. This change just enables
the possibility.

Reviewers: pelikan, kcc

Subscribers: llvm-commits

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

llvm-svn: 295534
2017-02-18 02:09:51 +00:00
Pirama Arumuga Nainar a84404c7a4 Enable PROFILE, TSAN and UBSAN for Android
Summary:
These sanitizers are enabled and used in Android but got built with
Android's build system.  This change enables them in the CMake build
system.

Reviewers: eugenis

Subscribers: llvm-commits, danalbert, srhines, mgorny

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

llvm-svn: 295523
2017-02-18 01:12:55 +00:00
Rong Xu 1ba2cacc96 [PGO] remove unintended debug trace. NFC
llvm-svn: 295469
2017-02-17 17:42:16 +00:00
Francis Ricci f891e90b35 Revert "Use pthreads for thread-local lsan allocator cache on darwin"
This caused a failure in Linux-x86_64 stack-use-after-return

This reverts commit 1f9563141e999016d13ac3fc6a50fde690381e82.

llvm-svn: 295449
2017-02-17 14:42:30 +00:00
Francis Ricci 908e2d9009 Revert "Upgrade ios min version to 8"
Accidental commit

This reverts commit f21d4a6836ea159e95e5042ba8383f20d4899cda.

llvm-svn: 295414
2017-02-17 04:33:40 +00:00
Francis Ricci 01159f5c58 Use pthreads for thread-local lsan allocator cache on darwin
Summary:
This patch allows us to move away from using __thread on darwin,
which is requiring for building lsan for darwin on ios version 7
and on iossim i386.

Reviewers: kubamracek, kcc

Subscribers: llvm-commits

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

llvm-svn: 295413
2017-02-17 04:32:19 +00:00
Francis Ricci 32f0ec51d1 Upgrade ios min version to 8
Summary:
Version 8 is the first version to support the __thread
keyword, which is required for building lsan for
64-bit ios.

Reviewers: kubamracek, kcc, glider

Subscribers: mgorny, llvm-commits

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

llvm-svn: 295412
2017-02-17 04:32:17 +00:00
Francis Ricci a0921f68ab Fix build breakage from moving kInvalidTid to lsan_common
llvm-svn: 295409
2017-02-17 03:34:56 +00:00
Francis Ricci 571c05a550 Use pthreads to store current thread id on darwin
Summary:
__thread is not supported by all darwin versions and architectures,
use pthreads instead to allow for building darwin lsan on iossim.

Reviewers: kubamracek, kcc

Subscribers: llvm-commits

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

llvm-svn: 295405
2017-02-17 03:23:07 +00:00
Rong Xu 72f1e5440e [PGO] Suspend SIGKILL for PR_SET_PDEATHSIG in profile-write
Summary:
We found a nondeterministic behavior when doing online profile merging
for multi-process applications. The application forks a sub-process and
sub-process sets to get SIGKILL when the parent process exits,

The first process gets the lock, and dumps the profile. The second one
will mmap the file, do the merge and write out the file. Note that before
the merged write, we truncate the profile.

Depending on the timing, the child process might be terminated
abnormally when the parent exits first. If this happens:
(1) before the truncation, we will get the profile for the main process
(2) after the truncation, and before write-out the profile,  we will get
0 size profile.
(3) after the merged write, we get merged profile.

This patch temporarily suspend the SIGKILL for PR_SET_PDEATHSIG
before profile-write and restore it after the write.

This patch only applies to Linux system.

Reviewers: davidxl

Reviewed By: davidxl

Subscribers: xur, llvm-commits

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

llvm-svn: 295364
2017-02-16 19:21:31 +00:00
Vitaly Buka 78395f23dc [sanitizers] DefaultSymbolizer should not be destroyed as as symbolizer
can be accessed after the static destroyed.

llvm-svn: 295348
2017-02-16 18:35:38 +00:00
Kuba Mracek 3e81c2675e [tsan] Provide external tags (object types) via debugging API
In D28836, we added a way to tag heap objects and thus provide object types into report. This patch exposes this information into the debugging API.

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

llvm-svn: 295318
2017-02-16 14:02:32 +00:00
Vitaly Buka f813697f05 [sanitizers] Fix formatting of the shell script.
llvm-svn: 295299
2017-02-16 08:47:27 +00:00
Vitaly Buka 69068dd50e [sanitizers] Redirect pthread calls to interceptors.
It's needed if libcxx is build without disabling threads.

llvm-svn: 295296
2017-02-16 08:06:17 +00:00
Vitaly Buka e4465dba20 Extract *.a to *.bc conversion into separate script.
Reviewers: eugenis

Subscribers: llvm-commits, kubamracek

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

llvm-svn: 295272
2017-02-16 02:12:18 +00:00
Weiming Zhao d77a6730b1 [Builtin][ARM] #ifdef ARM vfp tests and cpu_model_tests
Summary:
Add in #ifdef to exclude cpu_model_test on non-X86 and  *vfp_test on ARM targets without VFP support.

This is consistent with other target-specific tests that print "Skipped" if not supported.

Reviewers: rengolin, compnerd, asbirlea

Reviewed By: compnerd

Subscribers: llvm-commits, aemerson

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

llvm-svn: 295261
2017-02-15 23:59:09 +00:00
Tim Shen c6ce73b114 Re-commit r295017, since we have a potential fix of the tests, r295248, landed.
Differential Revision: https://reviews.llvm.org/D29742

llvm-svn: 295251
2017-02-15 22:40:29 +00:00
Tim Shen b39372859f [XRay] Fix gtest error code comparison. NFC.
llvm-svn: 295248
2017-02-15 22:30:54 +00:00
Etienne Bergeron b69639e217 [compiler-rt][asan|win] Fix ASAN exception handler missing import
Summary:
This patch is adding a missing ASAN API redirection from an instrumented DLL.
The bug was introduced here:
  https://reviews.llvm.org/D29463

This is causing this chromium bug:
  https://bugs.chromium.org/p/chromium/issues/detail?id=692580

Reviewers: rnk

Reviewed By: rnk

Subscribers: kubamracek, dberris, llvm-commits, chrisha, thakis

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

llvm-svn: 295232
2017-02-15 20:48:04 +00:00
Sagar Thakur ea831e4c46 [Compiler-rt][XRAY][MIPS] Support xray on mips/mipsel/mips64/mips64el
Summary: Adds support for xray on mips/mipsel/mips64/mips64el.

Reviewed by sdardis, dberris
Differential: D27699

llvm-svn: 295166
2017-02-15 10:54:09 +00:00
Xinliang David Li f2d9481028 [PGO] Delay profile dir creation until write
Differential Revision: http://reviews.llvm.org/D29960

llvm-svn: 295108
2017-02-14 21:39:55 +00:00
Tim Shen 6edc4883fe Revert r295017 "Re-commit r294826 and r294781, with a fix on the cmake file to only"
llvm-svn: 295097
2017-02-14 19:48:13 +00:00
Etienne Bergeron 0ce53e4b9f [compiler-rt][asan|win] Fix flaky unittest due to large allocations
Summary:
Coverage is using large arrays which requires large allocations.
These allocations are flaky and often failing on win64.

We are using the 32-bits size until this gets a better fix.

Reviewers: rnk

Reviewed By: rnk

Subscribers: llvm-commits, kubamracek, chrisha, dberris

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

llvm-svn: 295086
2017-02-14 18:57:17 +00:00
Etienne Bergeron 60ce0f667c [compiler-rt][asan|win] Force tls_init test to use dynamic runtime
Summary:
There is no guarantee that the tls_init is executed on the static runtime
(/MT).

On windows 7, this unittest is failing.
On windows 10, I believe it's working because of the new CRT.

On ASAN side, it doesn't matter that the hook point is run or not.
It must be run only if there is other tls_initializer that are registered.

Reviewers: rnk, chrisha

Reviewed By: rnk

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 295057
2017-02-14 15:21:53 +00:00
Tim Shen b94588eb88 Re-commit r294826 and r294781, with a fix on the cmake file to only
compile on powerpc64le.

I cannot locally reproduce this test failure:
http://lab.llvm.org:8011/builders/sanitizer-ppc64le-linux/builds/1363/steps/test%20standalone%20compiler-rt/logs/stdio

Let's see how the buildbot goes.

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

llvm-svn: 295017
2017-02-14 02:05:47 +00:00
Francis Ricci 8187c7b06b Add cmake build support for lsan on OS X
Summary:
Adds a new cmake flag 'COMPILER_RT_ENABLE_LSAN_OSX', which enables lsan
compilation and is turned off by default. Patches to fix build errors
when this flag is enabled will be uploaded soon.

This is part of an effort to port LSan to OS X, but LSan on OS X does not
currently work or pass tests currently.

Reviewers: kubamracek, kcc, glider, alekseyshl

Reviewed By: kubamracek

Subscribers: danalbert, srhines, mgorny, llvm-commits

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

llvm-svn: 295012
2017-02-14 00:56:53 +00:00
Kuba Mracek 53fc965b48 Fixup for r293885: Update external.cc testcase to include the forgotten stdlib.h.
llvm-svn: 295002
2017-02-13 23:28:06 +00:00
Francis Ricci 7cda03e6d1 Use pthreads to manage thread-local storage on darwin for leak sanitizer
Summary:
__thread is supported on Darwin, but is implemented dynamically via
function calls to __tls_get_addr. This causes two issues when combined
with leak sanitizer, due to malloc() interception.

- The dynamic loader calls malloc during the process of loading
  the sanitizer dylib, while swapping a placeholder tlv_boostrap
  function for __tls_get_addr. This will cause tlv_bootstrap to
  be called in DisabledInThisThread() via the asan allocator.

- The first time __tls_get_addr is called, it allocates memory
  for the thread-local object, during which it calls malloc(). This
  call will be intercepted, leading to an infinite loop in the asan
  allocator, in which the allocator calls DisabledInThisThread,
  which calls tls_get_addr, which calls into the allocator again.

Reviewers: kcc, glider, kubamracek

Subscribers: llvm-commits

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

llvm-svn: 294994
2017-02-13 22:20:07 +00:00
Francis Ricci 259ad9cf08 Disable darwin interception of non-darwin functions
Summary: Fixes build issues when compiling lsan for darwin.

Reviewers: kubamracek, kcc, rnk

Subscribers: llvm-commits

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

llvm-svn: 294984
2017-02-13 21:06:13 +00:00
Francis Ricci 7406f0f54f Add lsan function stubs for darwin
Summary:
This patch provides stubs for all of the lsan platform-specific
functions which need to be implemented for darwin. Currently
all of these functions are stubs, for the purpose of fixing
compilation.

Reviewers: kcc, glider, kubamracek

Subscribers: mgorny, llvm-commits

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

llvm-svn: 294983
2017-02-13 21:03:15 +00:00
Weiming Zhao a164f470e6 [Builtin][ARM] Fix subsf3vfp for non-HF target
Reviewers: rengolin, compnerd

Reviewed By: compnerd

Subscribers: hans, aemerson

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

llvm-svn: 294886
2017-02-12 05:10:25 +00:00
NAKAMURA Takumi eb7dcc8c68 sancov.py: [Py3] Get rid of "print" statement. Use print() or write() instead.
Differential Revision: https://reviews.llvm.org/D27405

llvm-svn: 294880
2017-02-12 00:26:28 +00:00
Vitaly Buka 579ca307ab Re-submit r294826 "Fix -Wsign-compare" reverted in r294842 by mistake.
Fix -Wsign-compare - this might not be quite right, but preserves behavior

llvm-svn: 294868
2017-02-11 19:39:05 +00:00
Vitaly Buka d8230247c9 This reverts commits r294826 and r294781 as they break linking on powerpc.
Revert "Fix -Wsign-compare - this might not be quite right, but preserves behavior"
Revert "[XRay] Implement powerpc64le xray."

This reverts commit r294826.
This reverts commit r294781.

llvm-svn: 294842
2017-02-11 12:34:27 +00:00
David Blaikie 9730789ae6 Fix -Wsign-compare - this might not be quite right, but preserves behavior
llvm-svn: 294826
2017-02-11 06:07:59 +00:00
NAKAMURA Takumi a2eb926e8a sancov.py: [Py3] Use sys.stdout.buffer for bytes.
This is part of https://reviews.llvm.org/D27405

llvm-svn: 294812
2017-02-11 00:16:02 +00:00
Dimitry Andric c18de74165 Remove struct_rtentry_sz on FreeBSD
Summary:
Since struct rtentry is an internal kernel-only structure on FreeBSD,
and SIOCADDRT and SIOCDELRT are not supported anyway, stop including
socketvar.h and attempting to get at the definition of struct rtentry,
and move the line with struct_rtentry_sz to the SANIZER_LINUX block.

Reviewers: kcc, kutuzov.viktor.84, emaste

Reviewed By: kcc, emaste

Subscribers: emaste, llvm-commits, kubamracek

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

llvm-svn: 294806
2017-02-10 23:48:40 +00:00
Kostya Serebryany 4b3ea2d776 s390 CVE-2016-2143 whitelist for RHEL kernels
Summary: This patch adds whitelist for RHEL6 and RHEL7 kernels that are known to have the CVE fixed.

Reviewers: koriakin, kcc

Reviewed By: kcc

Subscribers: kubamracek

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

llvm-svn: 294799
2017-02-10 22:50:44 +00:00
Kostya Serebryany 5b53a2f292 Fix AddressSanitizer on s390 (31-bit)
Summary:
GET_CALLER_PC doesn't work properly on 31-bit s390, as pointers are 31-bit, the MSB bit can be set when the return address is copied into integer.
This causes e.g. errors like:
    #0 0xfdadb129  (<unknown module>)
    #1 0x7da5e1d1 in __asan::GetStackTraceWithPcBpAndContext(__sanitizer::BufferedStackTrace*, unsigned long, unsigned long, unsigned long, void*, bool) ../../../../../libsanitizer/asan/asan_stack.h:50
    #2 0x7da5e1d1 in __asan::ErrorGeneric::Print() ../../../../../libsanitizer/asan/asan_errors.cc:482
    #3 0x7db178d5 in __asan::ErrorDescription::Print() ../../../../../libsanitizer/asan/asan_errors.h:360
    #4 0x7db178d5 in __asan::ScopedInErrorReport::~ScopedInErrorReport() ../../../../../libsanitizer/asan/asan_report.cc:167
    #5 0x7db178d5 in __asan::ReportGenericError(unsigned long, unsigned long, unsigned long, unsigned long, bool, unsigned long, unsigned int, bool) ../../../../../libsanitizer/asan/asan_report.cc:397
    #6 0x7dadb14f in __interceptor_memcmp ../../../../../libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:626
    #7 0x400cf5 in main /home/jakub/gcc/gcc/testsuite/c-c++-common/asan/memcmp-1.c:14
    #8 0x7d807215 in __libc_start_main (/lib/libc.so.6+0x1a215)
    #9 0x4007ed  (/home/jakub/gcc/obj/gcc/testsuite/memcmp-1.exe+0x4007ed)

The actual return PC inside __interceptor_memcmp was 0x7dadb129 rather than 0xfdadb129.

Reviewers: koriakin, kcc

Reviewed By: kcc

Subscribers: kubamracek

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

llvm-svn: 294793
2017-02-10 22:26:19 +00:00
Kostya Serebryany d94ba361e3 s390x __tls_get_addr_internal vs. __tls_get_offset
Summary:
Symbol __tls_get_addr_internal is a GLIBC_PRIVATE private symbol on s390{,x}, the glibc folks aren't very happy about asan using it.
Additionally, only recent glibc versions have it, older versions just have __tls_get_offset and nothing else.
The patch doesn't drop the __tls_get_addr_internal interception altogether, but changes it so that it calls real __tls_get_offset function instead (and much more importantly,
that __tls_get_offset interception calls the real __tls_get_offset function).
This way it should work also on glibc 2.18 and earlier.  See http://gcc.gnu.org/PR79341 for further details.

Reviewers: kcc, koriakin

Reviewed By: kcc, koriakin

Subscribers: kubamracek, mehdi_amini

Tags: #sanitizers

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

llvm-svn: 294790
2017-02-10 22:11:07 +00:00
Tim Shen 918ed871df [XRay] Implement powerpc64le xray.
Summary:
powerpc64 big-endian is not supported, but I believe that most logic can
be shared, except for xray_powerpc64.cc.

Also add a function InvalidateInstructionCache to xray_util.h, which is
copied from llvm/Support/Memory.cpp. I'm not sure if I need to add a unittest,
and I don't know how.

Reviewers: dberris, echristo, iteratee, kbarton, hfinkel

Subscribers: mehdi_amini, nemanjai, mgorny, llvm-commits

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

llvm-svn: 294781
2017-02-10 21:03:24 +00:00
Tim Shen 7d0bffb537 [XRay] Refactor TSC related functions into a single header. NFC.
Summary:
The implementation, however, is in different arch-specific files, unless it's emulated.

Reviewers: dberris, pelikan, javed.absar

Subscribers: aemerson, llvm-commits

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

llvm-svn: 294777
2017-02-10 20:30:43 +00:00
Francis Ricci 2f1f1616ae Remove strict tid checks from the mac implementation of BlockingMutex
Summary:
This patch unifies the behavior of BlockingMutex on linux and mac,
resolving problems that can arise when BlockingMutex is used in
code shared by the two platforms but has different behavior depending
on the platform.

No longer requires that the calling thread own the mutex for
CheckLocked calls to pass.

Reviewers: dvyukov, kubamracek

Subscribers: llvm-commits

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

llvm-svn: 294614
2017-02-09 19:29:11 +00:00
Dean Michael Berris 860247b1bb [XRAY] [compiler-rt] [NFC] Fixing the bit twiddling of Function Id in FDR logging mode.
Summary:
Fixing a bug I found when testing a reader for the FDR format. Function ID is
now correctly packed into the 28 bits which are documented for it instead of being
masked to all ones.

Reviewers: dberris, pelikan, eugenis

Reviewed By: dberris

Subscribers: llvm-commits

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

llvm-svn: 294563
2017-02-09 07:05:42 +00:00
Mike Aizatsky a7d3296957 [sancov] sanitizer coverage initialization test
Summary: Reflects the change in https://reviews.llvm.org/D29662

Subscribers: kubamracek

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

llvm-svn: 294533
2017-02-09 00:01:35 +00:00
Saleem Abdulrasool 8a450fb140 build: repair cross-compilation with clang
When building for Windows, we would check if we were using MSVC rather
than WIN32.  This resulted in needed targets not being defined by
sanitizer_common.  Fix the conditional.

When registering the objects libraries for ASAN, we would multiply
register for all targets as we were creating them inside a loop over all
architectures.  Only define the target per architecture.

llvm-svn: 294510
2017-02-08 20:43:39 +00:00
Bob Haarman d93d7754c4 [sanitizer] if WINAPI is already defined, do not redefine it
Summary: lib/sanitizer_common/sanitizer_win_defs.h defineds WINAPI, which is also defined by standard Windows headers. Redefining it causes warnings during compilation. This change causes us to only define WINAPI if it is not already defined, which avoids the warnings.

Reviewers: rnk, zturner, mpividori

Reviewed By: rnk, mpividori

Subscribers: kubamracek

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

llvm-svn: 294497
2017-02-08 18:34:05 +00:00
NAKAMURA Takumi 9c2d8102d1 asan_symbolize.py: [Py3] Get rid of "print" statement. Use print() or write() instead.
Differential Revision: https://reviews.llvm.org/D27404

llvm-svn: 294450
2017-02-08 14:07:39 +00:00
Michal Gorny 221532c00a [test] #ifdef new builtin tests for __arm__ platform
Add an #if that excludes the newly added aeabi* tests on non-ARM
platforms. This is consistent with other ARM tests, and aims to make
running builtin tests easier. Lacking a proper infrastructure to run
tests selectively, it is more convenient if we do not have to implement
directory-platform exclusions and can just rely on tests compiling to
no-op on other platforms.

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

llvm-svn: 294438
2017-02-08 12:02:48 +00:00
Michal Gorny 123515561f [test] Enable the strace_test only if strace is installed
Differential Revision: https://reviews.llvm.org/D29628

llvm-svn: 294425
2017-02-08 08:43:44 +00:00
Marcos Pividori 0033fcf72e [sanitizer] Add weak hooks for Windows.
Add support for weak hooks on Windows, as we do on Linux and Darwin.
As we use the macro: `SANITIZER_INTERFACE_WEAK_DEF()` it was not necessary to
modify the header file: `sanitizer_common_interceptors.h`.

After this diff, many tests were fixed for libFuzzer.

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

llvm-svn: 294409
2017-02-08 06:31:56 +00:00
Dean Michael Berris ea9042cf8f [XRay][compiler-rt][NFC] Turn ProudCase functions to humbleCase functions
Summary:
As pointed out in casual reading of the XRay codebase, that we had
some interesting named functions that didn't quite follow the LLVM coding
conventions.

Reviewers: chandlerc, dblaikie

Subscribers: llvm-commits

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

llvm-svn: 294373
2017-02-07 23:35:34 +00:00
Kostya Serebryany 263722f40f [asan] replace std::random_shuffle with std::shuffle in tests since std::random_shuffle is being deprecated in C++17; NFC
llvm-svn: 294370
2017-02-07 23:13:10 +00:00
NAKAMURA Takumi b3d0b2d018 sancov.py: [Py3] Use bytes.decode() explicitly.
Or bogus filename like "b'foo'" would be generated.

This is part of https://reviews.llvm.org/D27405

llvm-svn: 294307
2017-02-07 14:13:18 +00:00
NAKAMURA Takumi a80383730e sancov.py: [Py3] Use '//' instead of '/' as division operator.
Py3 emits float with '/'.

This is part of https://reviews.llvm.org/D27405

llvm-svn: 294306
2017-02-07 14:12:45 +00:00
NAKAMURA Takumi ce43bdb3d0 asan_symbolize.py: [Py3] Use text mode with universal_newlines=True for Popen.
With universal_newlines, readline() stalls to fill the buffer. Therefore, let the pipe unbuffered.

This is part of https://reviews.llvm.org/D27404

FIXME: Use Popen.communicate()
llvm-svn: 294303
2017-02-07 14:06:01 +00:00
Alexander Kornienko a8ebc34252 [asan] Remove `using std::vector` and `using std::map`
Looks like these are not needed anymore.

llvm-svn: 294200
2017-02-06 17:28:05 +00:00
Kostya Kortchinsky 031d732a47 [scudo] Fix standalone compiler-rt test breakage
Summary:
Apparently "test standalone compiler-rt" still requires -ldl and -lrt for
Scudo even with --gc-sections. I am not entirely sure why, so if anybody has
some input, feel free to chime in.

In the meantime, add again those two to fix the test.

Reviewers: kcc, alekseyshl

Reviewed By: kcc

Subscribers: Hahnfeld, dberris, llvm-commits

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

llvm-svn: 294199
2017-02-06 17:24:52 +00:00
Weiming Zhao d53f34618b [Builtin][ARM] Implement addsf3/__aeabi_fadd for Thumb1
Summary:
This patch implements addsf3/__aeabi_fadd in asm for Thumb1.
Compared with generic C version (lib/fp_add_impl.inc), it
1. all constants are materialized instead of loading from constant pool
2. no stack spills (C version uses 136 bytes stack space)
3. clz() is called only when necessary. (C version always calls it)

Reviewers: compnerd, rengolin, asl

Reviewed By: asl

Subscribers: efriedma, aemerson, mgorny, llvm-commits

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

llvm-svn: 294172
2017-02-06 06:04:10 +00:00
Dean Michael Berris 73c780a1fc [XRay][compiler-rt] Use gettid instead of getpid in FDR mode.
Summary:
This was pointed out that FDR mode didn't quite put the thread ID in the
buffers, but instead would write down the parent process ID.

Reviewers: pelikan, rSerge

Subscribers: llvm-commits

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

llvm-svn: 294166
2017-02-06 01:48:21 +00:00
Kostya Kortchinsky 93b88f0619 [scudo] Fix buildbot test error on ARM
Summary:
The assumption __sanitizer_get_heap_size() == 0 (introduced in D29341) at the
start of a program appears to be incorrect on some ARM machines
(SizeClassAllocator32).

This should fix the test while I investigate the issue.

Reviewers: kcc, alekseyshl

Reviewed By: alekseyshl

Subscribers: aemerson, rengolin, llvm-commits

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

llvm-svn: 294056
2017-02-03 21:59:00 +00:00
Kostya Kortchinsky 8d6257b4bf [scudo] 32-bit quarantine sizes adjustments and bug fixes
Summary:
The local and global quarantine sizes were not offering a distinction for
32-bit and 64-bit platforms. This is addressed with lower values for 32-bit.

When writing additional tests for the quarantine, it was discovered that when
calling some of the allocator interface function prior to any allocation
operation having occured, the test would crash due to the allocator not being
initialized. This was addressed by making sure the allocator is initialized
for those scenarios.

Relevant tests were added in interface.cpp and quarantine.cpp.

Last change being the removal of the extraneous link dependencies for the
tests thanks to rL293220, anf the addition of the gc-sections linker flag.

Reviewers: kcc, alekseyshl

Reviewed By: alekseyshl

Subscribers: llvm-commits

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

llvm-svn: 294037
2017-02-03 20:49:42 +00:00
Simon Dardis 75bdd93720 [sancov] Disable failing test for MIPS.
Currently unsupported.

llvm-svn: 294033
2017-02-03 20:16:07 +00:00
Maxim Ostapenko 490c508b1d [lsan] Disable sem_init_glibc.cc testcase for LSan x86.
This test relies on sanitizer common interceptor to pick the oldest version of
sem_init function from Glibc. But LSan actually doesn't intercept sem_init, thus
the new implementation is called that causes test failure. Disable it for LSan x86,
the proper fix would require to check Glibc version at runtime and adjust
GET_SEM_VALUE(V) accordingly. 

llvm-svn: 294001
2017-02-03 11:57:26 +00:00
Maxim Ostapenko e5f2bfaea9 [sanitizer] Fix 'dyld: Symbol not found: _memmem' linkage error on Darwin 10.6
This patch tries to fixes sanitizer linkage errors on Darwin 10.6 originally reporded
in GCC's pr78663 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78663).

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

llvm-svn: 293992
2017-02-03 06:58:14 +00:00
Marcos Pividori c1f8a82491 [sancov] Define delimiters for sanitizer coverage's binary section on Windows.
On Windows, the symbols "___stop___sancov_guards" and "___start___sancov_guards"
are not defined automatically. So, we need to take a different approach.
We define 3 sections: ".SCOV$A", ".SCOV$M" and ".SCOV$Z".

 Section ".SCOV$A" will only hold a variable ___start___sancov_guard.
 Section ".SCOV$M" will hold the main data.
 Section ".SCOV$Z" will only hold a variable ___stop___sancov_guards.

When linking, they will be merged sorted by the characters after the $, so we
can use the pointers of the variables ___[start|stop]___sancov_guard to know the
actual range of addresses of that section.

___[start|stop]___sancov_guard should be defined only once per module. On
Windows, we have 2 different cases:

+ When considering a shared runtime:
 All the modules, main executable and dlls, are linked to an auxiliary static
 library dynamic_runtime_thunk.lib. Because of that, we include the delimiters
 in `SancovDynamicRuntimeThunk`.

+ When considering a static runtime:
 The main executable in linked to the static runtime library.
 All the dlls are linked to an auxiliary static library dll_thunk.
 Because of that, we include the delimiter to both `SancovDllThunk` and
 `SANITIZER_LIBCDEP_SOURCES` (which is included in the static runtime lib).

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

llvm-svn: 293959
2017-02-02 23:02:15 +00:00
Marcos Pividori 2b9c44e226 [sanitizer] Use interception to access to strong definitions in the executable.
In Windows, when sanitizers are implemented as a shared library (DLL), users can
redefine and export a new definition for weak functions, in the main executable,
for example:

extern "C" __declspec(dllexport)
void __sanitizer_cov_trace_pc_guard(u32* guard) {
  // Different implementation provided by the client.
}

However, other dlls, will continue using the default implementation imported
from the sanitizer dll. This is different in linux, where all the shared
libraries will consider the strong definition.

With the implementation in this diff, when the dll is initialized, it will check
if the main executable exports the definition for some weak function (for
example __sanitizer_cov_trace_pc_guard). If it finds that function, then it will
override the function in the dll with that pointer. So, all the dlls with
instrumentation that import __sanitizer_cov_trace_pc_guard__dll() from asan dll,
will be using the function provided by the main executable.

In other words, when the main executable exports a strong definition for a weak
function, we ensure all the dlls use that implementation instead of the default
weak implementation.

The behavior is similar to linux. Now, every user that want to override a weak
function, only has to define and export it. The same for Linux and Windows, and
it will work fine. So, there is no difference on the user's side.

All the sanitizers will include a file sanitizer_win_weak_interception.cc that
register sanitizer's weak functions to be intercepted in the binary section WEAK

When the sanitizer dll is initialized, it will execute weak_intercept_init()
which will consider all the CB registered in the section WEAK. So, for all the
weak functions registered, we will check if a strong definition is provided in
the main executable.

All the files sanitizer_win_weak_interception.cc are independent, so we do not
need to include a specific list of sanitizers.
Now, we include [asan|ubsan|sanitizer_coverage]_win_weak_interception.cc and
sanitizer_win_weak_interception.cc in asan dll, so when it is initialized, it
will consider all the weak functions from asan, ubsan and sanitizer coverage.

After this diff, sanitizer coverage is fixed for MD on Windows. In particular
libFuzzer can provide custom implementation for all sanitizer coverage's weak
functions, and they will be considered by asan dll.

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

llvm-svn: 293958
2017-02-02 23:02:11 +00:00
Marcos Pividori e49ec6d57c [asan] Intercept SetUnhandledExceptionFilter.
In this diff I update the code for asan on Windows, so we can intercept
SetUnhandledExceptionFilter and catch some exceptions depending on the result of
IsHandledDeadlyException() (which depends on asan flags).

This way we have the same behavior on Windows and Posix systems.
On Posix, we intercept signal and sigaction, so user's code can only register
signal handlers for signals that are not handled by asan.
After this diff, the same happens on Windows, user's code can only register
exception handlers for exceptions that are not handled by asan.

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

llvm-svn: 293957
2017-02-02 23:02:04 +00:00
Marcos Pividori fe9288a6a0 [sanitizer] Move DescribeSignalOrException to sanitizer_common.
Differential Revision: https://reviews.llvm.org/D29459

llvm-svn: 293956
2017-02-02 23:01:59 +00:00
Marcos Pividori ee22156b78 [sanitizer] Move exception code to sanitizer_common.
Differential Revision: https://reviews.llvm.org/D29458

llvm-svn: 293955
2017-02-02 23:01:51 +00:00
Marcos Pividori 387210c6c8 [asan] Properly handle exceptions.
Differential Revision: https://reviews.llvm.org/D29457

llvm-svn: 293954
2017-02-02 23:01:46 +00:00
Marcos Pividori b88e87d4b2 [sanitizer] Add dynamic_runtime_thunk for different sanitizers.
In Windows, when the sanitizer is implemented as a shared library (DLL), we need
an auxiliary static library dynamic_runtime_thunk that will be linked to the
main executable and dlls.

In the sanitizer DLL, we are exposing weak functions with WIN_WEAK_EXPORT_DEF(),
which exports the default implementation with __dll suffix. For example: for
sanitizer coverage, the default implementation of __sanitizer_cov_trace_cmp is
exported as: __sanitizer_cov_trace_cmp__dll.

In the dynamic_runtime_thunk static library, we include weak aliases to the
imported implementation from the dll, using the macro WIN_WEAK_IMPORT_DEF().

By default, all users's programs that include calls to weak functions like
__sanitizer_cov_trace_cmp, will be redirected to the implementation in the dll,
when linking to dynamic_runtime_thunk.

After this diff, we are able to compile code with sanitizer coverage
instrumentation on Windows. When the instrumented object files are linked with
clang-rt_asan_dynamic_runtime_thunk-arch.lib all the weak symbols will be
resolved to the implementation imported from asan dll.

All the files sanitizer_dynamic_runtime_thunk.cc are independent, so we do not
need to include a specific list of sanitizers.
Now, we compile: [asan|ubsan|sanitizer_coverage]_win_dynamic_runtime_thunk.cc
and sanitizer_win_dynamic_runtime_thunk.cc to generate
asan_dynamic_runtime_thunk.lib, because we include asan, ubsan and sanitizer
coverage in the address sanitizer library.

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

llvm-svn: 293953
2017-02-02 23:01:41 +00:00
Marcos Pividori f5d265460d [sanitizer] Intercept weak functions in dll_thunks.
In this diff, I update current implementation of the interception in dll_thunks
to consider the special case of weak functions.
First we check if the client has redefined the function in the main executable
(for example: __sanitizer_cov_trace_pc_guard). It we can't find it, then we look
for the default implementation (__sanitizer_cov_trace_pc_guard__dll). The
default implementation is always available because the static runtime is linked
to the main executable.

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

llvm-svn: 293952
2017-02-02 23:01:34 +00:00
Marcos Pividori bfdfaa11ca [sanitizer] Split dll_thunks into different sanitizers.
When the sanitizer is implemented as a static library and is included in the
main executable, we need an auxiliary static library dll_thunk that will be
linked to the dlls that have instrumentation, so they can refer to the runtime
in the main executable. Basically, it uses interception to get a pointer the
function in the main executable and override its function with that pointer.

Before this diff, all of the implementation for dll_thunks was included in asan.
In this diff I split it into different sanitizers, so we can use other
sanitizers regardless of whether we include asan or not.

All the sanitizers include a file sanitizer_win_dll_thunk.cc that register
functions to be intercepted in the binary section: DLLTH

When the dll including dll_thunk is initialized, it will execute
__dll_thunk_init() implemented in: sanitizer_common/sanitizer_win_dll_thunk.cc,
which will consider all the CB registered in the section DLLTH. So, all the
functions registered will be intercepted, and redirected to the implementation
in the main executable.

All the files "sanitizer_win_dll_thunk.cc" are independent, so we don't need to
include a specific list of sanitizers. Now, we compile:  asan_win_dll_thunk.cc
ubsan_win_dll_thunk.cc,  sanitizer_coverage_win_dll_thunk.cc and
sanitizer_win_dll_thunk.cc, to generate asan_dll_thunk, because we include asan,
ubsan and sanitizer coverage in the address sanitizer library.

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

llvm-svn: 293951
2017-02-02 23:01:28 +00:00
Bill Seurer f2611acfec [powerpc] deactivate user_malloc.cc tsan test on powerpc64le
This test fails consistently on Ubuntu 16.xx powerpc64 LE systems.
The cause is being investigated and in the meantime disable it so
the buildbots can run cleanly.

llvm-svn: 293939
2017-02-02 21:32:07 +00:00
Vitaly Buka 89d054fc64 [compiler-rt] Fix incorrect use of snprintf
Summary:
snprintf returns buffer size needed for printing. If buffer was small, calling
code receives incorrectly symbolized buffer and fail.

Reviewers: eugenis

Subscribers: kubamracek, dberris, kcc

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

llvm-svn: 293930
2017-02-02 20:10:07 +00:00
Kuba Mracek aa78ad5fea [tsan] Provide API for libraries for race detection on custom objects
This patch allows a non-instrumented library to call into TSan runtime, and tell us about "readonly" and "modifying" accesses to an arbitrary "object" and provide the caller and tag (type of object).  This allows TSan to detect violations of API threading contracts where "read-only" methods can be called simulatenously from multiple threads, while modifying methods must be exclusive.

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

llvm-svn: 293885
2017-02-02 13:17:05 +00:00
Kuba Mracek 5c88271528 Fixup of r293882: Forgot to update sanitizer_thread_registry.test.cc
llvm-svn: 293884
2017-02-02 13:07:22 +00:00
Kuba Mracek bba1d40589 [tsan] Properly describe GCD worker threads in reports
When dealing with GCD worker threads, TSan currently prints weird things like "created by thread T-1" and "[failed to restore the stack]" in reports. This patch avoids that and instead prints "Thread T3 (...) is a GCD worker thread".

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

llvm-svn: 293882
2017-02-02 12:54:21 +00:00
Dean Michael Berris 607617b004 [XRay] Probe for CPU features that XRay needs
Summary:
In llvm.org/PR31756 it's pointed out that sometimes rdtscp isn't
available. We fix it here by checking first whether it's availble before
installing the logging handler. In future commits we can have
alternative implementations, maybe working around some of the
constraints on some systems.

This change enables us to make that determination, but report an error
instead when the features aren't available.

Reviewers: sdardis, javed.absar, rSerge

Subscribers: pelikan, llvm-commits

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

llvm-svn: 293870
2017-02-02 07:51:21 +00:00
Justin Bogner d6d57bb359 [asan] Support handle_sigfpe on Darwin
llvm-svn: 293746
2017-02-01 07:54:36 +00:00
Justin Bogner 05cfdb936a [sanitizer] Support SANITIZER_INTERCEPTOR_HOOKS on Darwin
This basically already worked other than weak symbols needing
definitions on darwin.

llvm-svn: 293741
2017-02-01 03:31:09 +00:00
Justin Bogner aded0f85e3 Remove XFAIL from the sanitizer guard test for darwin
This works as of "Support sanitizer guard section on darwin" in the
llvm repo.

llvm-svn: 293734
2017-02-01 02:38:42 +00:00
Marcos Pividori e72c69bb0a [sancov] Move __sancov_default_options declaration outside the namespace __sancov
After this commint, we can include sancov_flags.h and refer to
__sancov_default_options without requiring the namespace prefix.

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

llvm-svn: 293731
2017-02-01 01:36:19 +00:00
Marcos Pividori 8789a5a9f6 [sanitizer] Fix interface tests when SANITIZER_CAN_USE_CXXABI is true.
We ignore `__ubsan_handle_dynamic_type_cache_miss*` symbols when
`SANITIZER_CAN_USE_CXXABI` is true. Because they are included in the
library but they are not included in the interface lists.

llvm-svn: 293711
2017-01-31 22:57:55 +00:00
Marcos Pividori 8dac0cede7 [sanitizer] Fix interface test on Darwin, failing after 293682.
The test was failing because we export the functions: "__sanitizer_mz*" but they
are not included in the general interface lists.
Also, weak undefined symbols are tagged with U by `nm -g` on Darwin.

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

llvm-svn: 293710
2017-01-31 22:57:50 +00:00
Marcos Pividori 25527bf021 [sanitizer] Add list of symbols exported in sanitizers' interface.
Add a new auxiliary file to each sanitizer: sanitizer_interface.inc, listing all
the functions exported, with the macros: INTERFACE_FUNCTION() and
INTERFACE_WEAK_FUNCTION().
So, when we need to define or repeat a procedure for each function in the
sanitizer's interface, we can define the macros and include that header.
In particular, these files are needed for Windows, in the nexts commits.
Also, this files could replace the existing files: weak_symbols.txt for Apple.
Instead of reading weak_symbols.txt to get the list of weak symbols, we could
read the file sanitizer_interface.inc and consider all the symbols included with
the macro INTERFACE_WEAK_FUNCTION(Name).

In this commit, I only include these files to the sanitizers that work on
Windows. We could do the same for the rest of the sanitizers when needed.

I updated tests for: Linux, Darwin and Windows. If a new function is exported
but is not present in the interface list, the tests
"interface_symbols_[darwin|windows|linux].c" fail.

Also, I remove the comments: "/* OPTIONAL */" which are not required any more,
because we use the macro: INTERFACE_WEAK_FUNCTION() for weak functions.

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

llvm-svn: 293682
2017-01-31 20:23:21 +00:00
Marcos Pividori e9e0769764 [sanitizer] Define as weak, functions that are declared as weak.
Differential Revision: https://reviews.llvm.org/D29228

llvm-svn: 293681
2017-01-31 20:23:14 +00:00
Marcos Pividori c6c38b7537 [asan] Export __sancov_* symbols symbols.
Add __sancov_* symbols to the export list.

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

llvm-svn: 293680
2017-01-31 20:23:07 +00:00
Marcos Pividori 6342cf9dc3 [sancov] Add new sanitizer coverage functions to the internal interface.
Differential Revision: https://reviews.llvm.org/D28597

llvm-svn: 293672
2017-01-31 18:37:18 +00:00
Marcos Pividori 9de8f5910f [sanitizer] Ensure macro parameters are expanded before stringifying.
Add auxiliary macro to ensure parameters are expanded before stringifying.

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

llvm-svn: 293671
2017-01-31 18:37:07 +00:00
Maxim Ostapenko 7d8f1deafc [lsan] Fix typo in stale_stack_leak.cc testcase
llvm-svn: 293644
2017-01-31 16:32:58 +00:00
Maxim Ostapenko dbaacc7566 [lsan] Disable stale_stack_leak.cc testcase on x86
llvm-svn: 293621
2017-01-31 12:59:04 +00:00
Maxim Ostapenko 651cfe3cfa [lsan] Renable LSan for x86 Linux
The missed clang part was committed at https://reviews.llvm.org/rL293609 thus
we can reenable LSan for x86 Linux.

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

llvm-svn: 293610
2017-01-31 07:15:37 +00:00
Tim Shen f63f58a28f [compiler-rt] Don't change g_tls_size after initialization.
Summary:
g_tls_size is not supposed to be changed after initialization. It's not
atomic, not guarded by a lock, nor thread_local. But it's read by
multiple threads.

The reason why it's mutated is mips and powerpc64 specific. We can
implement the same funcitonality without mutating g_tls_size.

I'm not sure how to write a test for this. Please advice. Thanks!

Reviewers: eugenis, kcc

Subscribers: kubamracek, dberris, llvm-commits

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

llvm-svn: 293586
2017-01-31 01:53:36 +00:00
Kostya Kortchinsky 2282ede5a8 [sanitizer] Re-enable -fno-function-sections for powerpc64le
Summary:
For a reason that hasn't been investigated for lack of powerpc knowledge and
hardware, -fno-function-sections is required for the Sanitizers to work
properly on powerpc64le. Without, the function-sections-are-bad test fails on
that architecture (and that architecture only).

This patch re-enables the flag in the powerpc64le cflags.

I have to admit I am not entirely sure if my way is the proper way to do this,
so if anyone has a better way, I'll be happy to oblige.

Reviewers: kcc, eugenis

Reviewed By: eugenis

Subscribers: nemanjai, mgorny, llvm-commits

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

llvm-svn: 293558
2017-01-30 22:31:49 +00:00
Dimitry Andric f2ac1d1df2 Recommit: Stop intercepting some malloc-related functions on FreeBSD and
macOS

Summary:
In https://bugs.freebsd.org/215125 I was notified that some configure
scripts attempt to test for the Linux-specific `mallinfo` and `mallopt`
functions by compiling and linking small programs which references the
functions, and observing whether that results in errors.

FreeBSD and macOS do not have the `mallinfo` and `mallopt` functions, so
normally these tests would fail, but when sanitizers are enabled, they
incorrectly succeed, because the sanitizers define interceptors for
these functions.  This also applies to some other malloc-related
functions, such as `memalign`, `pvalloc` and `cfree`.

Fix this by not intercepting `mallinfo`, `mallopt`, `memalign`,
`pvalloc` and `cfree` for FreeBSD and macOS, in all sanitizers.

Also delete the non-functional `cfree` wrapper for Windows, to fix the
test cases on that platform.

Reviewers: emaste, kcc, rnk

Subscribers: timurrrr, eugenis, hans, joerg, llvm-commits, kubamracek

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

llvm-svn: 293536
2017-01-30 19:06:13 +00:00
Weiming Zhao a000b467d3 [Bultin][ARM] Make aeabi_uldivmod and aeabi_ldivmod be Thumb1 compatible
Summary:
in aeabi_ldivmod and uldivmod, using r6 instead of r12 as the temp reg due to limitation of Thumb1 ISA.
Now, all EABI sources are Thumb1 compatible.

Also added test cases by reusing the test cases from divmodsi4_test.c, udivmodsi4_test and udivmoddi4_test.c

Reviewers: rengolin, compnerd

Reviewed By: rengolin

Subscribers: javed.absar, aemerson, mgorny, llvm-commits

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

llvm-svn: 293527
2017-01-30 18:48:05 +00:00
Marcos Pividori 7ac943c463 [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: 293521
2017-01-30 18:23:37 +00:00
Serge Rogatch 7ccb24f8cb [XRay][ARM32][AArch64] Fix unstable FDR tests on weak-ordering CPUs
Summary: Change from `compare_exchange_weak()` to `compare_exchange_strong()` where appropriate, because on ARM ( http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/3190 , http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/3191 ) and AArch64 ( http://lab.llvm.org:8011/builders/clang-cmake-aarch64-42vma/builds/3900 ) it fails even in single-threaded scenarios.

Reviewers: dberris, rengolin

Reviewed By: rengolin

Subscribers: aemerson, llvm-commits, iid_iunknown

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

llvm-svn: 293505
2017-01-30 17:10:49 +00:00
Marcos Pividori bf0261d518 [asan] Fix tests for exported interfaces.
Add "OPTIONAL" comment to declaration of weak function in the internal
interface. This fix the tests `interface_symbols_linux.c` and
`interface_symbols_darwin.c` which were failing after r293423.

llvm-svn: 293442
2017-01-29 20:19:08 +00:00
Marcos Pividori 62a188d623 [asan] Add missing declaration in the internal interface
Differential Revision: https://reviews.llvm.org/D29230

llvm-svn: 293423
2017-01-29 06:14:55 +00:00
Marcos Pividori 35e60eeb6e [windows] Properly use dllimport / dllexport.
Update the headers, so we can change the dllexports to dllimport when
defining SANITIZER_IMPORT_INTERFACE.

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

llvm-svn: 293422
2017-01-29 06:11:32 +00:00
Marcos Pividori 8650f5d1a1 General definition for weak functions
In this diff, I define a general macro for defining weak functions
with a default implementation: "SANITIZER_INTERFACE_WEAK_DEF()".
This way, we simplify the implementation for different platforms.

For example, we cannot define weak functions on Windows, but we can
use linker pragmas to create an alias to a default implementation.
All of these implementation details are hidden in the new macro.

Also, as I modify the name for exported weak symbols on Windows, I
needed to temporarily disable "dll_host" test for asan, which checks
the list of functions included in asan_win_dll_thunk.

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

llvm-svn: 293419
2017-01-29 05:44:59 +00:00
Evgeniy Stepanov 8bf0633288 Revert "Stop intercepting some malloc-related functions on FreeBSD and macOS"
This reverts r293337, which breaks tests on Windows:

malloc-no-intercept-499eb7.o : error LNK2019: unresolved external symbol _mallinfo referenced in function _main

llvm-svn: 293346
2017-01-27 23:53:20 +00:00
Dimitry Andric 47e0ef3148 Stop intercepting some malloc-related functions on FreeBSD and macOS
Summary:
In https://bugs.freebsd.org/215125 I was notified that some configure
scripts attempt to test for the Linux-specific `mallinfo` and `mallopt`
functions by compiling and linking small programs which references the
functions, and observing whether that results in errors.

FreeBSD and macOS do not have the `mallinfo` and `mallopt` functions, so
normally these tests would fail, but when sanitizers are enabled, they
incorrectly succeed, because the sanitizers define interceptors for
these functions.  This also applies to some other malloc-related
functions, such as `memalign`, `pvalloc` and `cfree`.

Fix this by not intercepting `mallinfo`, `mallopt`, `memalign`,
`pvalloc` and `cfree` for FreeBSD and macOS, in all sanitizers.

Reviewers: emaste, kcc

Subscribers: hans, joerg, llvm-commits, kubamracek

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

llvm-svn: 293337
2017-01-27 22:19:11 +00:00
Weiming Zhao 68e20da3f9 [Builtin][ARM] Add Thumb1 support for aeabi_c{f,d}cmp.S and dcmp.S
Reviewers: compnerd, rengolin

Reviewed By: rengolin

Subscribers: aemerson, llvm-commits, mgorny

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

llvm-svn: 293247
2017-01-27 01:21:00 +00:00
Kostya Kortchinsky fb275a48b8 [sanitizer] Remove -fno-function-sections from SANITIZER_COMMON_CFLAGS
Summary:
-fno-function-sections was added as a default Sanitizer common cflag with
https://reviews.llvm.org/rL200683, the reasoning behind was that things would
break if linked with --gc-sections.

This appears to not be necessary anymore, as tests pass without, including
function-sections-are-bad.cc. There is a large benefit to having
function-sections when dealing with static libraries in terms of size and
dependencies that go away with --gc-sections.

Reviewers: kcc, eugenis

Reviewed By: eugenis

Subscribers: llvm-commits, mgorny

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

llvm-svn: 293220
2017-01-26 22:50:22 +00:00
Kuba Mracek 6393aa3a62 [tsan] Fix os_id of main thread
Currently, os_id of the main thread contains the PID instead of a thread ID. Let's fix this.

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

llvm-svn: 293201
2017-01-26 19:20:30 +00:00
Oleg Ranevskyy 41abca4355 [Compiler-rt] Broken compiler-rt CMake configuring on Windows
Summary:
Hi Michal,

Would you be able to review this simple fix, please?

Since r291504 compiler-rt uses `llvm-config --cmakedir` to get the path to the LLVM CMake modules.
On Windows this option returns Windows style path with backslashes. CMake treats backslashes as beginning of an escaped character and thus fails to append the path to `CMAKE_MODULE_PATH`.

Reviewers: compnerd, mgorny

Reviewed By: mgorny

Subscribers: compnerd, llvm-commits, dberris

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

llvm-svn: 293195
2017-01-26 18:16:02 +00:00
Serge Rogatch c4540b371d [XRay][Arm32] Reduce the portion of the stub and implement more staging for tail calls - in compiler-rt
Summary:
This patch provides more staging for tail calls in XRay Arm32 . When the logging part of XRay is ready for tail calls, its support in the core part of XRay Arm32 may be as easy as changing the number passed to the handler from 1 to 2.
Coupled patch:
- https://reviews.llvm.org/D28673

Reviewers: dberris, rengolin

Reviewed By: dberris, rengolin

Subscribers: llvm-commits, iid_iunknown, aemerson

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

llvm-svn: 293186
2017-01-26 16:18:13 +00:00
Saleem Abdulrasool 309b3bfa6a builtins: remove an errant ':'
Thanks to Dave Lee for pointing this out!

llvm-svn: 293120
2017-01-26 00:37:55 +00:00
Serge Rogatch fa846a116e [XRay][AArch64] More staging for tail call support in XRay AArch64 - in compiler-rt
Summary:
This patch provides a trampoline for function tail exit tracing. Still, it's staging because code `1` is passed to the handler function (indicating a normal exit) instead of `2`, which would indicate tail exit. This is so until the logging part of XRay supports tail exits too.
Related: https://reviews.llvm.org/D28947 (LLVM)

Reviewers: dberris, rengolin

Reviewed By: rengolin

Subscribers: aemerson, llvm-commits, iid_iunknown

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

llvm-svn: 293082
2017-01-25 20:27:19 +00:00
Kostya Kortchinsky 198f864c07 [scudo] Enabling AArch64 support for Scudo
Summary:
Adding ARM64 as a supported architecture for Scudo.
The random shuffle is not yet supported for SizeClassAllocator32, which is used
by the AArch64 allocator, so disable the associated test for now.

Reviewers: kcc, alekseyshl, rengolin

Reviewed By: rengolin

Subscribers: aemerson, mgorny, llvm-commits

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

llvm-svn: 293068
2017-01-25 16:35:18 +00:00
Bill Seurer 710e821ddc [powerpc] deactivate ThreadedOneSizeMallocStressTest asan test on powerpc64
This has not reliably worked on powerpc since r279664.  Re-enable this
once the problem is tracked down and fixed.

llvm-svn: 293066
2017-01-25 16:03:27 +00:00
Krzysztof Parzyszek 520e51d951 [compiler-rt] Fix xray compilation errors: errno and size_t
Include errno.h, and use size_t instead of std::size_t, since stddef.h
was included (and not cstddef).

llvm-svn: 293057
2017-01-25 14:20:30 +00:00
Dean Michael Berris e7dbebf182 [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: 293015
2017-01-25 03:50:46 +00:00
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
Reid Kleckner 310c3d3d26 Fix pc_array bounds check to use elements instead of bytes
pc_array_size and kPcArrayMaxSize appear to be measured in elements, not
bytes, so we shouldn't multiply idx by sizeof(uptr) in this bounds
check.  32-bit Chrome was tripping this assertion because it has 64
million coverage points. I don't think it's worth adding a test that has
that many coverage points.

llvm-svn: 292955
2017-01-24 17:45:35 +00:00