Commit Graph

5625 Commits

Author SHA1 Message Date
Nick Lewycky 816e0eabb7 Add another sanity check for swapcontext, which is currently unsupported. Patch by Alexey Samsonov!
llvm-svn: 233413
2015-03-27 20:40:23 +00:00
Viktor Kutuzov eff2d98ecc [Tsan] Do not sanitize memset() and other functions during initialization
Differential Revision: http://reviews.llvm.org/D8544

llvm-svn: 233378
2015-03-27 14:12:28 +00:00
Dmitry Vyukov 2034ce665a tsan: don't write to meta shadow unnecessarily
If user does malloc(1<<30), the write to meta shadow
can cause excessive memory consumption.

llvm-svn: 233373
2015-03-27 12:22:44 +00:00
Alexey Samsonov 0781e98cc7 [UBSan] Explicitly list all supported OS/arch pairs supported by UBSan.
llvm-svn: 233295
2015-03-26 17:26:04 +00:00
Timur Iskhodzhanov fd3241528d [Sanitizer] Plug a leak in POSIXSymbolizer::FindModuleForAddress
It was happening when we looked up a PC for a module that was dlopen'ed/dlclose'd
after the last time we fetched the list of modules

Reviewed at http://reviews.llvm.org/D8618

llvm-svn: 233257
2015-03-26 07:14:29 +00:00
Alexey Samsonov 1c1407395f [LSan] Don't explicitly exclude LSan from Windows build - it should just produce dummy object files. NFC.
llvm-svn: 233231
2015-03-25 23:26:49 +00:00
Kuba Brecka b47f4ef508 On OS X, explicitly use libc++
For OS X builds, both Make and CMake, let's be very explicit about using
libc++ and libc++abi with:

1) -stdlib=libc++ in CFLAGS and LDFLAGS for all platforms
2) -lc++ in LDFLAGS for all platforms
3) switch from -undefined dynamic_lookup to -lc++abi for UBSan in
   Makefile-based builds

Reviewed at http://reviews.llvm.org/D8617

llvm-svn: 233215
2015-03-25 21:07:20 +00:00
Timur Iskhodzhanov 3e8d392e9a [Sanitizers coverage] Minor cleanup: reduce scope and visibility of one method and one variable
llvm-svn: 233212
2015-03-25 20:19:51 +00:00
Bill Seurer 92760a3551 [PowerPC]Fix sancov.py to once again support big endian
Some recent changes to sancov.py broke ASAN for big endian.  This fixes it.

http://reviews.llvm.org/D8594

llvm-svn: 233189
2015-03-25 14:56:02 +00:00
Alexander Potapenko 2dee295a89 [ASan] Suppress the deprecation warning from atos that breaks AtosSymbolizer on OSX 10.9
On OS X 10.9 /usr/bin/atos prints the following warning upon invocation:

 --
Warning: /usr/bin/atos is moving and will be removed from a future OS X release.
It is now available in the Xcode developer tools to be invoked via: `xcrun atos`
To silence this warning, pass the '-d' command-line flag to this tool.
 --

AtosSymbolizer treats the warning as the symbolization result for the first PC passed to the symbolizer. As a result, for each of the following PCs the file:line info for the previous PC is printed, e.g.:

==97926==ERROR: AddressSanitizer: attempting double-free on 0x60200000dfb0 in thread T0:
==97926==Using atos at user-specified path: /usr/bin/atos
==97926==Using dladdr symbolizer.
   #0 0x1007407e0 in  --  (+0x427e0)
   #1 0x1006f6f25 in wrap_free asan_malloc_mac.cc:114
   #2 0x7fff916e05fc in main atos-symbolizer.cc:17
   #3 0x0  (<unknown module>)

Unfortunately atos doesn't accept the -d switch on OSX versions other than 10.9, thus we have to check for the OSX version.

llvm-svn: 233180
2015-03-25 11:01:33 +00:00
Alexey Samsonov ee449b68d0 Revert "Revert "[UBSan] Use shared library for UBSan on OS X" and its followup"
Fix the build/tests by providing -lc++abi for UBSan runtime only.

llvm-svn: 233122
2015-03-24 21:57:07 +00:00
Justin Bogner cc7e7cabd5 Revert "[UBSan] Use shared library for UBSan on OS X" and its followup
This change caused test failures on darwin, and the followup which was
meant to fix those caused compiler-rt to start failing to link.
Reverting to get the build working again.

This reverts r233071 and r233036.

llvm-svn: 233097
2015-03-24 17:43:31 +00:00
Alexander Potapenko f7d32ccc00 [ASan] Do not link ASan OSX runtime with -lc++abi (which was added in r233036)
This should fix the OSX Jenkins build at http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA_check/

llvm-svn: 233071
2015-03-24 13:10:55 +00:00
Alexey Samsonov 6279a07eaa [TSan] Disable -Wno-maybe-uninitialized in yet another place.
llvm-svn: 233044
2015-03-24 00:38:43 +00:00
Alexey Samsonov 58e4835779 [TSan] Fixup for r233038: restrict the -Wno-maybe-uninitialized flag to GCC only.
llvm-svn: 233042
2015-03-23 23:44:38 +00:00
Alexey Samsonov 705c449af5 [ASan] Remove XFAIL from now passing test.
llvm-svn: 233040
2015-03-23 23:37:39 +00:00
Alexey Samsonov 543e966142 [TSan] Disable noisy GCC warning.
llvm-svn: 233038
2015-03-23 23:29:39 +00:00
Kostya Serebryany cd019f3655 [sanitizer] instead of comparing pointers to module_names while initializing coverage do a proper strcmp and strdup. NFC
llvm-svn: 233037
2015-03-23 23:19:13 +00:00
Alexey Samsonov c4eb977b0f [UBSan] Use shared library for UBSan on OS X (compiler-rt part).
Summary:
Switch to shared library for UBSan. Add support for building
UBSan on OSX and iossim by cargo-culting ASan build rules.

Test Plan: regression test suite

Reviewers: zaks.anna, kubabrecka

Subscribers: llvm-commits

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

llvm-svn: 233036
2015-03-23 23:14:16 +00:00
Alexey Samsonov 6a7ee6f460 [UBSan] Introduce "ubsan_standalone" library (compiler-rt part).
Get rid of "libclang_rt.san" library that used to contain
sanitizer_common pieces required by UBSan if it's used in a standalone
mode. Instead, build two variants of UBSan runtime: "ubsan" and
"ubsan_standalone" (same for "ubsan_cxx" and "ubsan_standalone_cxx").

Later "ubsan" and "ubsan_cxx" libraries will go away, as they will
embedded it into corresponding ASan runtimes.

llvm-svn: 233011
2015-03-23 20:05:53 +00:00
Viktor Kutuzov 60f0aa8a42 [Sanitizers] Fix internal_ftruncate() to work on FreeBSD
Differential Revision: http://reviews.llvm.org/D8551

llvm-svn: 233003
2015-03-23 19:44:35 +00:00
Viktor Kutuzov 838ea617d6 [Tsan] Fix the mmap_large.cc test to build on FreeBSD
Differential Revision: http://reviews.llvm.org/D8545

llvm-svn: 233001
2015-03-23 19:40:59 +00:00
Alexander Potapenko f0581dda03 [sanitizer] Fix file access modes in SanitizerCommon.InternalMmapWithOffset and SanitizerCommon.FileOps
llvm-svn: 232972
2015-03-23 17:55:19 +00:00
Alexander Potapenko b9c928bd10 [libsanitizer] Fix OpenFile() usage in TSan and DFSan.
This is a follow-up for r232936.

llvm-svn: 232937
2015-03-23 10:32:28 +00:00
Alexander Potapenko 141e420a81 [ASan] Distinguish between read, write and read-write file access modes in OpenFile.
This is to fix mapping coverage files into memory on OSX.

llvm-svn: 232936
2015-03-23 10:10:46 +00:00
Kuba Brecka 0e66c49d62 Fix a flaky heap-overflow-large.cc test
Reviewed at http://reviews.llvm.org/D8515

llvm-svn: 232920
2015-03-22 18:00:58 +00:00
Kuba Brecka eefb2e2703 Demangling for DlAddrSymbolizer
On OS X, dladdr() provides mangled names only, so we need need to demangle in
DlAddrSymbolizer::SymbolizePC.

Reviewed at http://reviews.llvm.org/D8291

llvm-svn: 232910
2015-03-22 11:38:55 +00:00
Kuba Brecka 0be4e0e0c1 Add AtosSymbolizer and DlAddrSymbolizer as fallbacks for OS X
This patch changes the symbolizer chain on OS X (which currently only uses 1
symbolizer at most) to use this behavior:

* By default, use LLVMSymbolizer -> DlAddrSymbolizer.
* If the llvm-symbolizer binary is not found, use AtosSymbolizer 
    -> DlAddrSymbolizer.
* If the user specifies ASAN_SYMBOLIZER_PATH=.../atos, then use AtosSymbolizer
    -> DlAddrSymbolizer.
