Commit Graph

4657 Commits

Author SHA1 Message Date
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