Commit Graph

4814 Commits

Author SHA1 Message Date
Renato Golin 6d41f7ae22 UBSAN stable runtime more generic with arm* targets
llvm-svn: 219924
2014-10-16 12:43:10 +00:00
Renato Golin 45abb8c969 Adds stable-runtime to ubsan to avoid broken ARM tests with asan
llvm-svn: 219906
2014-10-16 07:48:27 +00:00
Kuba Brecka 14c0c5901d [compiler-rt] compiler-rt's CMake append_if function clashes with LLVM's, let's rename it to append_list_if
Doing s/append_if/append_list_if/, no functional change.

http://reviews.llvm.org/D5739

llvm-svn: 219860
2014-10-15 22:47:54 +00:00
Will Schmidt a286594237 [compiler-rt] Enable ASAN for powerpc64le-linux
Whitespace update for lint check by myself (Will).  Otherwise code and comments by Peter Bergner, as previously seen on llvm-commits. 

    The following patch gets ASAN somewhat working on powerpc64le-linux.
    It currently assumes the LE kernel uses 46-bit addressing, which is
    true, but it doesn't solve the case for BE where it may be 44 or
    46 bits.  That can be fixed with a follow on patch.
    
    There are some test suite fails even with this patch that I haven't had
    time to solve yet, but this is better than the state it is in now.
    The limited debugging of those test suite fails seems to show that the
    address map for 46-bit addressing has changed and so we'll need to
    modify the shadow memory location slightly.  Again, that can be fixed
    with a follow on patch.

llvm-svn: 219827
2014-10-15 18:34:04 +00:00
Alexey Samsonov 76c875579a [CMake] Cleanup CMake rules after r219302. NFC.
llvm-svn: 219825
2014-10-15 18:23:57 +00:00
Alexey Samsonov 6c386e229b [UBSan] [MIPS] Adding support of UBSan for mipsel arch
Summary:
Changed files:
config-ix.cmake: Added mipsel to UBSAN_SUPPORTED_ARCH

Reviewers: rsmith, kcc, dsanders, petarj, samsonov

Reviewed By: samsonov

Subscribers: llvm-commits, mohit.bhakkad, farazs, kumarsukhani

Differential Revision: http://reviews.llvm.org/D5750

llvm-svn: 219822
2014-10-15 18:04:42 +00:00
Viktor Kutuzov 6b862f22e5 [Tsan] Fix the sunrpc.cc test to build on FreeBSD
Differential Revision: http://reviews.llvm.org/D5730

llvm-svn: 219791
2014-10-15 12:47:48 +00:00
Viktor Kutuzov adcf1ce904 [Tsan] Make the mutex_robust tests Linux-specific
Differential Revision: http://reviews.llvm.org/D5729

llvm-svn: 219790
2014-10-15 12:43:04 +00:00
Dmitry Vyukov 6373829449 tsan: fix false positive related to signals
Write interceptor calls malloc, which causes a false
unsafe-call-in-signal-handler report. See the test.

llvm-svn: 219784
2014-10-15 08:56:43 +00:00
Dmitry Vyukov a08a8dc01d tsan: use a different dir for llvm build
build is used as gtest temp build dir, and is cleared during every build

llvm-svn: 219783
2014-10-15 08:56:15 +00:00
Dmitry Vyukov f03e719f23 tsan: remove dead code
llvm-svn: 219779
2014-10-15 05:38:49 +00:00
Ed Maste 3ba162d2f9 Fix compiler-rt build on FreeBSD 10.1
We have to #define _WANT_RTENTRY to get struct rtentry, and add headers
that it depends on.

SIOCADDRT and SIOCDELRT also do not exist in FreeBSD 10.1 and were removed
in FreeBSD rev. 263203:

  Garbage collect long time obsoleted (or never used) stuff from routing
  API.

Differential Revision: http://reviews.llvm.org/D5703

llvm-svn: 219722
2014-10-14 21:08:35 +00:00
Renato Golin 498b223eec Re-enable ASAN/UBSAN tests on ARM, with VFP3 they began to pass
When compiling with -mfpu=vfpv3, those tests began to pass, like the others
with "Illegal Instruction" error, so removing the XFAIL from them should
get the bot green (and have more tests!).

llvm-svn: 219721
2014-10-14 21:00:22 +00:00
Bob Wilson ca0a38e0ae Add complex multiply/divide functions to arm64 iOS libclang_rt libraries.
Clang r219557 introduces libcalls to complex multiply/divide functions.
Since these functions are not available in iOS for arm64 devices, add them to
the static libraries.

llvm-svn: 219715
2014-10-14 20:33:36 +00:00
Alexey Samsonov 37efdf0033 [UBSan] XFAIL test added in r219642 on Darwin
llvm-svn: 219699
2014-10-14 17:31:15 +00:00
Evgeniy Stepanov 9e984c5137 [sanitizer] Fix a crash in FP unwinder on ARM.
This change fixes 2 issues in the fast unwinder from r217079:
* A crash if a frame pointer points below current stack head, but
  inside the current thread stack limits. That memory may be
  unmapped. A check for this was lost in r217079.
* The last valid stack frame (the first one with an invalid next
  frame pointer) is always interpreted as a GCC layout frame. This
  results in garbled last PC in the (expected) case when the last
  frame has LLVM layout.

llvm-svn: 219683
2014-10-14 13:46:07 +00:00
Renato Golin 8fcae0b35e Fix silly commit to disable test on ARM
llvm-svn: 219681
2014-10-14 12:32:47 +00:00
Renato Golin 3743568735 Disable failing ASAN LongJump test on ARM
Updated the URL to reflect information on the problem as well as build the
case for ARM. This seems to be a wider problem, not ARM or PPC specific.