* If neither llvm-symbolizer or atos is found, or external symbolication is
    disabled with ASAN_SYMBOLIZER_PATH="", use DlAddrSymbolizer.

Reviewed at http://reviews.llvm.org/D8285

llvm-svn: 232908
2015-03-22 10:02:50 +00:00
Kostya Serebryany 90bb050c54 [asan] update the sized_delete_test following the change of clang flags in r232788.
llvm-svn: 232845
2015-03-20 20:45:42 +00:00
Alexander Potapenko 24c262f213 [ASan] fix litling warnings for coverage-order-pcs.cc
llvm-svn: 232812
2015-03-20 14:11:05 +00:00
Alexander Potapenko 001deff940 [ASan] Move a couple of Posix-specific tests to Posix/
Add a comment about potential breakage of coverage-maybe-open-file.cc on Win

llvm-svn: 232809
2015-03-20 13:42:11 +00:00
Alexander Potapenko d5b3f7b125 [ASan] Move the coverage tests that work on Darwin to common testcase dir.
llvm-svn: 232808
2015-03-20 13:31:03 +00:00
Kostya Serebryany dcb54db809 [sanitizer] fix 'sancov.py merge' and add a test for it
llvm-svn: 232763
2015-03-19 21:01:27 +00:00
Kostya Serebryany eaec5b67e7 [sanitizer] trying to fix sancov.py with 32-bit python
llvm-svn: 232754
2015-03-19 19:52:30 +00:00
Kostya Serebryany 2d56abacd1 [sanitizer] change the sanitizer coverage format once again, this time adding a magic to the beginning of the file
llvm-svn: 232679
2015-03-18 22:03:39 +00:00
Justin Bogner eba5227ccd asan: Cargo cult the linux test changes in r232501 to the darwin tests
This gets check-asan working again on Darwin - it looks like it was
just an omission not to update this as part of r232501.

llvm-svn: 232672
2015-03-18 21:30:46 +00:00
Renato Golin d8a128aafb [ARM] Remove XFAIL from passing RT test
This test started passing without warning, so in theory, we shouldn't mark
is as XPASS, but the buildbots are red and there's been an uncaught regression
meanwhile. Since it's passing on {ARM,Thumb2} x {NEON,VFPv3}, I'll risk future
failures for the benefit of getting the bots green again.

llvm-svn: 232642
2015-03-18 15:42:15 +00:00
Kostya Serebryany cba49d4b04 [sanitizer] add run-time a flag coverage_order_pcs. When true, the PCs are dumped in the order of their appearance
llvm-svn: 232573
2015-03-18 00:23:44 +00:00
Alexey Samsonov c9d9610317 Improve SUMMARY reporting in sanitizers.
Make sure SUMMARY is always reported unless print_summary flag is set to
false, even if symbolizer is unavailable or report stack trace is empty.
If file/line info for PC can't be evaluated, print module name/offset
like we do in stack trace.

llvm-svn: 232567
2015-03-17 23:46:06 +00:00
Kostya Serebryany 9f1243ee49 [sanitizer] change the format of coverage dump: instead of always dumping 32-bit offsets dump 32-bit offsets on 32-bit arch and 64-bit offsets on 64-bit arch. Also add the 'bits' parameter to sancov.py. This is a user-visible interface change.
llvm-svn: 232555
2015-03-17 22:09:19 +00:00
Dmitry Vyukov 27c50f4f02 asan: remove left-over code from submitted in rev r232501
__sanitizer_cov_hint is part of a different functionality
and was not intended to be submitted.

llvm-svn: 232506
2015-03-17 17:30:41 +00:00
Dmitry Vyukov 6bd917a31f asan: optimization experiments
The experiments can be used to evaluate potential optimizations that remove
instrumentation (assess false negatives). Instead of completely removing
some instrumentation, you set Exp to a non-zero value (mask of optimization
experiments that want to remove instrumentation of this instruction).
If Exp is non-zero, this pass will emit special calls into runtime
(e.g. __asan_report_exp_load1 instead of __asan_report_load1). These calls
make runtime terminate the program in a special way (with a different
exit status). Then you run the new compiler on a buggy corpus, collect
the special terminations (ideally, you don't see them at all -- no false
negatives) and make the decision on the optimization.

The exact reaction to experiments in runtime is not implemented in this patch.
It will be defined and implemented in a subsequent patch.

http://reviews.llvm.org/D8198

llvm-svn: 232501
2015-03-17 16:59:11 +00:00
Timur Iskhodzhanov d58230b9dc [ASan/Win] Fix a CHECK failure when an exception is thrown from a callback passed to BindIoCompletionCallback
This also simplifies how we handle QueueUserWorkItem

llvm-svn: 232499
2015-03-17 16:50:59 +00:00
Peter Collingbourne 3fc1563ad7 CFI: Make check-cfi depend on libLTO on Darwin.
llvm-svn: 232426
2015-03-16 22:00:04 +00:00
Viktor Kutuzov a7d323e996 [Tsan] Do not sanitize memcpy() during thread initialization on FreeBSD
Differential Revision: http://reviews.llvm.org/D8324

llvm-svn: 232381
2015-03-16 14:42:21 +00:00
Timur Iskhodzhanov 817ac724e2 [ASan] NFC: Factor out platform-specific interceptors
Reviewed at http://reviews.llvm.org/D8321

llvm-svn: 232377
2015-03-16 14:22:53 +00:00
Peter Collingbourne 678e78ca95 CFI: Add test for bad cast checks.
llvm-svn: 232242
2015-03-14 02:42:39 +00:00
Peter Collingbourne ca1c7793b1 CFI: Add a test for distinguishing between non-overriding siblings.
llvm-svn: 232238
2015-03-14 01:35:33 +00:00
Reid Kleckner a1410321f6 Translate some MSVC CMAKE_*_FLAGS to clang flags in clang_compile
Passing MSVC-style cflags to the gcc-style clang driver will almost
always end badly. Just translate a couple of simple flags used by the
base CMake cflags like /D, /U, and /O.

llvm-svn: 232219
2015-03-13 21:39:29 +00:00
Viktor Kutuzov 281347aa59 [Tsan] Fix test.h to work on FreeBSD
Differential Revision: http://reviews.llvm.org/D8303

llvm-svn: 232167
2015-03-13 14:08:55 +00:00
Joerg Sonnenberger 1aa3faaca2 We want single precision here.
llvm-svn: 232125
2015-03-13 00:18:28 +00:00
Ed Maste 9197c8dad0 Use signed int implementation for __fixint
llvm-svn: 232107
2015-03-12 21:36:10 +00:00
Alexey Samsonov 59c57cd89b Update copyright year to 2015.
llvm-svn: 232089
2015-03-12 19:53:06 +00:00
Viktor Kutuzov 285dd51b7b [Tsan] Do not declare std_suppressions when not used
Differential Revision: http://reviews.llvm.org/D8288

llvm-svn: 232074
2015-03-12 18:14:42 +00:00
Viktor Kutuzov 07a21dc46d [Tsan] Adjust SA_SIGINFO and SIG_SETMASK values on FreeBSD.
Differential Revision: http://reviews.llvm.org/D8176

llvm-svn: 232073
2015-03-12 18:12:43 +00:00
Viktor Kutuzov 74c2001f3f [Sanitizers] Fix sanitizers to build on FreeBSD.
Differential Revision: http://reviews.llvm.org/D8175

llvm-svn: 232072
2015-03-12 18:10:06 +00:00
Dmitry Vyukov b75212878f tsan: fix a bug in MetaMap::ResetRange
The bug was uncovered by NegativeTests.MmapTest from
data-race-test suite, so port it as well.

llvm-svn: 232032
2015-03-12 12:48:19 +00:00
Dmitry Vyukov a60829a1b6 tsan: fix crash during __tsan_java_move
Munmap interceptor did not reset meta shadow for the range,
and __tsan_java_move crashed because it encountered
non-zero meta shadow for the destination.

llvm-svn: 232029
2015-03-12 11:24:16 +00:00
Kuba Brecka 656e184f6c Adding the implementation of atos and dladdr symbolizers for OS X.
They are currently still *not* used, "llvm-symbolizer" is still the default symbolizer on OS X.

Reviewed at http://reviews.llvm.org/D6588

llvm-svn: 232026
2015-03-12 10:53:18 +00:00
Kuba Brecka 3c53266ca8 Make the UBSan coverage-levels.cc test be Linux specific
Reviewed at http://reviews.llvm.org/D8278

llvm-svn: 232025
2015-03-12 10:44:34 +00:00
Joerg Sonnenberger c8f5c18714 Be nicer to C90 environments and avoid the declaration of variables in for
header.

From Alexander Esilevich.

llvm-svn: 231975
2015-03-11 22:06:53 +00:00
Joerg Sonnenberger 099de18c42 Always include stddef.h to make sure size_t exists.
From Alexander Esilevich.

llvm-svn: 231972
2015-03-11 21:58:40 +00:00
Joerg Sonnenberger 91bd698eaf Refactor float to integer conversion to share the same code.
80bit Intel/PPC long double is excluded due to lacking support
for the abstraction. Consistently provide saturation logic.
Extend to long double on 128bit IEEE extended platforms.