llvm-svn: 219680
2014-10-14 12:24:28 +00:00
Dmitry Vyukov 4eebdf22ef tsan: remove trailing whitespace
llvm-svn: 219678
2014-10-14 09:46:56 +00:00
Evgeniy Stepanov f518a4e774 [asan] Add fast_unwind_on_check flag.
Allows to specify the unwinder to use for CHECK failures. Previous behaviour
was to use the "fatal" unwinder.
As compiler-rt is built without frame pointers, only the slow unwinder
really makes sense here, and it is the default.

llvm-svn: 219677
2014-10-14 09:36:24 +00:00
Dmitry Vyukov ea2f3bffca tsan: refactor atexit handling
The current handling (manual execution of atexit callbacks)
is overly complex and leads to constant problems due to mutual ordering of callbacks.
Instead simply wrap callbacks into our wrapper to establish
the necessary synchronization.
Fixes issue https://code.google.com/p/thread-sanitizer/issues/detail?id=80

llvm-svn: 219675
2014-10-14 09:32:45 +00:00
Alexey Samsonov eb47d8a2c8 Sanitize upcasts and conversion to virtual base.
This change adds UBSan check to upcasts. Namely, when we
perform derived-to-base conversion, we:
1) check that the pointer-to-derived has suitable alignment
   and underlying storage, if this pointer is non-null.
2) if vptr-sanitizer is enabled, and we perform conversion to
   virtual base, we check that pointer-to-derived has a matching vptr.

llvm-svn: 219642
2014-10-13 23:59:00 +00:00
Filipe Cabecinhas 830c45e5de Fix minor typos in comments.
llvm-svn: 219632
2014-10-13 21:40:52 +00:00
Dmitry Vyukov 02ff8bb986 tsan: better reporting for virtual-call-after-free
Previously we said that it's a data race, which is confusing
if it happens in the same thread.

llvm-svn: 219600
2014-10-13 08:46:25 +00:00
Chandler Carruth 30bdfa7f99 [UBSan] Disable one run line of this test to allow the test as a whole
to pass in an opt build.

The test case in question does show UBSan catching the error, but it
doesn't then successfully set the exit code of the program. I'll let the
UBSan folks sort out why. It should reproduce trivially with an
optimized build.

llvm-svn: 219563
2014-10-11 06:49:00 +00:00
Alexey Samsonov 19c2e631bd [UBSan] Fix UBSan testcase for float->int conversion after LLVM r219542.
llvm-svn: 219559
2014-10-11 01:34:16 +00:00
Petar Jovanovic a1ac4b2f6a [asan][mips] Adding support of asan for mipsel arch
cmake/config-ix.cmake: Enabled building of asan for mipsel arch
test/asan/CMakeLists.txt: Enabled testing of asan for mipsel

Patch by Kumar Sukhani

Differential Revision: http://reviews.llvm.org/D5615

llvm-svn: 219496
2014-10-10 13:46:55 +00:00
Renato Golin 1a8093c3a7 Disabling main() check on UBSAN, since the noreturn check is already made
llvm-svn: 219488
2014-10-10 10:26:14 +00:00
Viktor Kutuzov 4546519196 [Tsan] Do not use INTERCEPT_FUNCTION_VER() on FreeBSD
Differential Revision: http://reviews.llvm.org/D5708

llvm-svn: 219483
2014-10-10 07:11:58 +00:00
Viktor Kutuzov e3b6a6a379 [Tsan] Fix the getline_nohang.cc test to build on FreeBSD
Differential Revision: http://reviews.llvm.org/D5666

llvm-svn: 219482
2014-10-10 07:07:26 +00:00
Viktor Kutuzov 348758bbca [Tsan] Fix comments in the user_fopen.cc and user_malloc.cc tests
Related revision: http://reviews.llvm.org/D5670

llvm-svn: 219481
2014-10-10 07:01:52 +00:00
Viktor Kutuzov 918df1abd8 [Tsan] Make the user_fopen.cc and user_malloc.cc tests Linux-specific
Differential Revision: http://reviews.llvm.org/D5670

llvm-svn: 219478
2014-10-10 06:55:17 +00:00
Renato Golin e68963a986 XFAIL some more sanitiser ARMv7l tests
Some more tests failing on the ARMv7 buildbot.

llvm-svn: 219404
2014-10-09 11:34:40 +00:00
Viktor Kutuzov e17b55be69 [Tsan] Fix the signal_errno.cc and signal_malloc.cc tests to pass on FreeBSD
Differential Revision: http://reviews.llvm.org/D5669

llvm-svn: 219399
2014-10-09 09:40:02 +00:00
Viktor Kutuzov c2e274dc2c [Tsan] Fix the global_race tests to pass on FreeBSD
Differential Revision: http://reviews.llvm.org/D5668

llvm-svn: 219398
2014-10-09 09:35:25 +00:00
Viktor Kutuzov 27781f993d [Tsan] Fix the blacklist2.cc test to pass on FreeBSD
Differential Revision: http://reviews.llvm.org/D5665

llvm-svn: 219397
2014-10-09 09:04:26 +00:00
Viktor Kutuzov bafaa7f6ba [Sanitizers] Intercept dlopen() and dlclose() on FreeBSD
Differential Revision: http://reviews.llvm.org/D5664

llvm-svn: 219396
2014-10-09 08:59:59 +00:00
Viktor Kutuzov 2ed7c9df7f [Tsan] Fix references to libc entities in tsan_interceptors.cc on FreeBSD
Differential Revision: http://reviews.llvm.org/D5663