Initial patch with test cases from GuanHong Liu.
Reviewed by Steve Canon.

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

llvm-svn: 231965
2015-03-11 21:13:56 +00:00
Timur Iskhodzhanov 81514e0660 [ASan/Win] Fix a CHECK failure when an exception is thrown from a callback passed to QueueUserWorkItem
llvm-svn: 231947
2015-03-11 17:47:10 +00:00
Dmitry Vyukov 2d78c6371d asan: fix leak test for power platform
Power is 64-bit but does not support leak detection,
so this test fails. Use the more robust leak-detection
predicate instead.

llvm-svn: 231782
2015-03-10 10:36:06 +00:00
Kostya Serebryany 48a4023f40 [sanitizer] fix instrumentation with -mllvm -sanitizer-coverage-block-threshold=0 to actually do something useful.
llvm-svn: 231736
2015-03-10 01:58:27 +00:00
Alexey Samsonov de34ec0193 Revert "Revert "[UBSan] Add testcases for -fsanitize=shift-base and -fsanitize=shift-exponent.""
Re-land r231151 now that -fsanitize=shift-base implementation should not
introduce undefined behavior.

llvm-svn: 231712
2015-03-09 21:50:40 +00:00
Kuba Brecka ae219d3d3c Symbolizer refactoring: Merge common parts of POSIXSymbolizer and WinSymbolizer
Reviewed at http://reviews.llvm.org/D8105

llvm-svn: 231680
2015-03-09 18:36:28 +00:00
Joerg Sonnenberger ef24b4171d At least on NetBSD, sys/errno.h and errno.h are different, so use the
correct header to get errno.

llvm-svn: 231647
2015-03-09 11:23:29 +00:00
Joerg Sonnenberger 6d7cb4668f Avoid warnings on !PowerPC
llvm-svn: 231609
2015-03-08 21:08:39 +00:00
Joerg Sonnenberger 531cf7f491 Don't produce warnings on !PowerPC.
llvm-svn: 231608
2015-03-08 21:06:58 +00:00
Kuba Brecka 133b615558 Adding sanitizer_symbolizer_win.h to CMakeLists.txt
llvm-svn: 231562
2015-03-07 11:04:36 +00:00
Kostya Serebryany 136494c256 [asan] Fix 2 problems in nohugepage_test.
1. /proc/self/smaps may be bigger than 1 << 14.  On my machine, it is
26KB.
2. The read system call may return a partially filled buffer.  We need
to check the return value from read.

Patch by H.J. Lu

llvm-svn: 231502
2015-03-06 19:33:58 +00:00
Sergey Matveev 4a792988b3 [asan] Allow users of asan_symbolize.py to forbid fallback to atos/addr2line.
llvm-svn: 231492
2015-03-06 17:05:28 +00:00
Kuba Brecka 9930aaa9ed Symbolizer refactoring: Make WinSymbolizer use SymbolizerTool interface
Reviewed at http://reviews.llvm.org/D8089

llvm-svn: 231478
2015-03-06 14:33:56 +00:00
Dmitry Vyukov 0fc13a9a82 asan: fix comment formatting
As per comments in http://reviews.llvm.org/D8032

llvm-svn: 231457
2015-03-06 08:43:44 +00:00
Kuba Brecka da0204d05f Add a symbolizer testcase for closed stdin/stdout
Reviewed at http://reviews.llvm.org/D7973

llvm-svn: 231429
2015-03-05 23:41:47 +00:00
Kuba Brecka 334f9c4ed8 Print out which symbolizer are we using when verbosity >= 2
Reviewed at http://reviews.llvm.org/D8087

llvm-svn: 231428
2015-03-05 23:38:23 +00:00
Kostya Serebryany 769ddaa2d4 [sanitizer] Reconstruct the function that dumps block/edge coverage, hopefully making it more robust. Also increase the allowed coverage size on 32-bit.
llvm-svn: 231413
2015-03-05 22:19:25 +00:00
Alexey Samsonov 4833452c0c Revert "[UBSan] Add testcases for -fsanitize=shift-base and -fsanitize=shift-exponent."
The test case fails on AArch64.

llvm-svn: 231410
2015-03-05 21:57:47 +00:00
Joerg Sonnenberger 8a1f0446c0 Move use of __builtin_longjmp under the same conditions as the only
caller of the function.

llvm-svn: 231402
2015-03-05 20:17:05 +00:00
Dmitry Vyukov 72f169797e tsan: fix signal handling during stop-the-world
Long story short: stop-the-world briefly resets SIGSEGV handler to SIG_DFL.
This breaks programs that handle and continue after SIGSEGV (namely JVM).
See the test and comments for details.

This is reincarnation of reverted r229678 (http://reviews.llvm.org/D7722).
Changed:
- execute TracerThreadDieCallback only on tracer thread
- reset global data in TracerThreadSignalHandler/TracerThreadDieCallback
- handle EINTR from waitpid

Add 3 new test:
- SIGSEGV during leak checking
- StopTheWorld operation during signal storm from an external process
- StopTheWorld operation when the program generates and handles SIGSEGVs

http://reviews.llvm.org/D8032

llvm-svn: 231367
2015-03-05 14:37:28 +00:00
Kuba Brecka 5c4ce05d6a Symbolizer refactoring: Link symbolizer tools into a fallback chain
Reviewed at http://reviews.llvm.org/D8049

llvm-svn: 231361
2015-03-05 09:47:13 +00:00
Kostya Serebryany c1d6ab9a1e [sanitizer] add a run-time flag to dump the coverage counter bitset
llvm-svn: 231343
2015-03-05 02:48:51 +00:00
Kostya Serebryany c89aa6d697 [sanitizer] use simpler symbolizer interface (GetModuleNameForPc) where applicable
llvm-svn: 231337
2015-03-05 01:30:36 +00:00
Alexey Samsonov f3761c36f2 [ASan] Fix asan-(32|64)-bits lit tests feature.
It broke down at some point, and all tests with
  REQUIRES: asan-(32|64)-bits
line stopped being executed. Restore the intended behavior.

llvm-svn: 231325
2015-03-05 00:33:11 +00:00
Kostya Serebryany 07aee9c2c6 [sanitizer] when dumping coverage bitset, dump seperate file for every module, instead of dumping a single combined bitset
llvm-svn: 231319
2015-03-04 23:41:55 +00:00
Alexey Samsonov 27f4571a5a [Sanitizer] Fix/suppress compiler warnings in unit tests.
llvm-svn: 231293
2015-03-04 21:54:20 +00:00
Alexey Samsonov 00fb6c9da0 Exclude LLVM sources from lint check.
Checking files from different repository is not nice, and LLVM code
follows its own style guide anyway.

llvm-svn: 231289
2015-03-04 21:38:10 +00:00
Kostya Serebryany 46e5d5c669 [sanitizer] Since x32 runs under 64-bit kernel, GetKernelAreaSize should return 0
llvm-svn: 231283
2015-03-04 20:32:06 +00:00
Kostya Serebryany 4bdf5ada18 [asan] more fixes for x32, patches by H.J. Lu
llvm-svn: 231174
2015-03-03 23:46:40 +00:00
Kostya Serebryany 92b8ab502c [asan] attempting to fix the windows build
llvm-svn: 231171
2015-03-03 23:38:24 +00:00
Kostya Serebryany be5e0ed919 [sanitizer/coverage] Add AFL-style coverage counters (search heuristic for fuzzing).
Introduce -mllvm -sanitizer-coverage-8bit-counters=1
which adds imprecise thread-unfriendly 8-bit coverage counters.

The run-time library maps these 8-bit counters to 8-bit bitsets in the same way
AFL (http://lcamtuf.coredump.cx/afl/technical_details.txt) does:
counter values are divided into 8 ranges and based on the counter
value one of the bits in the bitset is set.
The AFL ranges are used here: 1, 2, 3, 4-7, 8-15, 16-31, 32-127, 128+.

These counters provide a search heuristic for single-threaded
coverage-guided fuzzers, we do not expect them to be useful for other purposes.

Depending on the value of -fsanitize-coverage=[123] flag,
these counters will be added to the function entry blocks (=1),
every basic block (=2), or every edge (=3).

Use these counters as an optional search heuristic in the Fuzzer library.
Add a test where this heuristic is critical.

llvm-svn: 231166
2015-03-03 23:27:02 +00:00
Kuba Brecka b126894b96 Symbolizer refactoring: Unify access to symbolizer tools from POSIXSymbolizer
Reviewed at http://reviews.llvm.org/D8029

llvm-svn: 231162
2015-03-03 23:13:02 +00:00
Alexey Samsonov 987666d57c [UBSan] Add testcases for -fsanitize=shift-base and -fsanitize=shift-exponent.
llvm-svn: 231151
2015-03-03 22:15:44 +00:00
Kuba Brecka e87a26c0ed Symbolizer refactoring: Turn FillAddressAndModuleInfo into FillModuleInfo
Reviewed at http://reviews.llvm.org/D8020

llvm-svn: 231061
2015-03-03 09:18:44 +00:00
Kostya Serebryany 3e7825efb5 [asan] Since x32 has 32-bit pointers, it should use the same code sequence as ia32 for AddressSanitizer asm_flags test. Patch by H.J. Lu
llvm-svn: 231052
2015-03-03 02:45:21 +00:00
Kuba Brecka 249a9e3a7f Symbolizer refactoring: Make LibbacktraceSymbolizer adopt the SymbolizerTool interface
Reviewed at http://reviews.llvm.org/D7971

llvm-svn: 231032
2015-03-02 22:56:25 +00:00
Kuba Brecka 59e8c3b342 Symbolizer refactoring: ExtractToken and friends
Reviewed at http://reviews.llvm.org/D7867

llvm-svn: 231027
2015-03-02 22:15:14 +00:00
Alexey Samsonov 990864018f [Sanitizer] Run test/sanitizer_common lit tests on all supported architectures.
llvm-svn: 231025
2015-03-02 22:03:52 +00:00
Kuba Brecka 898270513d Symbolizer refactoring: Move internals to separate files
Reviewed at http://reviews.llvm.org/D7972

llvm-svn: 231014
2015-03-02 21:15:09 +00:00
Renato Golin 26af9c9024 Allow compiler-rt build on Bitrig
This is the only patch Bitrig uses for compiler-rt. It adds support
for Bitrig/arm in the clear cache code.

Patch by Patrick Wildt.

llvm-svn: 231012
2015-03-02 21:02:43 +00:00
Timur Iskhodzhanov 18cfba9fa4 [ASan/Win] Work around PR22545: call LLVM global_dtors in the MD atexit()
llvm-svn: 231000
2015-03-02 19:41:09 +00:00
Alexey Samsonov d06aa3dc00 [MSan] Remove explicit -m64 from RUN lines.
Target-specific flags should usually be configured by CMake/lit.

llvm-svn: 230999
2015-03-02 19:34:27 +00:00
Alexey Samsonov 3e40703ab5 [DFSan] Remove explicit -m64 from RUN lines.
Target-specific flags should usually be configured by CMake/lit.

llvm-svn: 230997
2015-03-02 19:34:06 +00:00
Alexey Samsonov 1ce8745b77 [Sanitizer] Restrict open_memstream to x86_64. Fixes PR22714.
llvm-svn: 230996
2015-03-02 19:34:02 +00:00
Alexey Samsonov 1be519876d [Sanitizer] Fix StripPathPrefix function and improve test case.
llvm-svn: 230986
2015-03-02 18:55:46 +00:00
Dmitry Vyukov df01bdca70 asan: fix windows build after commit 230978
llvm-svn: 230980
2015-03-02 17:45:18 +00:00
Dmitry Vyukov b79ac88155 asan: fix signal handling during stoptheworld
The problem is that without SA_RESTORER flag, kernel ignores the handler. So tracer actually did not setup any handler.
Add SA_RESTORER flag when setting up handlers.
Add a test that causes SIGSEGV in stoptheworld callback.
Move SignalContext from asan to sanitizer_common to print better diagnostics about signal in the tracer thread.

http://reviews.llvm.org/D8005

llvm-svn: 230978
2015-03-02 17:36:02 +00:00
Sergey Matveev 348800b3d9 [asan] Demote "trying to poison/unpoison memory region" messages...
... to verbosity level 3. Because log spam.

llvm-svn: 230974
2015-03-02 17:13:38 +00:00
Timur Iskhodzhanov 45ddd694fd [ASan/Win] Rename a test.
I came up with the original name trying to test a different issue and forgot to rename afterwards

llvm-svn: 230961
2015-03-02 14:49:44 +00:00
Hans Wennborg 521a941074 Revert r229678 "tsan: fix signal handling during stop-the-world"
This was causing Chromium's browser_tests to flakily segfault during
leak check.

llvm-svn: 230874
2015-02-28 22:18:11 +00:00
Saleem Abdulrasool 06609c64d7 build: remove the stub linux SDK
The SDK is insufficient to really build much.  The builtins can be built
standalone now which is what the stub SDK was meant to permit.  Remove the
unnecessary files.

llvm-svn: 230869
2015-02-28 20:30:11 +00:00
Kuba Brecka ca48abc9b3 Fix OS X build failure with Command Line Tools and without full Xcode installation
On OS X, if you don't have a full Xcode installation, but just the Command Line Tools package, xcrun and xcodebuild don't return a valid SDK root path. In these cases, let's use "/" as the SDK root (which is where the headers and libraries are installed).

Reviewed at http://reviews.llvm.org/D7641

llvm-svn: 230847
2015-02-28 12:25:10 +00:00
Kuba Brecka 8f23ce244c Symbolizer refactoring: SymbolizerTool and better interface
Reviewed at: http://reviews.llvm.org/D7936

llvm-svn: 230842
2015-02-28 09:39:05 +00:00
Petar Jovanovic 9ef0d1c145 [MIPS] Add missing header for syscall
The syscall function itself is declared in <unistd.h>
Compiling compiler-rt with -Werror-implicit-function-declaration will
cause a build failure. This change fixes it.

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

llvm-svn: 230838
2015-02-28 02:32:55 +00:00
Alexey Samsonov 34dc40730a [ASan] debug_stacks.cc was passing on ARM by accident, disable this test there for now.
llvm-svn: 230833
2015-02-28 01:35:46 +00:00
Timur Iskhodzhanov 342f5dead0 [ASan/Win] Update test expectations after r230724
llvm-svn: 230755
2015-02-27 14:29:53 +00:00
Kuba Brecka 1cd77d4f13 [compiler-rt] Symbolizer refactoring: Abstract SymbolizerProcess better
Reviewed at http://reviews.llvm.org/D7889

llvm-svn: 230749
2015-02-27 11:11:05 +00:00
Anna Zaks 2249049db2 [compiler-rt] Allow suppression file to be relative to the location of the executable
The ASanified executable could be launched from different locations. When we
cannot find the suppression file relative to the current directory, try to
see if the specified path is relative to the location of the executable.

llvm-svn: 230723
2015-02-27 03:12:19 +00:00
Alexey Samsonov 0b0cafc8fc [Sanitizer] Print column number in SUMMARY line if it's available.
llvm-svn: 230721
2015-02-27 02:29:25 +00:00
Alexey Samsonov 655bd0200c [CMake] Effectively revert r230683.
Clang in 32-bit mode may choose to target different architecture
than host compiler.

llvm-svn: 230709
2015-02-27 00:07:04 +00:00
Alexey Samsonov a716618927 [CMake] Make sure we built one variant of i386/i686 runtime libraries.
llvm-svn: 230683
2015-02-26 21:03:41 +00:00
Alexey Samsonov 1c915782b9 [UBSan] Run all UBSan tests in 32-bit mode as well.
We build and support UBSan on 32-bit platforms. We should run tests
there as well. Fixes PR22683.

llvm-svn: 230662
2015-02-26 19:19:44 +00:00
Evgeniy Stepanov 504f0987fe [msan] Fix MsanTest to pass in track_origins=2 mode.
llvm-svn: 230639
2015-02-26 15:19:33 +00:00
Sergey Matveev b0caac77dd [lsan] Fix indent.
llvm-svn: 230633
2015-02-26 14:25:25 +00:00
Sergey Matveev c9b2cd5c8c LSan: fix a deadlock caused by dl_iterate_phdr().
Wrap the StopTheWorld call in a dl_iterate_phdr() callback. This ensures that no
other threads are holding the libdl lock, and we can safely reenter it in the
tracer thread.

llvm-svn: 230631
2015-02-26 14:01:08 +00:00
Kostya Serebryany ba9422971c [asan] reenable odr-violation.cc test on non-x86-64 after confirming that it's fixed. PR22699
llvm-svn: 230573
2015-02-25 23:23:01 +00:00
Alexey Samsonov 819045cdd6 [CMake] Properly detect whether we're building runtime for i386 or i686.
llvm-svn: 230569
2015-02-25 23:07:32 +00:00
Kuba Brecka 71b3a69433 Fix >80 line after r230530.
llvm-svn: 230541
2015-02-25 20:56:04 +00:00
Kostya Serebryany 497eeb598b [asan] restict no_asan_gen_globals.c test to 64-bit due to PR22682
llvm-svn: 230537
2015-02-25 20:19:23 +00:00
Peter Collingbourne 4be9b40091 CFI: Add a check-cfi-and-supported rule.
This rule works like check-cfi, but fails if the tests are unsupported.
This is useful to run on bots if we want to be sure that the tests aren't
silently being skipped.

llvm-svn: 230536
2015-02-25 20:14:05 +00:00
Kuba Brecka 8f12ce0825 [compiler-rt] Symbolizer refactoring: Move SymbolizerProcess interface to header
Reviewed at http://reviews.llvm.org/D7868

llvm-svn: 230530
2015-02-25 19:50:38 +00:00
Kuba Brecka d831a73b32 [compiler-rt] Symbolizer refactoring: Move string parsing into separate functions
Reviewed at http://reviews.llvm.org/D7869

llvm-svn: 230529
2015-02-25 19:35:08 +00:00
Kostya Serebryany 2a102cbc77 [asan] temporary disable the test on non-x86-64 while we are investigating PR22699
llvm-svn: 230516
2015-02-25 18:03:03 +00:00
Timur Iskhodzhanov 5c3f1c91f2 Address post-commit feedback on r230344: Don't use weak hooks on Sanitizer Go build for Windows
llvm-svn: 230507
2015-02-25 17:19:42 +00:00
Timur Iskhodzhanov 40d72d9a1f Reland r230019 - [ASan] Make the argument of '__sanitizer_annotate_contiguous_container' is not aligned error message easier to understand
This incorporates the fix for ARM architecture suggested by Renato Golin.

llvm-svn: 230506
2015-02-25 17:03:34 +00:00
Timur Iskhodzhanov 73e5951ed9 Fix duplicate test code introduced by running "patch -p0" twice
Sorry, SVN had some weird problems so I had to revert and reapply the patch
locally a couple of times and didn't notice I've added file contents to the same
file....

llvm-svn: 230505
2015-02-25 17:01:09 +00:00
Timur Iskhodzhanov 5c62af5bb1 Reland r230419 - add __asan_default_suppressions() hook with a fix for Windows
llvm-svn: 230501
2015-02-25 16:00:26 +00:00
Vasileios Kalintiris c9c7a3e4e5 InstrProf: Fix warnings for mixed declarations and code. NFC.
llvm-svn: 230494
2015-02-25 13:50:18 +00:00
Nico Weber d70bb8d8cb Revert 230419, 230425, 230432.
They don't build on Windows.
http://lab.llvm.org:8011/builders/sanitizer-windows/ went red for example.

llvm-svn: 230461
2015-02-25 04:39:21 +00:00
Kostya Serebryany 63419712f8 [asan] one more attempt to fix windows build
llvm-svn: 230432
2015-02-25 02:00:26 +00:00
Kostya Serebryany a54860e058 [asan] attempting to fix the windows build
llvm-svn: 230425
2015-02-25 01:41:42 +00:00
Kostya Serebryany 74dc7ea2e9 [asan] add __asan_default_suppressions() hook
llvm-svn: 230419
2015-02-25 01:15:37 +00:00
Kostya Serebryany efa60dfd34 [asan] add suppressions for odr violations
llvm-svn: 230409
2015-02-25 00:49:12 +00:00
Kostya Serebryany c1d8a371bf [asan] fix odr-violation.cc test to always use slow unwinding (hopefully fixes the ARM bot)
llvm-svn: 230356
2015-02-24 18:52:38 +00:00
Timur Iskhodzhanov 6ba66b95d1 [ASan/Win] Add support for sanitizer allocator hooks, __asan_default_options and __asan_on_error
llvm-svn: 230344
2015-02-24 17:07:22 +00:00
Renato Golin 9b1e758a55 Allow sanitizer to work with "old" kernel headers
Sanitizers work on ancient kernels and were depending on types existing.
When those types were removed, the sanitizer build broke. See bug
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59009 for more information.

This patch fixes it by isolating the need for those types only when the
feature is actually needed, thus allowing one to compile the kernel with
or without that change, irrespective of its version.

Patch by Christophe Lyon.

llvm-svn: 230324
2015-02-24 11:38:41 +00:00
Kuba Brecka 90c8b0e092 Try to unbreak sanitizer-x86_64-linux-autoconf after r230318
The buildbot failed to build with

    error: variable ‘enable_fp’ set but not used [-Werror=unused-but-set-variable]

let's add a `(void)enable_fp;`.

llvm-svn: 230323
2015-02-24 11:12:44 +00:00
Kuba Brecka 987bf0400d Fix the ASan ioctl.cc test when using COMPILER_RT_DEBUG=On
In debug mode (COMPILER_RT_DEBUG=On), we still build with -fomit-frame-pointer and wrap_ioctl doesn't set up a proper stack frame.  In release mode it does, because ioctl_common_pre gets inlined into wrap_ioctl and it uses the COMMON_INTERCEPTOR_READ_RANGE macro which in the end calls GET_CURRENT_FRAME and that forces the compiler to generate a stack frame for the function.

Not having a proper stack frame breaks the unwinder.  This patch forces to generate a frame pointer (via ENABLE_FRAME_POINTER macro).

Reviewed at http://reviews.llvm.org/D7815

llvm-svn: 230318
2015-02-24 10:10:25 +00:00
Kuba Brecka e4ac10179c Fix alloca_instruments_all_paddings.cc test to work under higher -O levels (compiler-rt part)
When AddressSanitizer only a single dynamic alloca and no static allocas, due to an early exit from FunctionStackPoisoner::poisonStack we forget to unpoison the dynamic alloca.  This patch fixes that.

Reviewed at http://reviews.llvm.org/D7810

llvm-svn: 230317
2015-02-24 09:47:33 +00:00
Alexey Samsonov f535d33fee [ASan] Disable strict init-order checking if dlopen() is called.
Revise the fix to https://code.google.com/p/address-sanitizer/issues/detail?id=178:
always disable strict init-order checking the first time dlopen() is
called: at this point shared library is allowed to access globals
defined in the main executable, as they are guaranteed to be
initialized. Revise the test cases:
* simplify init-order-dlopen.cc test case: make it Linux-specific
  (there's no strict init-order checking on other platforms anyway),
  and single-threaded.
* reinforce init-order-pthread-create.cc test case: make sure that
  init-order checker would produce a false positive unless we
  turn it off at the moment we call pthread_create().

llvm-svn: 230288
2015-02-24 00:37:27 +00:00
Kostya Serebryany 04d482e924 [asan] when registering globals, use the same unwinder as we use for malloc, instead of the one used for FATAL crash (which may be too slow)
llvm-svn: 230256
2015-02-23 20:40:53 +00:00
Alexey Samsonov 1f5bcbe918 Re-land part of r230171: fix GoTsanRuntimeCheck with ccache.
llvm-svn: 230247
2015-02-23 19:35:42 +00:00
Alexey Samsonov 562145c4e1 Add -fdefine-sized-deallocation to ASan test case.
This flag is now needed to force Clang emit the weak definition
of sized delete if it's not present in the header.

llvm-svn: 230242
2015-02-23 19:18:31 +00:00
Ed Schouten f6d492e683 Use compiler provided endianness definitions if available.
This makes int_endianness.h work on operating systems for which we
haven't written explicit constructs, as long as GCC or Clang are being
used.

llvm-svn: 230208
2015-02-23 09:27:49 +00:00
Ismail Pazarbasi 87f4c90a5c Unix/BSD system calls are prefixed with SYS_ on FreeBSD and Mac
Also, __syscall form should be used when one or more of the
parameters is a 64-bit argument to ensure that argument alignment
is correct.

llvm-svn: 230183
2015-02-22 22:01:09 +00:00
Renato Golin 4b1482e75c Revert "[ASan] Make the argument of '__sanitizer_annotate_contiguous_container' is not aligned error message easier to understand"
This reverts commit r230019, as it was breaking the ARM sanitizer buildbot
and let other errors be introduced since it wasn't fixed/reverted in
time.

llvm-svn: 230179
2015-02-22 18:58:18 +00:00
Dmitri Gribenko 9cbc6f42aa Revert r230171 "TSan runtime: unbreak the build with ccache"
It broke a buildbot with a non-clang (?) compiler.

llvm-svn: 230174
2015-02-22 12:20:05 +00:00
Kuba Brecka 3280dc7081 Whitespace fix for r230172.
llvm-svn: 230173
2015-02-22 11:49:21 +00:00
Kuba Brecka 11bb33c78b Fix gc-test.cc to work under higher -O levels
The gc-test.cc tries underflows of a variable up to -32 bytes, but on i386, the left redzone is not 32 bytes, it’s only 16 bytes and therefore the access to var[-32] is completely off. The reason why this test didn’t fail before is that we’ve been lucky and there was another variable before the var array, which was also instrumented. This fix uses “-32” for 64-bit systems and “-16” for 32-bit.

Reviewed at http://reviews.llvm.org/D7809

llvm-svn: 230172
2015-02-22 11:12:17 +00:00
Dmitri Gribenko bc4c42c345 TSan runtime: unbreak the build with ccache
llvm-svn: 230171
2015-02-22 11:04:59 +00:00
Peter Collingbourne 6b0d0464a8 Run simple-fail.cpp at -O{1,2,3}.
It's probably overkill to run the other tests at -O* given the increasing
combinatorial explosion.

llvm-svn: 230117
2015-02-21 01:48:51 +00:00
Peter Collingbourne f1d13da249 CFI: Add tests for 32-bit, 64-bit and memory bitsets. Break optimization in more places.
llvm-svn: 230116
2015-02-21 01:36:08 +00:00
Filipe Cabecinhas 0385152752 Don't set $LIB if we're not targetting windows.
Reviewers: timurrrr, samsonov

Subscribers: llvm-commits

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

llvm-svn: 230091
2015-02-20 23:35:19 +00:00
Peter Collingbourne e0c4f7eb81 Add test suite for the Control Flow Integrity feature.
Differential Revision: http://reviews.llvm.org/D7738

llvm-svn: 230056
2015-02-20 20:31:18 +00:00
Alexey Samsonov d1c318657b [Sanitizer] Refactor SuppressionContext class.
SuppressionContext is no longer a singleton, shared by all sanitizers,
but a regular class. Each of ASan, LSan, UBSan and TSan now have their
own SuppressionContext, which only parses suppressions specific to
that sanitizer.

"suppressions" flag is moved away from common flags into tool-specific
flags, so the user now may pass
  ASAN_OPTIONS=suppressions=asan_supp.txt LSAN_OPIONS=suppressions=lsan_supp.txt
in a single invocation.

llvm-svn: 230026
2015-02-20 17:41:59 +00:00
Timur Iskhodzhanov 8af971b267 [ASan] Make the argument of '__sanitizer_annotate_contiguous_container' is not aligned error message easier to understand
llvm-svn: 230019
2015-02-20 15:45:51 +00:00
Timur Iskhodzhanov d3e81e9625 [ASan/Win] Work around PR22545 - unregister globals when using the MD runtime
llvm-svn: 230018
2015-02-20 15:34:16 +00:00
Mohit K. Bhakkad 846de99fbd [TSan][MIPS64] Fix few more test cases for MIPS64
Patch by Sagar Thakur

Reviewers: dvyukov, samsonov, kcc.

Subscribers:  dsanders, mohit.bhakkad, Anand.Takale, llvm-commits.

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

llvm-svn: 230002
2015-02-20 09:32:45 +00:00
Mohit K. Bhakkad a46d5a7438 [TSan][MIPS] Adding support for MIPS64
Patch by Sagar Thakur

Reviewers: dvyukov, samsonov, petarj, kcc, dsanders.

Subscribers:  mohit.bhakkad, Anand.Takale, llvm-commits.

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

llvm-svn: 229972
2015-02-20 06:42:41 +00:00
Filipe Cabecinhas a1225be1ea Make FileCheck be a common dependency, not an ASan one.
Summary:
It still gets picked up by ASan, but it also gets picked up by the other
test suites.

Otherwise, some test suites (e.g: UBSan) would complain they had no
dependencies, and wouldn't run.

Reviewers: samsonov, eugenis

Subscribers: llvm-commits

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

llvm-svn: 229962
2015-02-20 03:41:07 +00:00
Alexey Samsonov 36afc349e8 [Sanitizer] Remove multiline comment to silence GCC warning. NFC.
llvm-svn: 229948
2015-02-20 01:45:51 +00:00
Kostya Serebryany 885994618c [sanitizer] when dumping the basic block trace, also dump the module names. Patch by Laszlo Szekeres
llvm-svn: 229940
2015-02-20 00:30:44 +00:00
Alexey Samsonov 1ec3c5bc99 [Sanitizer] Drop LibIgnore dependency on SuppressionContext. NFC.
Let each LibIgnore user (for now it's only TSan) manually go
through SuppressionContext and pass ignored library templates to
LibIgnore.

llvm-svn: 229924
2015-02-19 22:56:49 +00:00
Alexey Samsonov d2c20c49f8 [Sanitizer] Move TemplateMatch() to sanitizer_common.cc. NFC.
llvm-svn: 229923
2015-02-19 22:56:47 +00:00
Timur Iskhodzhanov 2462a2f404 [ASan/Win] Thread sanitizer common interface through asan_win_dll_thunk.cc
llvm-svn: 229860
2015-02-19 15:25:26 +00:00
Timur Iskhodzhanov 7a010dc5e7 [Sanitizers] Move the common sanitizer interface from sanitizer_internal_defs.h to a new sanitizer_interface_internal.h file
Reviewed at http://reviews.llvm.org/D7758

llvm-svn: 229858
2015-02-19 15:15:33 +00:00
Mohit K. Bhakkad 88077324c6 [LSan][MIPS64] Enable LSan testing for mips64/mips64el
Patch by Sagar Thakur

Reviewers: petarj, earthdok, kcc.

Subscribers:  samsonov, dsanders, mohit.bhakkad, Anand.Takale, llvm-commits.

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

llvm-svn: 229833
2015-02-19 09:14:43 +00:00
Dmitry Vyukov c0e912dd7b tsan: fix PTRACE_ATTACH handling during stop-the-world
If the thread receives a signal concurrently with PTRACE_ATTACH,
we can get notification about the signal before notification about stop.
In such case we need to forward the signal to the thread, otherwise
the signal will be missed (as we do PTRACE_DETACH with arg=0) and
any logic relying on signals will break. After forwarding we need to
continue to wait for stopping, because the thread is not stopped yet.
We do ignore delivery of SIGSTOP, because we want to make stop-the-world
as invisible as possible.

http://reviews.llvm.org/D7723

 --This line, and those below, will be ignored--
M    lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
M    test/tsan/signal_segv_handler.cc

llvm-svn: 229832
2015-02-19 09:02:29 +00:00
Mohit K. Bhakkad 36f974d76b [LSan] [MIPS] adding support of LSan for mips64/mips64el arch
Patch by Sagar Thakur

Reviewers: petarj, earthdok, kcc.

Subscribers:  samsonov, dsanders, mohit.bhakkad, Anand.Takale, llvm-commits.

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

llvm-svn: 229830
2015-02-19 07:30:39 +00:00
Alexey Samsonov d311566e1a Remove support for building sanitizers from Makefile/autoconf build on Linux.
This is a re-application of r229554 restricted to Linux build only.
Apple still uses Makefile/autoconf to build Clang and sanitizers.

llvm-svn: 229756
2015-02-18 22:26:49 +00:00
Renato Golin 67bf4bd316 Revert "Enable ASAN build and test on AArch64"
This reverts commit r229665. It seems that the AArch64 ASAN tests, that
pass on all our internal machines, doesn't like the public buildbot.

Turning this off until we can investigate the public bot for a better
understanding.

llvm-svn: 229739
2015-02-18 20:30:32 +00:00
Greg Fitzgerald 127f4e5c6a [ASan] Set DYLD_LIBRARY_PATH on Darwin
Differential Revision: http://reviews.llvm.org/D7706

llvm-svn: 229714
2015-02-18 18:26:58 +00:00
Timur Iskhodzhanov 805d807139 [ASan/Win] Speculative fix to make the sed command line work with all sed implementations
llvm-svn: 229679
2015-02-18 15:14:07 +00:00
Dmitry Vyukov 8870ee7755 tsan: fix signal handling during stop-the-world
Long story short: stop-the-world briefly resets SIGSEGV handler to SIG_DFL.
This breaks programs that handle and continue after SIGSEGV (namely JVM).
See the test and comments for details.

http://reviews.llvm.org/D7722

llvm-svn: 229678
2015-02-18 15:13:29 +00:00
Renato Golin ee130d1c2a Enable ASAN build and test on AArch64
llvm-svn: 229665
2015-02-18 11:34:41 +00:00
Dmitry Vyukov 2a80437038 tsan: add -Wno-maybe-uninitialized to mingw gcc build flags
As per discussion with David Blaikie here:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20150216/260289.html

llvm-svn: 229657
2015-02-18 09:37:31 +00:00
Mohit K. Bhakkad b40fed04e7 [MSan][MIPS] Fix for some failing tests on MIPS64
Enabling internal ptrace for mips, which fixes some
ptrace related tests. Along with this fixing some
other failures.

Reviewers: Reviewers: eugenis, kcc, samsonov

Subscribers: dsanders, sagar, lldb-commits

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

llvm-svn: 229656
2015-02-18 09:24:19 +00:00
Matthias Braun c0a2279099 Revert "Remove support for building sanitizers from Makefile/autoconf build."
This reverts commit r229556.

Reverting this for now as internal apple builds rely on this
functionality.

llvm-svn: 229585
2015-02-17 23:30:51 +00:00
Alexey Samsonov e194dfa6be [TSan] Provide default values for compile definitions.
Provide defaults for TSAN_COLLECT_STATS and TSAN_NO_HISTORY.
Replace #ifdef directives with #if. This fixes a bug introduced
in r229112, where building TSan runtime with -DTSAN_COLLECT_STATS=0
would still enable stats collection and reporting.

llvm-svn: 229581
2015-02-17 23:23:10 +00:00
Reid Kleckner c12cc5eba8 WinASan: Fix escaping in dll_host.cc test to work with internal shell
llvm-svn: 229570
2015-02-17 22:22:20 +00:00
Reid Kleckner 6fec509ac7 Silence an MSVC warning about testing a function for truth without calling it
In general, this is a reasonable warning, except real_pthread_create is
weak and can be null.  The existing usage is correct as it the function
is declared with SANITIZER_WEAK, but MSVC can't know that because it is
defined to nothing on Windows.

llvm-svn: 229562
2015-02-17 21:57:42 +00:00
Reid Kleckner 7885776604 Use lit's internal shell when running tests on Windows
The internal shell is faster and more predictable than any copy of
bash.exe on the user's system.

LLVM and Clang use the internal shell by default, and have an
environment variable to disable it. I don't think compiler-rt needs that
complexity, so I left it out.

llvm-svn: 229560
2015-02-17 21:57:10 +00:00
Alexey Samsonov d907016dd0 Remove support for building sanitizers from Makefile/autoconf build.
They autotools build has a number of missing features, supports less
OS, architectures, build configurations, doesn't have any tests and
is hard to support in sync with CMake build.

llvm-svn: 229556
2015-02-17 21:53:45 +00:00
Alexey Samsonov 79df187034 [LSan] Make parent tool responsible for initializing LSan flags.
Summary:
LSan can be combined with a parent tool (for now it's only ASan).
Also, we allow LSAN_OPTIONS to override certain common flags. It means
we have to parse LSAN_OPTIONS early enough, before the rest of the
parent tool (including chunks of sanitizer_common) is initialized.

In future, we can use the same approach for UBSan, after we embed it
into ASan runtime in a similar way.

Test Plan: regression test suite

Reviewers: earthdok, eugenis

Subscribers: llvm-commits

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

llvm-svn: 229519
2015-02-17 18:50:30 +00:00
Dimitry Andric 7a9afba9ad Remove inclusion of netinet/ip_compat.h for FreeBSD. This header is not
always available, and nothing in sanitizer_platform_limits_posix.cc uses
any of its definitions.

See also: https://svnweb.freebsd.org/changeset/base/277201

Reviewers: kcc, kutuzov.viktor.84, samsonov
Reviewed By: samsonov
Differential Revision: http://reviews.llvm.org/D7486

llvm-svn: 229518
2015-02-17 18:27:39 +00:00
Viktor Kutuzov dd82236273 [Msan] Fix the unit tests' PathToLoadable() to work on FreeBSD
Differential Revision: http://reviews.llvm.org/D7587

llvm-svn: 229491
2015-02-17 12:52:08 +00:00
Timur Iskhodzhanov f220f88fc9 [ASan/Win] Add an OOM test
llvm-svn: 229399
2015-02-16 15:24:20 +00:00
Evgeniy Stepanov 5c6de59ec4 [msan] Fix UnalignedLoad/UnalignedStore tests.
Add alignment attrubutes to ensure that the tests actually test unaligned
access irrespective of the stack layout.

llvm-svn: 229398
2015-02-16 15:05:14 +00:00
Dmitry Vyukov 620ebaa9c1 tsan: remove everything related to rss/background thread in Go mode
In Go mode the background thread is not started (internal_thread_start is empty).
There is no sense in having this code compiled in.
Also removes dependency on sanitizer_linux_libcdep.cc which is good,
ideally Go runtime does not depend on libc at all.

llvm-svn: 229396
2015-02-16 14:49:34 +00:00
Dmitry Vyukov 3ac5c27c1f tsan: fix freebsd build
GetTls is not defined in Go mode.

llvm-svn: 229395
2015-02-16 14:35:51 +00:00
Dmitry Vyukov 1236868f85 tsan: fix windows build script
add missing source files
+ add -std=c++11 as it is now required to build compiler-rt

llvm-svn: 229393
2015-02-16 13:54:32 +00:00
Dmitry Vyukov 78c25941ba tsan: fix compiler warning
mingw gcc complains:
warning: 'err' may be used uninitialized in this function [-Wmaybe-uninitialized]
       Printf("Failed to read options from '%s': error %d\n", value, err);

llvm-svn: 229392
2015-02-16 13:53:00 +00:00
Dmitry Vyukov 13fd535bcb tsan: fix shadow memory mapping on windows
llvm-svn: 229391
2015-02-16 13:52:04 +00:00
Dmitry Vyukov b3381fad11 tsan: exclude DumpProcessMap on windows
The function uses EnumProcessModules, which requires psapi.lib,
which is not linked with tsan on windows.

llvm-svn: 229390
2015-02-16 13:51:17 +00:00
Viktor Kutuzov 37a79210cb [Msan] Improve the EXPECT_NOT_POISONED() macro to provide the original line number
Differential Revision: http://reviews.llvm.org/D7341

llvm-svn: 229389
2015-02-16 13:30:52 +00:00
Viktor Kutuzov b1f54eeed4 [Msan] Make unit tests that use mempcpy() passing on FreeBSD
Differential Revision: http://reviews.llvm.org/D7588

llvm-svn: 229388
2015-02-16 13:26:32 +00:00
Viktor Kutuzov 1a55126699 [Msan] Disable the fgetgrent_r unit test on FreeBSD
Differential Revision: http://reviews.llvm.org/D7343

llvm-svn: 229387
2015-02-16 13:24:21 +00:00
Viktor Kutuzov f886b38a0e [Msan] Disable fcvt unit tests on FreeBSD
Differential Revision: http://reviews.llvm.org/D7340

llvm-svn: 229386
2015-02-16 13:22:07 +00:00
Viktor Kutuzov 4772b9c843 [Msan] Fix the getgrnam_r unit test to pass on FreeBSD
Differential Revision: http://reviews.llvm.org/D7339

llvm-svn: 229385
2015-02-16 13:19:21 +00:00
Viktor Kutuzov 2e19f31560 [Msan] Fix the sigaction unit test to build on FreeBSD
Differential Revision: http://reviews.llvm.org/D7335

llvm-svn: 229384
2015-02-16 13:15:58 +00:00
Viktor Kutuzov 7eff71a474 [Msan] Fix the ether unit test to build on FreeBSD
Differential Revision: http://reviews.llvm.org/D7334

llvm-svn: 229383
2015-02-16 13:13:53 +00:00
Viktor Kutuzov 0247b970c4 [Asan] Fix the dlclose-test.cc unit test to build on FreeBSD 11
Differential Revision: http://reviews.llvm.org/D7586

llvm-svn: 229381
2015-02-16 13:11:09 +00:00
Evgeniy Stepanov 84d30ba43a [asan] Support 'su' rooted devices in ASan setup script.
Android devices may not support 'adb root', but be rooted with 'su'
binary. This patch makes it possible to install ASAN to such
devices. When --use-su flag is specified, most 'adb ...' commangs are
changed to 'adb su -c "..."'.

Some other notes:
 * 'readlink' changed to 'ls -l', since not all devices have readlink
   in their firmware.
 * removing ASan library step moved to very end, because 'su' may not
   run properly without this library until shell will be restarted.

Patch by Dmitry <ripp at yandex-team dot ru>.

llvm-svn: 229368
2015-02-16 10:22:12 +00:00
Dmitry Vyukov a3bdbadfd2 tsan: fix build
Revision 229127 introduced a bug:
zero value is not OK for trace headers,
because stack0 needs constructor call.
Instead unmap the unused part of trace after
all ctors have been executed.

llvm-svn: 229263
2015-02-14 16:14:10 +00:00
Dmitry Vyukov 6aaedb0829 tsan: always subtract one from program counters
Go has a pending change to pass proper PCs to tsan:
https://go-review.googlesource.com/#/c/4902/
So now we can always subtract one from PCs.

llvm-svn: 229262
2015-02-14 16:06:22 +00:00
Filipe Cabecinhas 8cabc53215 Use @LINE instead of hardcoded line numbers
llvm-svn: 229190
2015-02-14 00:09:09 +00:00
Filipe Cabecinhas 22bba5dd4b Add -frtti to tests that need rtti
llvm-svn: 229184
2015-02-13 23:19:23 +00:00
Dmitry Vyukov 8a9d23bf53 tsan: don't initialize trace header in release mode
We are going to use only a small part of the trace with the default
value of history_size. However, the constructor writes to the whole trace.
It writes mostly zeros, so freshly mmaped memory will do.
The only non-zero field if mutex type used for debugging.

Reduces per-goroutine overhead by 8K.

https://code.google.com/p/thread-sanitizer/issues/detail?id=89

llvm-svn: 229127
2015-02-13 17:39:03 +00:00
Dmitry Vyukov b57e39e310 tsan: fix build
llvm-svn: 229120
2015-02-13 16:08:43 +00:00
Dmitry Vyukov 816bf44ac6 tsan: reduce history size in Go mode
The ContainsSameAccess optimization substantially reduces pressure
on trace by eliminating duplicate accesses. So now we can reduce
default trace size to reduce per-goroutine memory consumption.
Current default size is 64K events, new -- 32K events.
In either case user can change it with GORACE env var.

Reduces per-goroutine memory consumption from 356K to 226K.

llvm-svn: 229117
2015-02-13 15:59:23 +00:00
Dmitry Vyukov 05841b1e39 tsan: disable deadlock detector in Go mode
Go does not use that.
https://code.google.com/p/thread-sanitizer/issues/detail?id=89

llvm-svn: 229116
2015-02-13 15:44:50 +00:00
Dmitry Vyukov a22870ec7a tsan: remove internal deadlock detector from ThreadState in Go mode
Go does not use that.
https://code.google.com/p/thread-sanitizer/issues/detail?id=89

llvm-svn: 229115
2015-02-13 15:37:11 +00:00
Dmitry Vyukov c30c5f7d9d tsan: reduce size of vector clock in Go mode
Go does not have freed memory.
Reduces per-goroutine overhead from 455K to 356K.

https://code.google.com/p/thread-sanitizer/issues/detail?id=89

llvm-svn: 229113
2015-02-13 15:32:34 +00:00
Dmitry Vyukov 41f4eba02d tsan: remove stats from ThreadState ifndef TSAN_COLLECT_STATS
Issue 89: Uses a lot of memory for each goroutine
https://code.google.com/p/thread-sanitizer/issues/detail?id=89

llvm-svn: 229112
2015-02-13 15:25:47 +00:00
Dmitry Vyukov af3b09663b tsan: fix stack printing
strip_path_prefix was not stripped from file names.

llvm-svn: 229106
2015-02-13 14:27:43 +00:00
Alexey Samsonov 1225816a2d [Sanitizer] Change InitializeFlags() signatures. NFC.
These functions are always used to initialize singleton flags(), as
well as other global data (common_flags()).

llvm-svn: 228894
2015-02-12 00:36:42 +00:00
Alexey Samsonov c9b0ea6eec [Sanitizer] Add "final" specifier to FlagHandlerBase::Parse overrides. NFC.
llvm-svn: 228893
2015-02-12 00:36:39 +00:00
Dimitry Andric 349e062695 [Sanitizers] The MAP_NORESERVE define has been removed in FreeBSD 11.x,
and even before that, it was never implemented.  Just define it to zero
instead, so compiler-rt can compile on FreeBSD 11 and later.

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

llvm-svn: 228871
2015-02-11 19:48:27 +00:00
Alexey Samsonov 8812e73c63 [UBSan] Allow UBSan location to store frames returned by symbolizer.
Summary:
__ubsan::getFunctionLocation() used to issue a call to symbolizer, and
convert the result (SymbolizedStack) to one of UBSan structures:
SourceLocation, ModuleLocation or MemoryLocation. This:
(1) is inefficient: we do an extra allocation/deallocation to copy data,
while we can instead can just pass SymbolizedStack around (which
contains all the necessary data).
(2) leaks memory: strings stored in SourceLocation/MemoryLocation are
never deallocated, and Filipe Cabecinhas suggests this causes crashes
of UBSan-ified programs in the wild.

Instead, let Location store a pointer to SymbolizedStack object, and
make sure it's properly deallocated when UBSan handler exits.

ModuleLocation is made obsolete by this change, and is deleted.

Test Plan: check-ubsan test suite

Reviewers: rsmith, filcab

Subscribers: llvm-commits

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

llvm-svn: 228869
2015-02-11 19:45:07 +00:00
Timur Iskhodzhanov 8a8b00b684 [ASan] Print out a diagnostic when a global is unregistered
llvm-svn: 228838
2015-02-11 15:21:09 +00:00
Justin Bogner 43b2cae82a Revert "[UBSan] Enable -Wglobal-constructors."
We're still using global constructors when not on linux, so this was
causing warnings on Darwin. Reverting for now.

This reverts r228384.

llvm-svn: 228795
2015-02-11 03:05:02 +00:00
Alexey Samsonov fa8b3db54b [UBSan] Add report deduplication for -fsanitize=function.
Summary:
Make sure we don't print the error report from -fsanitize=function
twice for the same source location, as we do in another UBSan handlers.

Test Plan: check-ubsan test suite

Reviewers: rsmith, pcc

Reviewed By: pcc

Subscribers: llvm-commits

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

llvm-svn: 228772
2015-02-11 00:05:31 +00:00
Petar Jovanovic 08fc9e9158 [mips] Add __clear_cache() definition for non-Android systems
Make sure clear_cache() builtin has an appropriate definition for Linux.
Call syscall(NR_cacheflush, ...).

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

llvm-svn: 228767
2015-02-10 23:36:19 +00:00
Kuba Brecka 9a18c3016c Fix ASan's Noinst unit tests
We currently skip all "Noinst" unit tests on OS X, which was probably caused when we removed the "allow_reexec" flag. The MaybeReexec function fails to re-execute when the runtime is linked statically, because there is no dylib to use. This patch adds an explicit DisableReexec function that is used from asan_noinst_test.cc and the runtime then doesn't try to re-execute.

Reviewed at http://reviews.llvm.org/D7493

llvm-svn: 228740
2015-02-10 20:37:57 +00:00
Alexey Samsonov 1923595b4f [UBSan] Reduce the number of getCallerLocation() calls.
getCallerLocation() is expensive as it issues a call to symbolizer.
(In fact, this function has a memory leak at the moment, but this
will be fixed in the nearest future). We should only call it if
we're actually going to print an error report, in particular,
once for every reported source location.

__ubsan_handle_type_mismatch: call getCallerLocation() only if
provided source location is invalid, and only if the report is not
deduplicated.

__ubsan_handle_float_cast_overflow: call getSourceLocation with
correct CallerPC (the one in user code, not in UBSan handler). Source
location for this check is not currently emitted by frontend.

llvm-svn: 228732
2015-02-10 19:50:20 +00:00
Timur Iskhodzhanov 8ce4a069e4 [ASan/Win] NFC, just minor simplification of the code
llvm-svn: 228702
2015-02-10 16:29:05 +00:00
Timur Iskhodzhanov 54cc5b6fc8 [ASan/Win] Add the executable's directory to the symbol search path
This should fix symbolization in those cases when the .exe file is moved together with the .pdb

llvm-svn: 228701
2015-02-10 16:17:01 +00:00
Alexey Samsonov e977a8c747 [ASan] Add missing RUN: prefix.
llvm-svn: 228651
2015-02-10 01:55:02 +00:00
Alexey Samsonov 54a0e40442 [CMake] PowerPC: detect host endianness to build corresponding version of runtimes.
Prior to this change we built two identical runtimes, named "powerpc64"
and "powerpc64le", while their actual endianness matched the host
endianness.

llvm-svn: 228650
2015-02-10 01:42:44 +00:00
Timur Iskhodzhanov 758ac94ee2 [ASan/Win] Add a test case for PR22431
llvm-svn: 228573
2015-02-09 12:47:51 +00:00
Kuba Brecka bb39671516 [compiler-rt] Make MaybeReexec properly process DYLD_INSERT_LIBRARIES when using non-absolute paths
MaybeReexec() in asan_mac.cc checks for presence of the ASan dylib in DYLD_INSERT_LIBRARIES, and if it is there, it will process this env. var. and remove the dylib from its value, so that spawned children don't have this variable set. However, the current implementation only works when using a canonical absolute path to the dylib, it fails to remove the dylib for example when using @executable_path.

This patch changes the processing of DYLD_INSERT_LIBRARIES to comparing values only based on filenames (ignoring directories).

Reviewed at http://reviews.llvm.org/D7160

llvm-svn: 228392
2015-02-06 12:07:29 +00:00
Yury Gribov 55aae51325 [UBSan] Enable -Wglobal-constructors.
llvm-svn: 228384
2015-02-06 05:53:08 +00:00
Alexander Potapenko 1c4d621556 [ASan] Fix interface_symbols_darwin.c test
by manually adding __asan_mz_* to the generated interface functions list.

Declaring these functions in asan_interface_internal.h doesn't work quite well:
their prototypes must match the prototypes of zone functions in malloc/malloc.h,
but some of the types (e.g. malloc_zone_t and size_t) aren't available in
asan_interface_internal.h

llvm-svn: 228290
2015-02-05 13:07:50 +00:00
Juergen Ributzka 6e25858b5c Revert "[ASan] Add the new __asan_mz_* symbols to asan_interface_internal.h"
Reverting r228137 to unbreak the build bots.

llvm-svn: 228172
2015-02-04 19:14:35 +00:00
Alexander Potapenko 42fa73cef0 [ASan] Add the new __asan_mz_* symbols to asan_interface_internal.h
to fix the interface_symbols_darwin.c test.

llvm-svn: 228137
2015-02-04 12:42:12 +00:00
Viktor Kutuzov 2ea54bcb28 [Msan] Fix the pthread_attr_get unit test to build on FreeBSD
Differential Revision: http://reviews.llvm.org/D7342

llvm-svn: 228125
2015-02-04 09:08:00 +00:00
Kostya Serebryany 77cc729ad7 [sanitizer] add another workaround for PR 17409: when over a threshold emit coverage instrumentation as calls.
llvm-svn: 228102
2015-02-04 01:21:45 +00:00
Renato Golin b61cd95431 Revert "Enabling testing ASAN on AArch64"
This reverts commit r227966, which turned ASAN on on AArhc64 and may be the
cause of the bots never finishing the check-all. I'll re-apply once we're
sure that bot can cope with it.

llvm-svn: 228023
2015-02-03 20:23:00 +00:00