llvm-svn: 219395
2014-10-09 08:56:22 +00:00
Renato Golin 1aaa4bcdd1 Mark sanitizer tests XFAIL on ARMv7
ASAN, UBSAN and profile tests that don't work with arm-linux-gnueabi and
android also don't work on armv7l-linux-gnueabihf. Some of the tests have
known causes, others not yet. In order to get a green bot, I'm disabling
those tests for now and will investigate when the priority rises.

llvm-svn: 219343
2014-10-08 21:13:23 +00:00
Ed Maste e4320f5e6a Remove bashisms and switch to /bin/sh
On a default FreeBSD install Bash is not installed and fdescfs is not
mounted.  Use plain sh functionality instead.

Differential Revision: http://reviews.llvm.org/D5631

llvm-svn: 219333
2014-10-08 18:35:16 +00:00
Tim Northover 8897b8d21a AArch64: don't just hack arm64 support into compiler-rt.
We should check whether the compiler & linker support ARM64 before attempting
to build a version of compiler-rt for it. Otherwise things will go badly.

rdar://problem/18575597

llvm-svn: 219332
2014-10-08 18:34:30 +00:00
Tim Northover a5a06ad6fc AArch64: add support for ARM64 iOS versions of compiler-rt.
Just a dummy directory and a few sane choices in the Darwin SDK.

rdar://problem/18575597

llvm-svn: 219323
2014-10-08 17:28:37 +00:00
Renato Golin 34cb659103 Separating ARM/AArch64 Compiler-RT tests
Makes sure ARM bots don't run AArch64 and vice-versa, since not all
AArch64 systems can run AArch32 and no ARM hardware can run AArch64.

llvm-svn: 219304
2014-10-08 13:47:18 +00:00
Alexander Potapenko ff7456dd34 [ASan] Bump the minimum OSX version required to run ASan to 10.7.
llvm-svn: 219302
2014-10-08 12:41:11 +00:00
Lorenzo Martignoni 60ebffc12f Custom wrappers for DFSanitizing sprintf & snprintf.
Differential Revision: http://reviews.llvm.org/D5561

llvm-svn: 219293
2014-10-08 10:01:42 +00:00
Ed Maste 89b80fb022 Avoid bashisms and switch to /bin/sh
Bash may not be installed on some systems by default, like FreeBSD.

Differential Revision: http://reviews.llvm.org/D5654

llvm-svn: 219231
2014-10-07 20:23:57 +00:00
Ed Maste 1419e9adb5 Run profile tests on FreeBSD
FreeBSD does not have libdl, so set it via lit.cfg instead of the test
input, as with asan.  Also remove it from Darwin test runs - it's not
necessary, but harmless there.

Add FreeBSD to the list of hosts to test.

Differential Revision: http://reviews.llvm.org/D5650

llvm-svn: 219227
2014-10-07 19:24:24 +00:00
Yuri Gorshenin d6c04770c1 Fixed asan-asm-stacktrace-test.cc
Summary: Fixed asan-asm-stacktrace-test.cc. Now it's supported on x86_64 and added test run when no debug info is generated.

Differential Revision: http://reviews.llvm.org/D5547

llvm-svn: 219200
2014-10-07 11:12:55 +00:00
Saleem Abdulrasool 2cf5d82983 builtins: add missed change from previous commit
The macro rework was missing a trailing SEPARATOR for the .thumb_func, resulting
in assembly failures.

llvm-svn: 219183
2014-10-07 03:00:17 +00:00
Saleem Abdulrasool 48d4e4dd35 builtins: rework use of DEFINE_COMPILERRT_THUMB_FUNCTION
This is simply to help clarity of the code.  The functions are built as thumb
only if Thumb2 is available (__ARM_ARCH_ISA_THUMB == 2).  Sink the selection
into the location of the definition and make DEFINE_COMPILERRT_THUMB_FUNCTION
always define a thumb function while DEFINE_COMPILERRT_FUNCTION always selects
the default.

Since the .thumb_func directive is always available (at least on Linux, Windows,
and BSD), sinking the macro right into the macro works just as well.

No functional change intended.

llvm-svn: 219182
2014-10-07 02:39:13 +00:00
Evgeniy Stepanov faef77480d [asan] Minor tweak to asan_device_setup.
Add another wait-for-device which may fix a flaky setup error.
Fix output message.

llvm-svn: 219117
2014-10-06 12:45:39 +00:00
Bob Wilson 115547464e Try harder to fix ARM/Linux after r219040.
llvm-svn: 219066
2014-10-04 20:11:10 +00:00
Bob Wilson d2f1281e6c Attempt to fix ARM/Linux after r219040.
llvm-svn: 219064
2014-10-04 18:13:41 +00:00
Steven Wu 84610ba9b3 Fix the armv7 thumb builtins on darwin
The arm builtins converted into thumb in r213481 are not working
on darwin. On apple platforms, .thumb_func directive is required
to generated correct symbols for thumb functions.

<rdar://problem/18523605>

llvm-svn: 219040
2014-10-04 00:18:59 +00:00
Dmitry Vyukov 7e1accefa2 tsan: output stats about stackdepot in memory profiler
quite amusing on some programs:
RSS 9152 MB: shadow:2456 meta:1736 file:454 mmap:3442 trace:196 heap:866 other:0 stacks=176[1065994] nthr=157/159
...
RSS 30192 MB: shadow:613 meta:5550 file:1839 mmap:20487 trace:212 heap:1489 other:0 stacks=12870[1599445] nthr=162/165
...
RSS 42232 MB: shadow:599 meta:8199 file:2304 mmap:29420 trace:213 heap:1494 other:0 stacks=17794[1690645] nthr=162/165

llvm-svn: 218988
2014-10-03 14:54:11 +00:00
Evgeniy Stepanov 0b9109c803 [asan] Support Android/x86 in asan_device_setup.
llvm-svn: 218968
2014-10-03 08:57:11 +00:00
Daniel Sanders 09c8f6f6a4 [Compiler-rt][MIPS][Profile] Adding support for MIPS32/64
Summary:
Changed cmake/config-ix.cmake to add support for different MIPS architectures: mips, mipsel, mips64, mips64el
In profile code there is no target  based dependencies, so just enabling mips flag does the work. 

Patch by Mohit Bhakkad

Reviewers: dsanders, void, petarj, kcc, samsonov

Reviewed By: samsonov

Subscribers: llvm-commits, farazs, kumarsukhani

Differential Revision: http://reviews.llvm.org/D4880

llvm-svn: 218866
2014-10-02 12:47:55 +00:00
Kostya Serebryany 36aa17a4e3 [asan] make new_array_cookie_test more robust
llvm-svn: 218841
2014-10-01 23:24:54 +00:00
Alexey Samsonov 1b42bde30d [ASan] Don't use large stack buffer for local variable name in stack frame description
llvm-svn: 218827
2014-10-01 21:28:54 +00:00
Alexey Samsonov 0470e24780 [ASan] Make stack-buffer-overflow reports more robust
Summary:
Fix the function that gets stack frame description by address in
thread stack, so that it clearly indicates failures. Make this error non-fatal,
and print as much information as we can in this case. Make all errors in
ParseFrameDescription non-fatal.

Test Plan: check-asan testsuite

Reviewers: kcc

Reviewed By: kcc

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D5554

llvm-svn: 218819
2014-10-01 21:13:00 +00:00
Evgeniy Stepanov d90c20bc26 [asan] Scale back mmap_limit_mb test.
There is some strange interaction between mmap limit and unlimited stack
(ulimit -s unlimited), which results in this test failing when run with
"make".

llvm-svn: 218764
2014-10-01 14:21:05 +00:00
Evgeniy Stepanov 0f7ab59adc [sanitizer] Add i686 arch to compiler-rt.
This is needed so we can produce -i686- named libraries for
x86 Android (which is i686-linux-android).

An alternative solution would be keeping the "i386" name internally and
tweaking the OUTPUT_NAME of compiler-rt libraries.

llvm-svn: 218761
2014-10-01 12:55:06 +00:00
Evgeniy Stepanov b68af953d9 [asan] Tune down mmap_limit_mb test.
The memory limits were a bit too large for 32-bit Android.

llvm-svn: 218759
2014-10-01 12:43:50 +00:00
Alexander Potapenko 79dc4420f0 Disable the ubsan-asan config on Darwin.
UBSan doesn't work together with ASan on Darwin yet, see http://llvm.org/bugs/show_bug.cgi?id=21112

llvm-svn: 218746
2014-10-01 08:53:00 +00:00
Kuba Brecka 12dee62b02 [compiler-rt] Re-enable the use of -gmlt for ASan tests on Darwin
The optimization for -gmlt/-gline-tables-only introduced in r218129 happened to break on Darwin and produce no line number information due to
an incompatibility with dsymutil. ASan tests have been failing because of that and we disabled the use of -gmlt for the tests in r218545. This patch re-enables the use of -gmlt, because we have conditionally disabled the incompatible optimization in LLVM, so -gmlt now works on Darwin. Once Darwin's dsymutil is modified to allow this optimization, we can re-enable the optimization in LLVM.

llvm-svn: 218716
2014-09-30 23:07:45 +00:00
Alexander Potapenko d775f3b5f0 [UBsan] Disable summary.cpp on Darwin. The test requires ubsan-asan, which does not work yet.
llvm-svn: 218675
2014-09-30 13:55:44 +00:00
Evgeniy Stepanov a9d434918e [asan] XFAIL one test on Android.
And add a missing return in main, just in case.

llvm-svn: 218674
2014-09-30 12:54:32 +00:00
Evgeniy Stepanov 3b7a461674 [asan] Run tests with the default compiler on Android.
llvm-svn: 218664
2014-09-30 11:12:41 +00:00
Evgeniy Stepanov fa413a977d [asan] Re-enable lsan_annotations test on Android.
Was fixed by r218605.

llvm-svn: 218663
2014-09-30 11:11:59 +00:00
Alexander Potapenko a3d4131cd5 [UBSan] Use <machine/endian.h> on Darwin.
llvm-svn: 218662
2014-09-30 10:07:37 +00:00
Kostya Serebryany da9d495d03 [asan] add a test for array cookie if the operator new is defined inside the class (the cookie should not be poisoned in such case); update the related comment in asan_poisoning.cc
llvm-svn: 218620
2014-09-29 19:40:56 +00:00
Evgeniy Stepanov 9e922e7d24 [sanitizer] Android build cleanup.
* Detect Android toolchain target arch and set correct runtime library name.
* Merged a lot of Android and non-Android code paths.
* Android is only supported in standalone build of compiler-rt now.
* Linking lsan-common in ASan-Android (makes lsan annotations work).
* Relying on -fsanitize=address linker flag when building tests (again,
  unification with non-Android path).
* Runtime library moved from lib/asan to lib/linux.

llvm-svn: 218605
2014-09-29 13:18:55 +00:00
Oliver Stannard 609e2e6a6e [compiler-rt] Do not use ldrexd or strexd on v7M
The ldrexd and strexd instructions are undefined for the ARMv7M
architecture, so we cannot use them to implement the
__sync_fetch_and_*_8 builtins. There is no other way to implement
these without OS support, so this patch #ifdef's these functions out
for M-class architectures.

There are no tests as I cannot find any existing tests for these
builtins.

I used the __ARM_ARCH_PROFILE predefine because __ARM_FEATURE_LDREX is
deprecated and not set by clang.

llvm-svn: 218601
2014-09-29 10:23:20 +00:00
Evgeniy Stepanov 3f11c0d79c [asan] Fix SELinux setup on Android-K.
On pre-L devices SELinux is set up in such a way that zygote wrapper
has to be in system_file context, not zygote_exec.

llvm-svn: 218599
2014-09-29 09:48:13 +00:00
Alexey Samsonov 987370b6bd Effectively revert r217284 on Darwin due to issues with -gmlt there
llvm-svn: 218545
2014-09-26 21:58:33 +00:00
Kuba Brecka 7e38e429b7 [compiler-rt] recommit of r218481: ASan debugging API for report info extraction and locating addresses
Reviewed at http://reviews.llvm.org/D4527

Fixed a test case failure on 32-bit Linux, I did right shift on intptr_t, instead it should have been uintptr_t.

llvm-svn: 218538
2014-09-26 19:15:32 +00:00
Petar Jovanovic c2e0427b94 [UBSan] Adding support of MIPS32
Changed files: 
config-ix.cmake: Enabled UBSan for MIPS32
sanitizer_stacktrace.cc: Program counter for MIPS32 is four byte aligned
and a delay slot so subtracted PC by 8 for getting call site address.
cast-overflow.cpp: Added big endian support for this test case.

Patch by Sagar Thakur.

Differential Revision: http://reviews.llvm.org/D4881

llvm-svn: 218519
2014-09-26 14:16:06 +00:00
Kuba Brecka db22cd1721 [compiler-rt] revert r218481 due to test failure on sanitizer-x86_64-linux
llvm-svn: 218501
2014-09-26 05:25:37 +00:00
Kuba Brecka e892580415 [compiler-rt] fix failing debug_locate.cc test due to a leak
New test from r218481 fails on Linux due to LeakSanitizer reporting a leak, this patch frees the memory properly. 

llvm-svn: 218483
2014-09-26 00:20:37 +00:00
Kuba Brecka e37e089b66 [compiler-rt] ASan debugging API for report info extraction and locating addresses
Reviewed at http://reviews.llvm.org/D4527

This patch is part of an effort to implement a more generic debugging API, as proposed in http://lists.cs.uiuc.edu/pipermail/llvmdev/2014-July/074656.html, with first part reviewed at http://reviews.llvm.org/D4466. Now adding several new APIs: __asan_report_present, __asan_get_report_{pc,bp,sp,address,type,size,description}, __asan_locate_address. These return whether an asan report happened yet, the PC, BP, SP, address, access type (read/write), access size and bug description (e.g. "heap-use-after-free"), __asan_locate_address takes a pointer and tries to locate it, i.e. say whether it is a heap pointer, a global or a stack, or whether it's a pointer into the shadow memory. If global or stack, tries to also return the variable name, address and size. If heap, tries to return the chunk address and size. Generally these should serve as an alternative to "asan_describe_address", which only returns all the data in text form. Having an API to get these data could allow having debugging scripts/extensions that could show additional information about a variable/expression/pointer. Test cases in test/asan/TestCases/debug_locate.cc and test/asan/TestCasea/debug_report.cc.

llvm-svn: 218481
2014-09-25 23:53:57 +00:00
Kostya Serebryany 8a86fa37af [asan] disable a test that uses -coverage on Android
llvm-svn: 218475
2014-09-25 23:30:37 +00:00
Ehsan Akhgari 5bb7234b23 Add support for intercepting functions from msvcr110.dll
Summary: This finishes support for ASAN on MSVC2012.

Test Plan: |ninja check-asan| passes locally with this on MSVC2012.

Reviewers: timurrrr

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D5494

llvm-svn: 218465
2014-09-25 20:47:10 +00:00
Ehsan Akhgari 045423f26d Fix a mistake in r217762
Summary:
The extra macro definition needs to go into COMPILER_RT_GTEST_CFLAGS
in order to be used for gtests on MSVC2012.

Test Plan: This is part of the fixes necessary for the ASAN tests to pass with MSVC2012.

Reviewers: timurrrr

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D5493

llvm-svn: 218464
2014-09-25 20:42:49 +00:00
Alexander Potapenko bc4ce3a224 Follow-up for r217523: fix the dependencies for standalone compiler-rt build.
Patch by Kuba Brecka (kuba.brecka@gmail.com)

llvm-svn: 218444
2014-09-25 09:30:05 +00:00
Kostya Serebryany fd5e21adba [asan] make sanitizer tests depend on libclang_rt.profile since we now have a test that uses -coverage
llvm-svn: 218427
2014-09-24 23:54:04 +00:00
Kostya Serebryany 34ddf8725c [asan] don't instrument module CTORs that may be run before asan.module_ctor. This fixes asan running together -coverage
llvm-svn: 218421
2014-09-24 22:41:55 +00:00
Evgeniy Stepanov c07dc68852 [asan] Fix one test on Android-L.
index() is deprecated.

llvm-svn: 218312
2014-09-23 15:42:04 +00:00
Alexey Samsonov 7dd95610e5 UBSan: print 'undefined-behavior' instead of 'runtime-error' in report summary
llvm-svn: 218264
2014-09-22 19:39:46 +00:00
Alexander Potapenko 1aba330e52 [ASan] Introduce the dump_instruction_bytes flag to print the faulting instruction upon SIGSEGV
When dump_instruction_bytes=1 and the instruction pointer doesn't point to the zero page, ASan prints 16 bytes starting at the instruction point.

llvm-svn: 218243
2014-09-22 11:58:52 +00:00
Alexey Samsonov 25c2224922 [UBSan] Introduce more flexible __ubsan_default_options function instead of UBSAN_DEFAULT_OPTIONS compile definition
llvm-svn: 218137
2014-09-19 18:54:52 +00:00
Alexey Samsonov 760750c44f [UBSan] Optionally report summary in UBSan error reports.
By default summary is not printed if UBSan is run in a standalone mode,
but is printed if it's combined with another sanitizer (like ASan).

llvm-svn: 218135
2014-09-19 18:33:45 +00:00
Evgeniy Stepanov a5d07482d9 [asan] asan_device_setup improvements.
* Allow user SEGV handler if Android-L-like setup is detected.
  Necessary for correctness.
* Change file context labels on the wrapper script to appease SELinux.

llvm-svn: 218124
2014-09-19 15:04:44 +00:00
Alexander Potapenko 53b85c25e0 [ASan] Print a hint when the program crashes accessing the zero page.
This may help some users figure out that the error report is valid.

llvm-svn: 218123
2014-09-19 12:37:00 +00:00
Saleem Abdulrasool 8bf8409be8 builtins: 80-column
Re-wrap a couple of lines.  NFC.

llvm-svn: 218096
2014-09-19 01:35:08 +00:00
Saleem Abdulrasool c5ff406f5f builtins: remove definition of __ARM_ARCH
__ARM_ARCH is part of the ACLE specification.  At least clang and GCC have
supported this part of the ACLE for some time now.  Let the compiler provide the
proper definition for the macro rather than try to guess it.

llvm-svn: 218095
2014-09-19 01:34:03 +00:00
Sergey Matveev 756afb2f82 [asan] Initialize logfile in asan_symbolize.py to sys.stdin.
llvm-svn: 218072
2014-09-18 20:01:28 +00:00
Sergey Matveev 4588de1c22 [asan] Fix a bug in asan_symbolize.py
Do not forget to add newlines between multiple symbolized lines corresponding to
a single input line (i.e. inlining).

llvm-svn: 218071
2014-09-18 19:16:44 +00:00
Dmitry Vyukov 59dce3d4d0 tsan: more careful handling of signals
On some tests we see that signals are not delivered
when a thread is blocked in epoll_wait. The hypothesis
is that the signal is delivered right before epoll_wait
call. The signal is queued as in_blocking_func is not set
yet, and then the thread just blocks in epoll_wait forever.
So double check pending signals *after* setting
in_blocking_func. This way we either queue a signal
and handle it in the beginning of a blocking func,
or process the signal synchronously if it's delivered
when in_blocking_func is set.

llvm-svn: 218070
2014-09-18 19:03:32 +00:00
Dmitry Vyukov c0ae07e98c tsan: fix signal_longjmp test in debug mode
In debug mode tsan checks that user accesses
access user memory. NULL is not user memory.
So the test fails. Allocate real inaccessible
memory for the test.

llvm-svn: 218069
2014-09-18 19:00:02 +00:00
Dmitry Vyukov 9767d2f8da tsan: fix double semicolon ;;
llvm-svn: 218067
2014-09-18 18:58:44 +00:00
Viktor Kutuzov ea66f5bc40 Enable Asan lit tests on FreeBSD.
Differential Revision: http://reviews.llvm.org/D5375

llvm-svn: 218042
2014-09-18 10:04:07 +00:00
Dmitry Vyukov 538ceee2b9 tsan: fix bug number in comment
llvm-svn: 217992
2014-09-17 22:57:57 +00:00
Alexey Samsonov 1947bf9921 PR20721: Don't let UBSan print inaccessible memory
Summary:
UBSan needs to check if memory snippet it's going to print resides
in addressable memory. Similar check might be helpful in ASan with
dump_instruction_bytes option (see http://reviews.llvm.org/D5167).

Instead of scanning /proc/self/maps manually, delegate this check to
the OS kernel: try to write this memory in a syscall and assume that
memory is inaccessible if the syscall failed (e.g. with EFAULT).

Fixes PR20721.

Test Plan: compiler-rt test suite

Reviewers: eugenis, glider

Reviewed By: glider

Subscribers: emaste, ygribov, llvm-commits, glider, rsmith

Differential Revision: http://reviews.llvm.org/D5253

llvm-svn: 217971
2014-09-17 17:56:15 +00:00
Viktor Kutuzov 68b3e87263 Do not link the dyndd runtime library against libdl on FreeBSD
Differential Revision: http://reviews.llvm.org/D5207

llvm-svn: 217944
2014-09-17 07:54:46 +00:00
Viktor Kutuzov 308b93f6e4 Add FreeBSD support to the address sanitizer's deep_call_stack.cc test case
Differential Revision: http://reviews.llvm.org/D4562

llvm-svn: 217943
2014-09-17 07:31:37 +00:00
Dmitry Vyukov 6466f43688 tsan: fix crash when a program registers zillions of atexit callbacks
I don't remember that crash on mmap in internal allocator
ever yielded anything useful, only crashes in rare wierd untested situations.
One of the reasons for crash was to catch if tsan starts allocating
clocks using mmap. Tsan does not allocate clocks using internal_alloc anymore.
Solve it once and for all by allowing mmaps.

llvm-svn: 217929
2014-09-17 00:12:50 +00:00
Dmitry Vyukov 69c4d37b45 tsan: support longjmp out of signal handlers
Fixes https://code.google.com/p/thread-sanitizer/issues/detail?id=75

llvm-svn: 217908
2014-09-16 21:48:22 +00:00
Kostya Serebryany 9fa2fc8357 [sanitizer] Fix global constructor warning in sanitizer; patch by Samuel F Antao
llvm-svn: 217904
2014-09-16 20:49:55 +00:00
Joerg Sonnenberger ed35a3e717 Implement floatsitf, floatunstfsi, which perform
(signed/unsigned)integer to quad-precision conversion.

Submitted by GuanHong Liu.

Differential Revision: http://reviews.llvm.org/D2805

llvm-svn: 217901
2014-09-16 20:34:41 +00:00
Evgeniy Stepanov 3905bb9150 [asan] De-flake one test.
This change replaces an in-test timeout with an unconditional blocking wait.
It speeds up normal execution significantly at the cost of hanging up indefinitely
in case of a failure. This is a very specific regression test and we don't
expect any failures in the future.

Another approach ould be increasing the timeout to ~8 seconds, which seems too
much for a lit test.

llvm-svn: 217870
2014-09-16 12:03:52 +00:00
Evgeniy Stepanov 6ef0106e43 [asan] Fix a comment in a test.
llvm-svn: 217869
2014-09-16 12:01:01 +00:00
Evgeniy Stepanov a59459de27 [asan] Fix a flaky test.
This test has a chance to hit some other random allocation
and get neither heap overflow nor SEGV.

Relax test condition to only check that there is no internal CHECK failure.

llvm-svn: 217769
2014-09-15 13:05:40 +00:00
Evgeniy Stepanov bc496dab07 [asan] Delay system log initialization on Android.
Writing to system log requires libc interceptors to be initialized.
Fixes crashes with verbosity=1 on newer Android builds.

llvm-svn: 217764
2014-09-15 11:37:40 +00:00
Ehsan Akhgari c4f23419bb Avoid calling strtoll and atoll in asan_str_test.cc on Windows for now
Summary:
These two functions are unavailable on MSVC2012, which breaks building the
ASAN tests with MSVC2012.  Since the tests required to run these functions
are disabled on Windows for now, avoid building them to fix the MSVC2012
builds.

Test Plan: This is needed in order to fix building the ASAN tests with MSVC2012.

Reviewers: timurrrr

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D5343

llvm-svn: 217763
2014-09-15 11:34:12 +00:00
Ehsan Akhgari 47d260962f Port the variadic std::tr1::tuple hack for building gtest for MSVC2012 to ASAN tests.
Summary: This is copied from llvm/utils/unittest/CMakeLists.txt.

Test Plan: This partly enables building ASAN tests with MSVC2012.

Reviewers: timurrrr

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D5342

llvm-svn: 217762
2014-09-15 11:33:50 +00:00
Evgeniy Stepanov 7a8330e7bf [asan] Fix path in test.
llvm-svn: 217754
2014-09-15 09:33:20 +00:00
Evgeniy Stepanov 207930d345 [asan] Disable wait4 test on Android.
https://code.google.com/p/memory-sanitizer/issues/detail?id=64

llvm-svn: 217753
2014-09-15 09:20:15 +00:00
Dmitry Vyukov e4b846e0d8 tsan: use growable vector for atexit callbacks
Most real programs setup much more than 1024 callbacks.

llvm-svn: 217713
2014-09-12 22:19:03 +00:00
Alexey Samsonov 0e8364e912 [UBSan] Don't overflow when calculating memory range that should be dumped
llvm-svn: 217703
2014-09-12 19:51:26 +00:00
Timur Iskhodzhanov 651725e191 [ASan/Win] Fix PR20918 -- SEH handler doesn't work with the MD runtime
llvm-svn: 217679
2014-09-12 14:01:30 +00:00
Timur Iskhodzhanov 92c0601d27 [ASan/Win] Rename asan_win_uar_thunk.lib to asan_win_dynamic_runtime_thunk.lib
It turned out that we have to bridge more stuff between the executable
and the ASan RTL DLL than just __asan_option_detect_stack_use_after_return.
See PR20918 for more details.

llvm-svn: 217673
2014-09-12 13:21:02 +00:00
Alexey Samsonov 74f07ed7fe Revert r217616. Problems and complexity it introduces negate its benefit
llvm-svn: 217652
2014-09-12 01:26:57 +00:00
Alexey Samsonov 5d2c0dfe4c [UBSan] Parse common flags from UBSAN_OPTIONS runtime variable even if
UBSan is combined with ASan.

llvm-svn: 217616
2014-09-11 18:20:11 +00:00
Evgeniy Stepanov e579c76bd5 [asan] Preserve existing LD_PRELOAD setting on Android.
llvm-svn: 217584
2014-09-11 12:20:29 +00:00
Alexey Samsonov 5c825967ea [TSan] Use common flags in the same way as all the other sanitizers
llvm-svn: 217559
2014-09-10 23:08:06 +00:00
Alexey Samsonov 611c906cb3 [Sanitizer] Get rid of Symbolizer::Get() and Symbolizer::GetOrNull().
We may as well just use Symbolizer::GetOrInit() in all the cases.
Don't call Symbolizer::Get() early in tools initialization: these days
it doesn't do any important setup work, and we may as well create the
symbolizer the first time it's actually needed.

llvm-svn: 217558
2014-09-10 22:45:09 +00:00
Alexey Samsonov 7f0f17b3fb [UBSan] Add noinline attribute to handlers that should never return.
FIx a problem reported by Jakub Jelinek: don't do early-exit from fatal
UBSan handlers: even if source location is disabled (i.e. acquired by
some other thread), we should continue the execution to make sure that:
a) some thread will print the error report before calling Die().
b) handler marked as noreturn will indeed not return.

Explicitly add "Die()" calls at the end of all fatal handlers to be
sure UBSan handlers don't introduce UB themselves.

llvm-svn: 217542
2014-09-10 20:43:36 +00:00
Alexey Samsonov b69d5dffc3 [UBSan] Add halt_on_error runtime flag
llvm-svn: 217535
2014-09-10 19:35:31 +00:00
Kuba Brecka fa2de77a14 Make compiler-rt tests work with relocatable SDKs on OS X
Reviewed at http://reviews.llvm.org/D4047

llvm-svn: 217523
2014-09-10 17:23:58 +00:00
Yuri Gorshenin 6118d07b00 [asan-assembly-instrumentation] Added end-to-end test for proper stack unwind for functions with inline assembly.
Summary: [asan-assembly-instrumentation] Added end-to-end test for proper stack unwind for functions with inline assembly.

Reviewers: eugenis

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D5260

llvm-svn: 217487
2014-09-10 10:44:35 +00:00
Alexey Samsonov 513e8a911f Remove extra semicolon [-Wpedantic]
llvm-svn: 217407
2014-09-08 23:37:09 +00:00
Alexey Samsonov 90452df7b1 Report source location of returns_nonnull attribute in UBSan reports.
llvm-svn: 217400
2014-09-08 20:17:19 +00:00
Alexey Samsonov c7c3ae0a8b Revert accidental change
llvm-svn: 217391
2014-09-08 17:52:48 +00:00
Alexey Samsonov 8e1162c71d Implement nonnull-attribute sanitizer
Summary:
This patch implements a new UBSan check, which verifies
that function arguments declared to be nonnull with __attribute__((nonnull))
are actually nonnull in runtime.

To implement this check, we pass FunctionDecl to CodeGenFunction::EmitCallArgs
(where applicable) and if function declaration has nonnull attribute specified
for a certain formal parameter, we compare the corresponding RValue to null as
soon as it's calculated.

Test Plan: regression test suite

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits, rnk

Differential Revision: http://reviews.llvm.org/D5082

llvm-svn: 217389
2014-09-08 17:22:45 +00:00
Evgeniy Stepanov 256d5512e6 [msan] Fix wrong array index in io_submit interceptor.
llvm-svn: 217362
2014-09-08 09:28:25 +00:00
Evgeniy Stepanov 36974a7061 [msan] Make chained_origin_limits test faster.
llvm-svn: 217361
2014-09-08 09:04:45 +00:00
Saleem Abdulrasool c89ae72e43 builtins: replace section symbol with reference to spec
Removes a non-ascii character that was committed.

llvm-svn: 217353
2014-09-08 01:49:24 +00:00
Saleem Abdulrasool a0a5873e28 builtins: add AEABI div0 functions
Add the missing AEABI functions that are part of the base platform ABI
specification.  The provided implementation does the bare minimum to avoid
requiring libc headers.  This permits the use of compiler-rt on bare-metal
environments which conform to EABI.

llvm-svn: 217322
2014-09-06 21:34:02 +00:00
Saleem Abdulrasool b6a85b4f6a builtins: remove unnecessary COMPILER_RT_EXPORT
This macro did not do anything at this point, and is not particularly needed for
Windows unless building the builtins as a shared library.  NFC.

llvm-svn: 217321
2014-09-06 21:33:55 +00:00
Viktor Kutuzov 75e31aeb89 Support building tsan_test_util_linux.cc on FreeBSD
Differential Revision: http://reviews.llvm.org/D5210

llvm-svn: 217309
2014-09-06 07:59:05 +00:00
Viktor Kutuzov 1827415be4 Do not assume RLIM_INFINITY is always (rlim_t)-1in sanitizers code
Differential Revision: http://reviews.llvm.org/D5212

llvm-svn: 217308
2014-09-06 07:52:51 +00:00
Viktor Kutuzov dcb98e5dcc Intercept sigfillset() and sigemptyset() for sanitizers needs on FreeBSD
Differential Revision: http://reviews.llvm.org/D5206

llvm-svn: 217307
2014-09-06 07:46:55 +00:00
Viktor Kutuzov eead048ee9 Enable sanitizers' libignore on FreeBSD
Differential Revision: http://reviews.llvm.org/D5205

llvm-svn: 217306
2014-09-06 07:41:22 +00:00
Alexey Samsonov 62063b46fc Use "-gline-tables-only" instead of "-g" in sanitizer test suites.
We are interested in verifying that -gline-tables-only provides enough
debug information for verbose error reports and symbolized stack traces.

llvm-svn: 217284
2014-09-05 22:05:32 +00:00
Alexander Potapenko 869342c1cb [ASan] disable zero_page_pc.cc on Android.
Bug: https://code.google.com/p/address-sanitizer/issues/detail?id=336

llvm-svn: 217228
2014-09-05 06:26:08 +00:00
Kostya Serebryany 1fb81720ec [asan] relax the assertion around array cookie load; still need to extract a reproducer where this assertion fails...
llvm-svn: 217215
2014-09-05 01:16:30 +00:00
Alexey Samsonov f537aeaea1 [ASan] Remove the call to GetPageSizeCached from fast path of FastPoisonShadow
llvm-svn: 217194
2014-09-04 20:47:27 +00:00
Kostya Serebryany d147590492 [asan] trying to de-flake new_array_cookie_uaf_test.cc
llvm-svn: 217177
2014-09-04 18:02:59 +00:00
Justin Bogner cc0d7eeb6d profile: Avoid name collisions between instrumentation and runtime
The naming scheme we're using for counters in profile data shares a
prefix with some fixed names we use for the runtime, notably
__llvm_profile_data_begin and _end. Embarrassingly, this means a
function called begin() can't be instrumented.

This modifies the runtime names so as not to collide with the
instrumentation.

llvm-svn: 217166
2014-09-04 15:45:31 +00:00
Alexander Potapenko 7c3d581e8a [ASan] Remove the check for a double-SEGV from zero_page_pc.cc
Looks like the second crash doesn't happen on Mac.

llvm-svn: 217165
2014-09-04 15:40:25 +00:00