Commit Graph

5280 Commits

Author SHA1 Message Date
Evgeniy Stepanov 6c6e589c1f [sanitizer] Switch flag parsing to LowLevelAlloc.
InternalAlloc is quite complex and its behavior may depend on the values of
flags. As such, it should not be used while parsing flags.

Sadly, LowLevelAlloc does not support deallocation of memory.

llvm-svn: 226453
2015-01-19 11:47:13 +00:00
Evgeniy Stepanov 3231dd3c1c [sanitizer] Simplify code in flag parser.
llvm-svn: 226452
2015-01-19 10:54:36 +00:00
Viktor Kutuzov abfacbdf3a [Sanitizers] Order initialization of coverage and guard arrays
Differential Revision: http://reviews.llvm.org/D6892

llvm-svn: 226440
2015-01-19 09:41:52 +00:00
Evgeniy Stepanov 141c5a9ae0 [sanitizer] Move options-related tests to sanitizer_common.
And handle help=1 in standalone LSan.

llvm-svn: 226438
2015-01-19 09:21:44 +00:00
Evgeniy Stepanov e5b1c0d98e [msan] Use internal__exit() instead of _exit().
llvm-svn: 226437
2015-01-19 09:20:28 +00:00
Evgeniy Stepanov 0540f4141f [dfsan] Use append_no_rtti_flag instead of manually specifying -fno-rtti.
llvm-svn: 226435
2015-01-19 08:26:38 +00:00
David Blaikie 4da5edbebe Update for tests failing due to improvements in clang's column information for aggregate expressions
llvm-svn: 226393
2015-01-18 02:17:55 +00:00
Hal Finkel 0e39c55d22 [sanitizer] Adjust max read size in FlagHandlerInclude
Setting the maximum read size in FlagHandlerInclude to 2^15 might be a good
default, but causes the read to fail on systems with a page size larger than
that (ReadFileToBuffer(...) will fail if the maximum allowed size is less than
the value returned by GetPageSizeCached()). For example, on my PPC64/Linux
system, GetPageSizeCached() returns 2^16. In case the page size is larger, use
that instead.

llvm-svn: 226368
2015-01-17 03:31:43 +00:00
Justin Bogner 66fd5c914a InstrProf: Optionally print an error when emitting profile data fails
Debugging a missing profile is a bit painful right now. We can make
people's lives a bit easier by adding a knob to enable printing a
helpful error message for such failures.

llvm-svn: 226312
2015-01-16 20:10:56 +00:00
Evgeniy Stepanov 5450a9635a [sanitizer] Additional error checking.
llvm-svn: 226279
2015-01-16 15:25:16 +00:00
Viktor Kutuzov 05f6929932 [Sanitizers] Intercept clock_gettime() on FreeBSD
Committed unreviewed with permission.

llvm-svn: 226276
2015-01-16 14:54:39 +00:00
Viktor Kutuzov 068ece9679 [Sanitizers] Intercept lgamma_r() on FreeBSD
Committed unreviewed with permission.

llvm-svn: 226275
2015-01-16 14:52:17 +00:00
Evgeniy Stepanov 4286a9bd5a [asan] Change detection of allow_user_segv_handler on Android.
llvm-svn: 226273
2015-01-16 13:12:22 +00:00
Evgeniy Stepanov 4448007885 [asan] More verbose output from one of the tests.
Trying to debug a buildbot-only failure.

llvm-svn: 226270
2015-01-16 12:08:32 +00:00
Evgeniy Stepanov 82d3ef1617 [asan] Fix asan_options-include test.
Wrong include order.

llvm-svn: 226268
2015-01-16 10:30:53 +00:00
Evgeniy Stepanov 29235e374c [sanitizer] Fix bashism in check_lint.sh.
llvm-svn: 226267
2015-01-16 10:20:49 +00:00
Evgeniy Stepanov e0009356ba [sanitizer] Cleanup linter temporary files.
llvm-svn: 226266
2015-01-16 10:09:56 +00:00
Evgeniy Stepanov db20539d3a [sanitizer] Fix compiler warning in the flag parser code.
llvm-svn: 226263
2015-01-16 09:32:31 +00:00
Hal Finkel e67f32aa99 [asan] Loosen test for upcoming ppc64 change
This test casts 0x4 to a function pointer and calls it. Unfortunately, the
faulting address may not exactly be 0x4 on PPC64 ELFv1 systems. The LLVM PPC
backend used to always generate the loads "in order", so we'd fault at 0x4
anyway. However, at upcoming change to loosen that ordering, and we'll pick a
different order on some targets. As a result, as explained in the comment, we
need to allow for certain nearby addresses as well.

llvm-svn: 226202
2015-01-15 20:48:38 +00:00
Evgeniy Stepanov 8c9a0708a0 [sanitizer] Restore -fno-lto accidentally removed in r226169.
llvm-svn: 226177
2015-01-15 16:31:22 +00:00
Evgeniy Stepanov bc14dd46f2 [sanitizer] Implement include= option.
Allows loading sanitizer options from file.

llvm-svn: 226175
2015-01-15 16:26:59 +00:00
Evgeniy Stepanov f294d5b829 [sanitizer] Flag parser rewrite.
The new parser is a lot stricter about syntax, reports unrecognized
flags, and will make it easier to implemented some of the planned features.

llvm-svn: 226169
2015-01-15 15:13:43 +00:00
Evgeniy Stepanov 1a1a7d0f30 [lsan] Fix a typo in a test.
llvm-svn: 226168
2015-01-15 15:00:49 +00:00
Evgeniy Stepanov fa1d9f4860 Fix compilation of compiler_rt against libunwind.
libunwind defines _Unwind_GetLanguageSpecificData as returning long
instead of (uint8_t *).

llvm-svn: 226167
2015-01-15 14:27:38 +00:00
Saleem Abdulrasool a7452e434b builtins: avoid duplicating unwind declarations
Use unwind.h to get the declarations for unwinding interfaces.  This header is
already provided by clang and gcc, so this adds no additional dependencies for
building the builtins library.  It avoids the duplication which may drift over
time though.

llvm-svn: 225990
2015-01-14 15:55:17 +00:00
Viktor Kutuzov 0181812bf6 [Msan] Fix strlen() and strnlen() interceptors to work on FreeBSD
Differential Revision: http://reviews.llvm.org/D6928

llvm-svn: 225986
2015-01-14 14:59:46 +00:00
David Blaikie baaaa67819 Reapply debug info changes now that more precise column information is available.
llvm-svn: 225959
2015-01-14 07:59:48 +00:00
Rafael Espindola c7e4fb209e Another try at handling LD_LIBRARY_PATH not being defined.
llvm-svn: 225932
2015-01-14 02:23:27 +00:00
Rafael Espindola a9782ecfb0 Handle LD_LIBRARY_PATH not being defined.
Should fix the bots after r225890.

llvm-svn: 225919
2015-01-14 01:28:08 +00:00
Alexey Samsonov f3b61be2ee Update test cases for new -fsanitize-recover= semantics.
llvm-svn: 225725
2015-01-12 23:02:42 +00:00
Peter Collingbourne 75e259ed95 [dfsan] Export dfsan_get_label_info function with C linkage.
llvm-svn: 225692
2015-01-12 20:40:30 +00:00
Viktor Kutuzov b4b05017cf [Msan] Fix use of mmap(MAP_ANONYMOUS) in the unit tests on FreeBSD
Differential Revision: http://reviews.llvm.org/D6929

llvm-svn: 225688
2015-01-12 20:18:38 +00:00
Viktor Kutuzov 6aba5098fd [Msan] Fix tests reading /proc files on FreeBSD
Differential Revision: http://reviews.llvm.org/D6926

llvm-svn: 225686
2015-01-12 20:15:33 +00:00
Timur Iskhodzhanov 00ede84084 [ASan] Move the shadow on Windows 32-bit from 0x20000000 to 0x40000000
llvm-svn: 225641
2015-01-12 17:38:58 +00:00
Evgeniy Stepanov 3f2e761826 [asan] Fix uninit in coverage.
pc_fd was not initialized to (-1) on some code paths, resulting in the program
erroneously closing stdin when reinitializing coverage.

llvm-svn: 225637
2015-01-12 17:13:20 +00:00
Evgeniy Stepanov 5975243955 [asan] Pass activation options in the android test runner.
llvm-svn: 225636
2015-01-12 17:10:05 +00:00
Ehsan Akhgari d918614586 Fix two extra semicolon warnings
Reviewers: timurrrr

Subscribers: llvm-commits

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

llvm-svn: 225635
2015-01-12 17:03:02 +00:00
Jay Foad 335c08e56c [ASan] Handle SIGBUS on Linux.
Summary:
On Linux in some situations we can get SIGBUS instead of SIGSEGV on
stack overflow, so asan should handle SIGBUS as well as SIGSEGV.

https://code.google.com/p/address-sanitizer/issues/detail?id=369

Reviewers: samsonov, glider

Reviewed By: glider

Subscribers: glider, llvm-commits

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

llvm-svn: 225630
2015-01-12 13:46:37 +00:00
Roman Divacky 0c9c0c5a6d Add FreeBSD support for __clear_cache.
llvm-svn: 225610
2015-01-11 18:21:11 +00:00
David Blaikie 9098487213 Revert "Reapply debug info changes now that more precise column information is available."
While the clang patch is reverted pending investigation/fixes.

This reverts commit r225001.

llvm-svn: 225560
2015-01-09 23:27:12 +00:00
Alexey Samsonov 95674c8181 Remove AsanInterceptsSignal in favor of (equivalent) IsDeadlySignal.
llvm-svn: 225556
2015-01-09 23:03:31 +00:00
Kostya Serebryany 96fc9a2537 [sanitizer] use the right memory order
llvm-svn: 225546
2015-01-09 21:01:34 +00:00
Kuba Brecka 1a03ccd848 [asan] Adding a regression test for https://code.google.com/p/address-sanitizer/issues/detail?id=368
llvm-svn: 225484
2015-01-09 00:26:45 +00:00
Kostya Serebryany 8cc4002df2 [asan] make a test consume 2x less RAM (we observe flaky bot failures that seem like OOMs)
llvm-svn: 225478
2015-01-08 23:37:09 +00:00
Alexey Samsonov a04ca22edf Fix memory leaks in GetListOfModules() users.
llvm-svn: 225472
2015-01-08 22:31:14 +00:00
Alexey Samsonov b40fd1b24e [Sanitizer] Remove the hardcoded limit of address ranges in LoadedModule.
This should fix https://code.google.com/p/address-sanitizer/issues/detail?id=368.

llvm-svn: 225469
2015-01-08 22:03:05 +00:00
Viktor Kutuzov e01a595dad [Sanitizers] Fix internal_lseek() to work on FreeBSD
Differential Revision: http://reviews.llvm.org/D6825

llvm-svn: 225443
2015-01-08 13:28:22 +00:00
Renato Golin ea56f08b3f XFAIL AArch64 UBsan test, just like ARM
llvm-svn: 225370
2015-01-07 20:03:47 +00:00
Kostya Serebryany 7ad02fca09 [asan] add flag quarantine_size_mb, deprecate quarantine_size
llvm-svn: 225337
2015-01-07 02:37:52 +00:00
Alexey Samsonov 7eba6dfdaa [TSan] Fix Go build.
llvm-svn: 225336
2015-01-07 02:12:41 +00:00
Alexey Samsonov 03499e920b [Sanitizer] Change the runtime flag representation.
This mirrors r225239 to all the rest sanitizers:
ASan, DFSan, LSan, MSan, TSan, UBSan.

Now the runtime flag type, name, default value and
description is located in the single place in the
.inc file.

llvm-svn: 225327
2015-01-07 00:38:00 +00:00
Kostya Serebryany 7e85a9216e [asan] add a flag soft_rss_limit_mb
llvm-svn: 225323
2015-01-06 23:53:32 +00:00
Alexey Samsonov 6239ebc1c2 [Sanitizer] Improve unit tests in COMPILER_RT_DEBUG=ON mode.
Propagate -DSANITIZER_DEBUG definition to unit tests.
Make sure unit tests depend on compiler-rt headers.

llvm-svn: 225298
2015-01-06 20:58:40 +00:00
Alexey Samsonov ea04032144 Use -DSANITIZER_DEBUG=1 if COMPILER_RT_DEBUG=ON, now that PR22083 is fixed.
llvm-svn: 225293
2015-01-06 20:25:34 +00:00
Kostya Serebryany 4e781371d1 [ubsan] disable coverage-levels.cc on darwin until we can investigate what's wrong there.
llvm-svn: 225281
2015-01-06 18:48:49 +00:00
Jay Foad a566693334 [asan] Bump the self-imposed stack limit from 128k to 256k. PowerPC64
Linux has 64k pages, so the old limit was only two pages. With ASLR the
initial sp might be right at the start of the second page, so the stack
will immediately grow down into the first page; and if you use all pages
of a limited stack then asan hits a kernel bug to do with how stack
guard pages are reported in /proc/self/maps:
http://lkml.iu.edu//hypermail/linux/kernel/1501.0/01025.html

We should still fix the underlying problems, but in the mean time this
patch makes the test work with 64k pages as well as it does with 4k
pages.

llvm-svn: 225261
2015-01-06 10:01:15 +00:00
Alexey Samsonov bdbdd3fd4e [Sanitizer] Use COMMON_FLAG macro to describe common runtime flags.
Summary:
Introduce a single place where we specify flag type, name, default
value, and description. This removes a large amount of boilerplate
and ensures we won't leave flags uninitialized.

Test Plan: regression test suite

Reviewers: kcc

Subscribers: llvm-commits

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

llvm-svn: 225239
2015-01-06 02:44:05 +00:00
Kostya Serebryany fb42a5a292 [ubsan] partially enable -fsanitize-coverage=N with ubsan. It will work as usual in most cases but will not dump coverage on error with -fno-sanitize-recover (that'll be a separate fix)
llvm-svn: 225234
2015-01-06 01:31:23 +00:00
Kostya Serebryany e02839b60f [asan/tracing] write the trace using a sequence of internal_write calls instead of just one (otherwise files of > 2Gb are trunkated). Also a minor adjustment to the trace collection.
llvm-svn: 225230
2015-01-06 01:11:23 +00:00
Nick Kledzik 83a2d8ec73 Add 64-bit multiply functions to iOS arm64 compiler-rt dylib
llvm-svn: 225226
2015-01-06 00:27:21 +00:00
Saleem Abdulrasool 6e6c1c3ef2 tests: correct builtins test if built under -mthumb on ARM
The clear_cache and enable_execute_stack tests attempt to memcpy the definition
of a function into a buffer before executing the function.  The problem with
this approach is that on some targets (ARM with thumb mode compilation, MIPS
with MIPS16 codegen or uMIPS), you would use a pointer which is incorrect (it
would be off-by-one) due to the ISA selection being encoded into the address.
This ensures that the function address is retrieved correctly in all cases.

llvm-svn: 225215
2015-01-05 21:54:50 +00:00
Alexey Samsonov df3aeb8e71 Remove TSAN_DEBUG in favor of SANITIZER_DEBUG.
llvm-svn: 225111
2015-01-03 04:29:12 +00:00
Alexey Samsonov 3b1885448a Replace DCHECK with DCHECK_LE where appropriate.
llvm-svn: 225110
2015-01-03 04:29:05 +00:00
Kostya Serebryany 0f53d9a2ee [asan/tracing] extend the test a bit more, simplify the tracing code, add a guard page to trace array, fix the trace IDs before dumping
llvm-svn: 225108
2015-01-03 02:07:58 +00:00
Kostya Serebryany 86ced092f4 [asan] extend coverage-tracing.cc test
llvm-svn: 225107
2015-01-03 01:41:11 +00:00
Kostya Serebryany d421db05bb [asan] simplify the tracing code, make it use the same guard variables as coverage
llvm-svn: 225103
2015-01-03 00:54:43 +00:00
Alexey Samsonov c426c337ed Revert "Revert r224736: "[Sanitizer] Make CommonFlags immutable after initialization.""
Fix test failures by introducing CommonFlags::CopyFrom() to make sure
compiler doesn't insert memcpy() calls into runtime code.

Original commit message:
Protect CommonFlags singleton by adding const qualifier to
common_flags() accessor. The only ways to modify the flags are
SetCommonFlagsDefaults(), ParseCommonFlagsFromString() and
OverrideCommonFlags() functions, which are only supposed to be
called during initialization.

llvm-svn: 225088
2015-01-02 21:28:37 +00:00
Chandler Carruth 6173e869eb Revert r224736: "[Sanitizer] Make CommonFlags immutable after initialization."
We've got some internal users that either aren't compatible with this or
have found a bug with it. Either way, this is an isolated cleanup and so
I'm reverting it to un-block folks while we investigate. Alexey and
I will be working on fixing everything up so this can be re-committed
soon. Sorry for the noise and any inconvenience.

llvm-svn: 225079
2015-01-02 09:59:38 +00:00
Rafael Espindola 0dfd240068 Avoid building compiler-rt with LTO.
During a LTO we still need to build a compiler_rt with regular object files
in the .a.

llvm-svn: 225049
2014-12-31 18:20:52 +00:00
Kostya Serebryany 77c5c1a66d [asan] fix coverage between fork() and exec(): reinitialize the guards after fork()
llvm-svn: 225016
2014-12-30 23:16:12 +00:00
Kostya Serebryany a7ee2734cf [asan] add flag coverage_pcs. When false, the coverage is not dumped as PCs. Useful e.g. if the user only needs coverage is bitset
llvm-svn: 225002
2014-12-30 19:55:04 +00:00
David Blaikie 63ac92ca28 Reapply debug info changes now that more precise column information is available.
(recommitting as the Clang patch is back in with the latest fix -
hopefully it sticks)

llvm-svn: 225001
2014-12-30 19:54:25 +00:00
Kostya Serebryany aa185bfc4b [asan] change _sanitizer_cov_module_init to accept int* instead of int**
llvm-svn: 224999
2014-12-30 19:29:28 +00:00
Timur Iskhodzhanov a023e06618 Follow-up to r224987: fix a lint warning
llvm-svn: 224988
2014-12-30 15:30:19 +00:00
Timur Iskhodzhanov 64fc8e4a5a [ASan/Win] Sort the list of modules when we fail to reserve the shadow memory range
llvm-svn: 224987
2014-12-30 14:44:12 +00:00
Alexey Samsonov 93c064968d Revert "UBSan: Teach isDerivedFromAtOffset and findBaseAtOffset about vbases"
This reverts commit r221445. This change leads to false positives
reports from -fsanitize=vptr. See original commit thread for more
details.

llvm-svn: 224972
2014-12-30 00:33:50 +00:00
David Blaikie b7373cd639 Revert "Reapply debug info changes now that r224385 has been recommitted to clang (in r224941)"
Asserting when building compiler-rt when using a gcc host compiler.
Reverting while I investigate.

This reverts commit r224942.

llvm-svn: 224969
2014-12-29 23:48:46 +00:00
Alexey Samsonov e585e738d4 Remove darwin_fat.mk.
Summary:
Its seems to be replaced by clang_darwin.mk in the Makefile-based
build, and is only referenced in unittest scripts, which are
broken for a long time now.

Test Plan: n/a

Reviewers: bob.wilson

Subscribers: llvm-commits

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

llvm-svn: 224946
2014-12-29 19:21:59 +00:00
David Blaikie 90b6344c56 Reapply debug info changes now that r224385 has been recommitted to clang (in r224941)
llvm-svn: 224942
2014-12-29 18:19:36 +00:00
Chandler Carruth 11fb7a49ae [cmake/multilib] Support multilib libdir suffixes by applying the
LLVM_LIBDIR_SUFFIX variable to one place in the cmake file.

This is all that I had to do to get everything from compiler-rt working
for me, but there may be more work required if folks are relying on more
parts of compiler-rt. Notably, I'm mostly using it for the sanitizers.

llvm-svn: 224928
2014-12-29 12:26:30 +00:00
Kuba Brecka c52f300698 [sanitizer-common] Fixing the ASan test build failure on OS X
The change in r224819 started using internal_unlink in a sanitizer_common unit test. For some reason, internal_unlink is not defined in sanitizer_mac.cc, fixing that.

llvm-svn: 224910
2014-12-29 02:18:59 +00:00
Daniel Jasper 1e8eafd6c8 Escape ? to silence GCC warning about trigraphs.
llvm-svn: 224863
2014-12-26 18:21:34 +00:00
Evgeniy Stepanov 9e609426a7 [sanitizer] Treat \r, \n, \t as flag separators.
llvm-svn: 224858
2014-12-26 16:09:15 +00:00
Evgeniy Stepanov ef0f244594 [asan] Fix possibly uninitialized coverage flag.
llvm-svn: 224857
2014-12-26 16:07:33 +00:00
Timur Iskhodzhanov a04b33b9de [ASan/Win] Add basic support for MemoryRangeIsAvailable and DumpProcessMap to make it easier to debug startup shadow mapping failures
llvm-svn: 224856
2014-12-26 14:28:32 +00:00
Evgeniy Stepanov 103084691d [asan] Bump coverage size limit on 32-bit platforms.
This increases the limit from 4M locations to 16M, reserving
64Mb virtual memory. Chrome has >5M unique coverage locations with coverage=3.

llvm-svn: 224855
2014-12-26 13:54:11 +00:00
Evgeniy Stepanov da02effd9e [asan] Extend coverage test.
llvm-svn: 224854
2014-12-26 12:51:31 +00:00
Evgeniy Stepanov 05dc4be0dc [asan] Allow enabling coverage at activation.
This is a re-commit of r224838 + r224839, previously reverted in r224850.
Test failures were likely (still can not reproduce) caused by two lit tests
using the same name for an intermediate build target.

llvm-svn: 224853
2014-12-26 12:32:32 +00:00
Timur Iskhodzhanov b8373bc119 [ASan/Win] Suppress error messaging when Abort() is called
This will prevent ASan bots from hanging / timing out

llvm-svn: 224852
2014-12-26 12:25:54 +00:00
Evgeniy Stepanov f8c7e25560 Revert r224838, r224839.
Flaky failures on the build bots.

llvm-svn: 224850
2014-12-26 10:19:56 +00:00
Evgeniy Stepanov b723834d82 [sanitizer] Tweak sancov.py output.
llvm-svn: 224841
2014-12-25 16:03:24 +00:00
Evgeniy Stepanov 01b922d9f2 [sanitizer] sancov.py: print status to stderr
llvm-svn: 224840
2014-12-25 16:01:09 +00:00
Evgeniy Stepanov 300d29a75d [asan] Disable __sanitizer_cov_dump registration on Windows.
Looks like we can't use atexit() during ASan initialization on Windows.

llvm-svn: 224839
2014-12-25 15:11:00 +00:00
Evgeniy Stepanov be9a53fec6 [asan] Allow enabling coverage at activation.
llvm-svn: 224838
2014-12-25 14:26:45 +00:00
Timur Iskhodzhanov fe5c5b98b3 Simplify allocator_returns_null.cc test
llvm-svn: 224837
2014-12-25 13:03:58 +00:00
Dmitry Vyukov bda655004e tsan: fix trace initialization during thread id reuse
The current code leaves the first event in the trace part uninitialized
(from the previous thread). It can cause unpredictable behavior
during stack/mutexset restoration.
Initialize the first event to a fake harmless memory access.

llvm-svn: 224834
2014-12-25 10:32:25 +00:00
Evgeniy Stepanov cb2f6d4314 [asan] Support ASAN_ACTIVATION_OPTIONS.
This is mostly useful for testing, as the only other way of specifying
activation options (Android system property) is system-wide and affects
concurrently running tests.

llvm-svn: 224824
2014-12-24 16:58:50 +00:00
Timur Iskhodzhanov ced288f822 [ASan/Win] Bandaid fix for PR22025 -- deadlocks when creating suspended threads
llvm-svn: 224823
2014-12-24 16:14:16 +00:00
Evgeniy Stepanov 5a09b2cdeb [sanitizer] Disable InternalMmapWithOffset test on OSX.
llvm-svn: 224822
2014-12-24 13:59:35 +00:00
Evgeniy Stepanov ca9e045570 [sanitizer] Fix off-by-8x in direct coverage.
File mapping offset was calculated by offsetting (uptr *) instead of (char *).

llvm-svn: 224821
2014-12-24 13:57:11 +00:00
Evgeniy Stepanov 40b16f4037 [sanitizer] Disable InternalMmapWithOffset test on Windows.
llvm-svn: 224820
2014-12-24 13:05:21 +00:00
Evgeniy Stepanov 98211121ab [sanitizer] mmap2 syscall works with 4096-byte units instead of bytes.
Ouch.

llvm-svn: 224819
2014-12-24 12:58:09 +00:00
Evgeniy Stepanov 0b7c1cf1e0 [asan] Disable one test on Android.
It used to pass by chance and started failing on recent Android builds.

llvm-svn: 224818
2014-12-24 12:23:15 +00:00
Jay Foad 4195dff0fb [ASan] Fix asan_preload_test-2 on PowerPC64 Linux
Summary:
This test failed because clang compiled the call to memset() into a
single sth instruction, instead of a call. Fix it by using write() instead
of memset().

Reviewers: kcc, samsonov, garious, eugenis

Reviewed By: eugenis

Subscribers: llvm-commits

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

llvm-svn: 224812
2014-12-24 11:48:40 +00:00
Kostya Serebryany 9fdeb37bd3 [asan] change the coverage collection scheme so that we can easily emit coverage for the entire process as a single bit set, and if coverage_bitset=1 actually emit that bitset
llvm-svn: 224789
2014-12-23 22:32:17 +00:00
Evgeniy Stepanov b2dacb0c76 [asan] Fix line >80 chars.
llvm-svn: 224763
2014-12-23 10:18:47 +00:00
Evgeniy Stepanov 874b2bb228 [asan] Better error message in coverage.
llvm-svn: 224762
2014-12-23 10:12:51 +00:00
Dmitry Vyukov 10070626b7 tsan: fix style
Usually we roll the variable declaration into the condition in cases like this.

llvm-svn: 224755
2014-12-23 07:21:23 +00:00
Kuba Brecka 5238deb2ff Change the CMake build to generate full debugging info when COMPILER_RT_DEBUG=ON
The compiler-rt CMake build currently uses -gline-tables-only for all builds. While this makes the debugger correctly map source files, debugging of the runtime libraries in general is pretty tough, because you don't see any local variables, parameters, etc. Let's allow emitting full debugging info by setting COMPILER_RT_DEBUG=ON.

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

llvm-svn: 224749
2014-12-23 01:52:53 +00:00
Alexey Samsonov b430f6e17a [Sanitizer] Make CommonFlags immutable after initialization.
Summary:
Protect CommonFlags singleton by adding const qualifier to
common_flags() accessor. The only ways to modify the flags are
SetCommonFlagsDefaults(), ParseCommonFlagsFromString() and
OverrideCommonFlags() functions, which are only supposed to be
called during initialization.

Test Plan: regression test suite

Reviewers: kcc, eugenis, glider

Subscribers: llvm-commits

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

llvm-svn: 224736
2014-12-22 21:46:10 +00:00
Viktor Kutuzov 54c7590073 [Msan] Fix msan_test.cc inclusions to build the unit tests on FreeBSD
Differential Revision: http://reviews.llvm.org/D6757

llvm-svn: 224724
2014-12-22 19:14:23 +00:00
Kuba Brecka 742c471142 AddressSanitizer: Abort after failed exec() and get rid of the allow_reexec ASan flag
As mentioned in
https://code.google.com/p/address-sanitizer/issues/detail?id=365, when the
re-exec that adds the required DYLD_INSERT_LIBRARIES variable fails, ASan
currently continues to run, but things are broken (some memory can be
overwritten, interceptors don't work, ...). This patch aborts if the execv()
fails and prints an error message that DYLD_INSERT_LIBRARIES is required. It
also removes the "alllow_reexec" flag, since using it causes the same issues.

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

llvm-svn: 224712
2014-12-22 17:32:27 +00:00
Kuba Brecka 090d33e393 AddressSanitizer: Properly handle dispatch_source_set_cancel_handler with a
NULL handler

Per
https://developer.apple.com/library/mac/documentation/Performance/Reference/GCD_libdispatch_Ref/index.html,
the dispatch_source_set_cancel_handler() API *can* be called with a NULL
handler. In that case, the libdispatch removes an already existing cancellation
handler, if there was one. ASan's interceptor always creates a new block that
always tries to call the original handler. In case the original block is NULL,
a segmentation fault happens. Let's fix that by not wrapping a NULL-block at
all.

It looks like all the other libdispatch APIs (which we intercept) do *not*
allow NULL. So it's really only the dispatch_source_set_cancel_handler one that
needs this fix.

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

llvm-svn: 224711
2014-12-22 17:30:04 +00:00
Alexander Potapenko 7f9be7120d [ASan] Fix the logic that decides whether we need to spawn a new llvm-symbolizer in asan_symbolize.py
llvm-svn: 224710
2014-12-22 16:00:00 +00:00
Viktor Kutuzov 90f8673f05 [Sanitizers] Intercept wcsnrtombs() on FreeBSD
Differential Revision: http://reviews.llvm.org/D6755

llvm-svn: 224709
2014-12-22 14:45:30 +00:00
Viktor Kutuzov 2a5b81dd7f [Msan] Fix uname() interception on FreeBSD
Differential Revision: http://reviews.llvm.org/D6738

llvm-svn: 224708
2014-12-22 14:42:24 +00:00
Dmitry Vyukov c1a04162ba tsan: reset stack0 in the first partition of thread trace
stack0/mset0 contained bogus values from the previous thread
that used the same id

llvm-svn: 224702
2014-12-22 12:32:52 +00:00
Dmitry Vyukov 8f9911b571 tsan: fix debugging output
llvm-svn: 224701
2014-12-22 12:31:32 +00:00
Viktor Kutuzov d4c3ffc5bf [Sanitizers] Intercept snprintf_l() on FreeBSD
Differential Revision: http://reviews.llvm.org/D6418

llvm-svn: 224700
2014-12-22 12:29:40 +00:00
Viktor Kutuzov 35fb0b5d52 [Sanitizers] Intercept wordexp on FreeBSD
Differential Revision: http://reviews.llvm.org/D6737

llvm-svn: 224699
2014-12-22 12:21:35 +00:00
Dmitry Vyukov 732b128129 tsan: add acquire/release functions to java interface
they are required to handle synchronization on volatile/final fields

llvm-svn: 224697
2014-12-22 09:44:56 +00:00
Kuba Brecka 2ce8c25f4b log-path_test testcase - make the invalid path more invalid
The ASan test/asan/TestCases/log-path_test.cc testcase uses /INVALID as an invalid path and expects that the program will not be allowed to create or write to that file. This actually is a valid writable path on one of my setups. Let's make the path more invalid.

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

llvm-svn: 224694
2014-12-22 00:02:28 +00:00
Kostya Serebryany baae9d2df1 [sanitizer] fix a performance regression in sanitizer coverage: move a small perf-critical function to a header. ALso set the coverage guard to 1 before the early return from CoverageData::Add
llvm-svn: 224660
2014-12-20 01:45:28 +00:00
Kostya Serebryany f053fc9b5c [sanitizer] initialize two flas in SetCommonFlagsDefaults
llvm-svn: 224645
2014-12-19 23:09:59 +00:00
Alexey Samsonov 2f8c8d59b2 [Sanitizer] Refactor CommonFlags interface. NFC.
Add CommonFlags::SetDefaults() and CommonFlags::ParseFromString(),
so that this object can be easily tested. Enforce
that ParseCommonFlagsFromString() and SetCommonFlagsDefaults()
work only with singleton CommonFlags, shared across all sanitizer
runtimes.

llvm-svn: 224617
2014-12-19 21:40:04 +00:00
Alexey Samsonov 04eeec32e6 [ASan] Change activation strategy.
Now ASan deactivation doesn't modify common or ASan-specific runtime
flags. Flags stay constant after initialization, and "deactivation"
instead stashes initialized runtime state, and deactivates the
runtime. Activation then just restores the original state (possibly,
overriden by some activation flags provided in system property on
Android).

llvm-svn: 224614
2014-12-19 20:35:53 +00:00
Alexey Samsonov 30f330b39b [Sanitizer] Make Quarantine::Init slightly safer.
ASan Quarantine can be reinitialized at activation/deactivation.
Make max_size_/min_size_ atomic.

llvm-svn: 224613
2014-12-19 20:35:50 +00:00
Alexey Samsonov d6b24fa1e2 [ASan] Introduce AllocatorOptions to configure allocator behavior.
Summary:
Reduce the dependency of allocator code on runtime flags. Instead,
pass a bunch of options that configure allocator behavior at
initialization or re-initialization. That would allow us to
cleaner modify allocator behavior during a program execution
when ASan is activated or de-activated.

Test Plan: regression test suite

Reviewers: kcc

Subscribers: llvm-commits, eugenis

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

llvm-svn: 224605
2014-12-19 19:35:11 +00:00
Alexey Samsonov 1b64854574 [ASan] Restrict the set of flags overriden at activation.
Summary:
Change the way ASan flag parsing is performed at activation: instead
of overwriting all ASan and common flags from the activation string,
ASan will now only override a handful of whitelisted flags.
This is a first step towards making runtime flags immutable after
initialization. I plan to re-factor the activation stragegy to
the following one:

  - Parse commandline flags. Override the defaults from compile
    definition, env var, etc. Flags are immutable at this point.
  - Initiailize the runtime from commandline flags.
  - If ASan needs to be started deactivated, stash the runtime
    state in "asan_deactivated_flags" and deactivate the runtime.
  - When ASan is activated, override "asan_deactivated_flags" with
    activation flags, and use it to re-activate the runtime.

Test Plan: regression test suite

Reviewers: eugenis, kcc

Subscribers: llvm-commits

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

llvm-svn: 224601
2014-12-19 19:16:07 +00:00
Alexey Samsonov 583e9d29ad [ASan] Move flag validation from ParseFlagsFromString() to InitializeFlags().
llvm-svn: 224600
2014-12-19 19:16:02 +00:00
Saleem Abdulrasool 5bbc718539 builtins: rely on the compiler for user label prefix
clang does not like the definition of builtins.  In order to work around this,
we use a SUN CC to redefine the generated name.  However, this requires that we
account for the user label prefix.  Rather than hard coding that into the file,
rely on the compiler to tell us the information and use the preprocessor to
generate the name as we do in the assembly routines.  NFC.

llvm-svn: 224597
2014-12-19 18:54:13 +00:00
Sergey Matveev 5010b262aa [lsan] Add debug output to leak_check_before_thread_started.cc.
Trying to investigate why this test is flaky.

llvm-svn: 224580
2014-12-19 15:33:13 +00:00
Sergey Matveev 8cd909e749 [sanitizer] Rename InitIfLinkerInitialized to InitLinkerInitialized.
llvm-svn: 224577
2014-12-19 14:45:19 +00:00
Dmitry Vyukov 7fe690ce12 tsan: intercept closedir
llvm-svn: 224575
2014-12-19 14:29:40 +00:00
Evgeniy Stepanov b01eee941d [asan] Test BB- and edge- level coverage on Android.
llvm-svn: 224572
2014-12-19 12:21:40 +00:00
Evgeniy Stepanov aa7daaef7e [asan] Add tests for direct (mmap-ed) mode for BB- and edge-level coverage.
llvm-svn: 224571
2014-12-19 11:49:46 +00:00
Evgeniy Stepanov fd454ec3d9 [asan] Resurrect sanitize-coverage test on Android.
The test got silently disabled because of a typo in the lit config.
Also, compiler flags have changed (asan-coverage -> fsanitize-coverage).

llvm-svn: 224569
2014-12-19 10:40:14 +00:00
Dmitry Vyukov 76d629744b tsan: add an additional test for signal handlers
the test passes now, but signal handling during thread creation
and shutdown is tricky

llvm-svn: 224532
2014-12-18 18:40:52 +00:00
Dmitry Vyukov f6fab7adcf tsan: disable __tls_get_addr interceptor
see the added comments for details, it's messy

llvm-svn: 224531
2014-12-18 18:39:55 +00:00
Dmitry Vyukov f7790012a5 tsan: fix data races between signal handler and sigaction
signal handler reads sa_sigaction when a concurrent sigaction call can modify it
as the result in could try to call SIG_DFL or a partially overwritten function pointer

llvm-svn: 224530
2014-12-18 18:31:47 +00:00
Filipe Cabecinhas 9fd326d4d6 Fix suppressions file usage
Summary:
Always quote suppressions files given to *_OPTIONS.
This will make it not break when given full Windows paths (otherwise,
parsing would stop after the drive's letter + ':').

Also fix one or two cases where the suppression files' extensions were
not *.supp.

Reviewers: samsonov, kcc

Subscribers: llvm-commits

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

llvm-svn: 224529
2014-12-18 18:25:18 +00:00
Jay Foad d348d7c757 [Sanitizer] Fix GetRSS on Linux with non-4k pages
Summary:
The numbers in /proc/self/statm are in pages, not in fixed 4k units.
This fixes Linux/hard_rss_limit_mb_test.cc on my PowerPC64 box which
has 64k pages.

Reviewers: kcc, willschm

Reviewed By: willschm

Subscribers: llvm-commits

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

llvm-svn: 224522
2014-12-18 16:24:01 +00:00
Dmitry Vyukov 84fa6b37f4 tsan: fix deadlock reporting
currently deadlock detector reports effectively random stacks in report after flush
because it looks at old edges with wrong stacks

llvm-svn: 224519
2014-12-18 14:05:34 +00:00
Dmitry Vyukov a8def72dd6 tsan: fix failing CHECK In deadlock detector
and re-enable the test

llvm-svn: 224518
2014-12-18 14:02:28 +00:00
Dmitry Vyukov 794771b08b tsan: disable the test even harder
currently it fails in cmake build with weird errors:

/tmp/real_deadlock_detector_stress_test-68a5ae.o: In function `__clang_call_terminate':
/ssd/src/llvm/projects/compiler-rt/test/tsan/real_deadlock_detector_stress_test.cc:(.text.__clang_call_terminate[__clang_call_terminate]+0x12): undefined reference to `__cxa_begin_catch'
/ssd/src/llvm/projects/compiler-rt/test/tsan/real_deadlock_detector_stress_test.cc:(.text.__clang_call_terminate[__clang_call_terminate]+0x17): undefined reference to `std::terminate()'
/tmp/real_deadlock_detector_stress_test-68a5ae.o: In function `std::vector<int, std::allocator<int> >::_M_check_len(unsigned long, char const*) const':
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_vector.h:1339: undefined reference to `std::__throw_length_error(char const*)'
/tmp/real_deadlock_detector_stress_test-68a5ae.o: In function `__gnu_cxx::new_allocator<int>::allocate(unsigned long, void const*)':
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ext/new_allocator.h:102: undefined reference to `std::__throw_bad_alloc()'
/tmp/real_deadlock_detector_stress_test-68a5ae.o:(.eh_frame+0x63): undefined reference to `__gxx_personality_v0'
clang-3.5: error: linker command failed with exit code 1 (use -v to see invocation)

llvm-svn: 224511
2014-12-18 10:55:41 +00:00
Dmitry Vyukov 8c7baa4abc tsan: add a stress test for deadlock detector
currently disabled because fails

llvm-svn: 224509
2014-12-18 10:32:48 +00:00
Dmitry Vyukov e1881269f8 tsan: don't crash with NULL deref during reporting
tctx==NULL crash observed during deadlock reporting.
There seems to be some bugs in the deadlock detector,
but it is still useful to be more robust during reporting.

llvm-svn: 224508
2014-12-18 10:19:32 +00:00
Dmitry Vyukov a4cd69217b tsan: disable flaky debug check
see the comment for details

llvm-svn: 224507
2014-12-18 10:17:01 +00:00
Petar Jovanovic 7a6f5e47cf Do not define CRT_HAS_128BIT for MIPS64
Do not define it for MIPS64 until its backend supports it.
See the bug report [1] for more information.

[1] http://llvm.org/bugs/show_bug.cgi?id=20098

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

llvm-svn: 224488
2014-12-18 01:21:33 +00:00
Alexey Samsonov ae23ffb751 [ASan] Mark test for -fsized-delete as XFAIL for dynamic runtime.
-fsized-delete is implemented via weak symbols, and doesn't work
properly when malloc/free replacements are provided in shared
ASan runtime.

llvm-svn: 224474
2014-12-17 23:46:53 +00:00
Alexey Samsonov 658e2d274d [ASan] Add -ldl to linker invocation to lit tests that require it.
This fixes these tests under dynamic ASan runtime.

llvm-svn: 224473
2014-12-17 23:46:49 +00:00
Renato Golin 518a7b2585 Fix obvious cut&paste error on AArch64 Compiler-RT settings
llvm-svn: 224472
2014-12-17 23:43:39 +00:00
Alexey Samsonov 969902b43b [ASan] Always build shared ASan runtime on Linux.
This commit changes the strategy for building shared ASan runtime
and the way we test it:
  - COMPILER_RT_BUILD_SHARED_ASAN CMake option is removed. We now
    always build shared ASan runtime (it is the default on Android,
    Windows and Mac, and not the default on Linux and FreeBSD).
  - Platforms, which use static runtime by default now have
    "check-asan-dynamic" testsuite. This testsuite contains instrumented
    unit tests, and ASan lit tests, and runs them with shared ASan
    runtime. This testsuite is *not* a part of "check-asan" and
    *not* a part of "check-all", as adding 1000 more test cases, which
    duplicate existing ones is costly. However, you're welcome to
    add this command to your buildbot.

llvm-svn: 224470
2014-12-17 23:14:01 +00:00
Kostya Serebryany 20f3a52249 [sanitizer] add CombinedAllocator::InitIfLinkerInitialized and use it in lsan: speeds up lsan start-up time by ~25%
llvm-svn: 224469
2014-12-17 23:06:36 +00:00
Kostya Serebryany 4de56ef736 [sanitizer] allow -fsanitize-coverage=N w/ -fsanitize=leak, compiler-rt part
llvm-svn: 224464
2014-12-17 21:51:07 +00:00
Alexey Samsonov 9aca5e07ec [ASan] Move flag parsing logic to asan_flags.cc. NFC.
llvm-svn: 224450
2014-12-17 19:31:39 +00:00
David Blaikie c2e03a9c0d Revert "Fix test cases given Clang's improved location information."
The Clang improevments were reverted due to failures created in an asan
bootstrap.

This reverts commit r224387.

llvm-svn: 224446
2014-12-17 19:11:27 +00:00
Evgeniy Stepanov 372deb091e [msan] Stop calling pthread_getspecific in signal handlers.
pthread_getspecific is not async-signal-safe.

MsanThread pointer is now stored in a TLS variable, and the TSD slot
is used only for its destructor, and never from a signal handler.

This should fix intermittent CHECK failures in MsanTSDSet.

llvm-svn: 224423
2014-12-17 10:30:06 +00:00
Dmitry Vyukov 508dd9b94c tsan: add disabled test case for issue 87
llvm-svn: 224422
2014-12-17 10:19:20 +00:00
Alexey Samsonov b2dcac0bb7 [ASan] Re-structure the allocator code. NFC.
Introduce "Allocator" object, which contains all the bits and pieces
ASan allocation machinery actually use: allocator from sanitizer_common,
quarantine, fallback allocator and quarantine caches, fallback mutex.

This step is a preparation to adding more state to this object. We want
to reduce dependency of Allocator on commandline flags and be able to
"safely" modify its behavior (such as the size of the redzone) at
runtime.

llvm-svn: 224406
2014-12-17 01:55:03 +00:00
Alexey Samsonov 2c31cc3cf1 Rename asan_allocator2.cc to asan_allocator.cc
llvm-svn: 224396
2014-12-17 00:26:50 +00:00
Alexey Samsonov 91bb25f515 [ASan] Introduce SetCanPoisonMemory() function.
SetCanPoisonMemory()/CanPoisonMemory() functions are now used
instead of "poison_heap" flag to determine if ASan is allowed
to poison the shadow memory. This allows to hot-patch this
value in runtime (e.g. during ASan activation) without introducing
a data race.

llvm-svn: 224395
2014-12-17 00:01:02 +00:00
David Blaikie 5413abf88f Fix test cases given Clang's improved location information.
llvm-svn: 224387
2014-12-16 23:07:55 +00:00
Kostya Serebryany 5f5bc4abd3 [asan] trying to fix Mac build
llvm-svn: 224370
2014-12-16 21:06:07 +00:00
Hans Wennborg 7dd94570b0 Fix Win build after r224353: void function returning zero.
llvm-svn: 224366
2014-12-16 20:46:05 +00:00
Renato Golin 398e9ccf8b Fixes wrong -march=aarch64 option in compiler-rt
llvm-svn: 224362
2014-12-16 20:31:37 +00:00
Kostya Serebryany 43eb7735f2 [asan] new flag: hard_rss_limit_mb
llvm-svn: 224353
2014-12-16 19:13:01 +00:00
Mohit K. Bhakkad a94a037528 internal_stat for mips64
llvm-svn: 224326
2014-12-16 07:11:08 +00:00
Kuba Brecka 731089bbce Add an MACOS_VERSION_UNKNOWN_NEWER enum value for OS X versions above 10.10.
We recently had a broken version check because an newer OS X version is treated as MACOS_VERSION_UNKNOWN which is less than all the defined values. Let's have a separate enum value for unknown but newer versions, so the ">=" and "<=" version checks still work even in upcoming OS X releases.

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

llvm-svn: 224315
2014-12-16 04:46:15 +00:00
Alexey Samsonov 1c65001e5e Fix data symbolization with libbacktrace. Patch by Jakub Jelinek!
llvm-svn: 224308
2014-12-16 01:52:55 +00:00
Alexey Samsonov bba821b5b1 [ASan] Allow to atomically modify malloc_context_size at runtime.
Summary:
Introduce __asan::malloc_context_size atomic that is used to determine
required malloc/free stack trace size. It is initialized with
common_flags()->malloc_context_size flag, but can later be overwritten
at runtime (e.g. when ASan is activated / deactivated).

Test Plan: regression test suite

Reviewers: kcc, eugenis

Subscribers: llvm-commits

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

llvm-svn: 224305
2014-12-16 01:23:03 +00:00
Kostya Serebryany 42102b110e [asan] introduce __sanitizer_set_death_callback, deprecate __asan_set_death_callback
llvm-svn: 224286
2014-12-15 23:02:57 +00:00
Duncan P. N. Exon Smith 4a7fddca0d Update lib/profile tests for metadata assembly change
Running the upgrade script from PR21532.  Hopefully this will unstick
compiler-rt bots [1] after r224257.

[1]: http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA_check/181/

llvm-svn: 224276
2014-12-15 21:34:19 +00:00
Justin Bogner 42be29f748 profile: Add the relevant parts of lib/profile to cc_kext on darwin
Patch by Lawrence D'Anna. Thanks!

llvm-svn: 224270
2014-12-15 20:44:05 +00:00
Kumar Sukhani 3176f9b65d [ubsan][arm] supporting misaligned testcase
After previous commit: http://reviews.llvm.org/rL224242, misaligned testcase is now supported on ARM also

llvm-svn: 224243
2014-12-15 12:16:36 +00:00
Kumar Sukhani fef606cf0a [UBSan][MIPS] Adding support of MIPS64 in UBSan testing
On mips64 addresses are 40-bit. Where as a 48 bit address is used in TypeCheck/misaligned.cpp.
Using regular expression for that address.

reviewed by : samsonov
submitted by: sagar

llvm-svn: 224242
2014-12-15 10:52:06 +00:00
Kumar Sukhani 79c79e3e8a [UBSan][MIPS] Adding support for MIPS64
No MIPS64 architecture dependant code

reviewed by : samsonov
submitted by: sagar

llvm-svn: 224239
2014-12-15 09:20:06 +00:00
David Blaikie c4fbfee4ff Update test case with more accurate column information now that Clang produces same
llvm-svn: 224222
2014-12-14 18:49:31 +00:00
Justin Bogner efa6197ab7 Use the newer python syntax for exceptions
We've dropped support for python 2.5, so now we can use the forward
compatible "except ... as" syntax.

llvm-svn: 224181
2014-12-13 02:46:56 +00:00
Alexey Samsonov 6334f46db8 [Sanitizer] Introduce Allocator::may_return_null bool flag.
Summary:
Turn "allocator_may_return_null" common flag into an
Allocator::may_return_null bool flag. We want to make sure
that common flags are immutable after initialization. There
are cases when we want to change this flag in the allocator
at runtime: e.g. in unit tests and during ASan activation
on Android.

Test Plan: regression test suite, real-life applications

Reviewers: kcc, eugenis

Subscribers: llvm-commits

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

llvm-svn: 224148
2014-12-12 20:07:35 +00:00
Viktor Kutuzov 7163d00359 [Asan] XFAIL the interception_failure_test.cc test on FreeBSD
Differential Revision: http://reviews.llvm.org/D6591

llvm-svn: 224117
2014-12-12 12:13:40 +00:00
Viktor Kutuzov df4dab69e2 [Asan] Fix the tsd_dtor_leak.cc test to pass on FreeBSD
Differential Revision: http://reviews.llvm.org/D6590

llvm-svn: 224116
2014-12-12 12:09:56 +00:00
Kumar Sukhani adb3864744 [mips] [test] Enable COMPILER_RT_INCLUDE_TESTS for MIPS
Enabling COMPILER_RT_INCLUDE_TESTS and updating tests/sanitizer_allocator_test.cc to remove Allocator64 related tests for MIPS.

Reviewed By: samsonov

llvm-svn: 224101
2014-12-12 07:08:12 +00:00
Alexey Samsonov c60042ef8b [ASan] Group all flag parsing code together. NFC.
llvm-svn: 224087
2014-12-12 01:08:24 +00:00
Alexey Samsonov 0545f4b0f3 [ASan] Change fake stack and local variables handling.
This commit changes the way we get fake stack from ASan runtime
(to find use-after-return errors) and the way we represent local
variables:
  - __asan_stack_malloc function now returns pointer to newly allocated
    fake stack frame, or NULL if frame cannot be allocated. It doesn't
    take pointer to real stack as an input argument, it is calculated
    inside the runtime.
  - __asan_stack_free function doesn't take pointer to real stack as
    an input argument. Now this function is never called if fake stack
    frame wasn't allocated.
  - __asan_init version is bumped to reflect changes in the ABI.
  - new flag "-asan-stack-dynamic-alloca" allows to store all the
    function local variables in a dynamic alloca, instead of the static
    one. It reduces the stack space usage in use-after-return mode
    (dynamic alloca will not be called if the local variables are stored
    in a fake stack), and improves the debug info quality for local
    variables (they will not be described relatively to %rbp/%rsp, which
    are assumed to be clobbered by function calls). This flag is turned
    off by default for now, but I plan to turn it on after more
    testing.

llvm-svn: 224063
2014-12-11 21:53:19 +00:00
Alexey Samsonov 2c3045f1b9 [Sanitizer] Don't modify mmap_limit_mb flag in runtime.
Instead, rely on the fact that RAW_CHECK doesn't call mmap(),
and we'll be able to print an error message and kill a program.

llvm-svn: 224034
2014-12-11 18:45:24 +00:00
Alexey Samsonov 3a41ed1574 [Sanitizer] Fix report_path functionality:
Summary:
  - Make sure mmap() is never called inside RawWrite function.
  - Wrap a bunch of standalone globals in a ReportFile object.
  - Make sure accesses to these globals are thread-safe.
  - Fix report_path functionality on Windows, where
    __sanitizer_set_report_path() would break program.

I've started this yak shaving in order to make
"CommonFlags::mmap_limit_mb" immutable. Currently we drop this flag
to zero before printing an error message.

Test Plan: regression test suite

Reviewers: kcc, glider

Subscribers: llvm-commits

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

llvm-svn: 224031
2014-12-11 18:30:25 +00:00
Viktor Kutuzov bf3d446528 [Tsan] Fix the signal_recursive.cc test to pass on systems with high loads
Differential Revision: http://reviews.llvm.org/D6504

llvm-svn: 224030
2014-12-11 17:42:29 +00:00
Dmitry Vyukov a1038b1081 tsan: fix Go build
GetRSS is used in Go build.

llvm-svn: 224023
2014-12-11 16:12:45 +00:00
Dmitry Vyukov 4bde5c42b0 tsan: don't subtract one from fake PCs
These are fake and not actual PCs, more like function IDs.
Pass them to external symbolizer untouched.

llvm-svn: 224022
2014-12-11 16:12:16 +00:00
Timur Iskhodzhanov 92292898ab Fix check-asan on Windows by putting lib/clang/... onto PATH (PR21880)
llvm-svn: 224018
2014-12-11 14:04:57 +00:00
Timur Iskhodzhanov 924a4921b4 Update ASan/Win test expectations broken by r223508
llvm-svn: 223932
2014-12-10 17:56:29 +00:00
Evgeniy Stepanov e14d29b1de [sanitizer] Disable compile-time checks for __kernel_old_uid_t size on aarch64.
Should fix PR21476.

llvm-svn: 223925
2014-12-10 11:44:09 +00:00
Saleem Abdulrasool 1fe0c18914 builtins: cleanup constant data section selection
Each of the object formats use a different directive for selecting the constant
section.  Use a macro to avoid the duplication across a number of files.  Also
correct a small macro mismatch on the Windows case (HIDDEN_DIRECTIVE -> HIDDEN).

Patch by Vadim Chugunov!

llvm-svn: 223910
2014-12-10 02:36:22 +00:00
Alexey Samsonov 20962292e8 [DD] Don't store the second copy of CommonFlags inside DDFlags.
llvm-svn: 223909
2014-12-10 02:30:04 +00:00
Alexey Samsonov c2485cab33 [CMake] Make sure dd is built as a part of compiler-rt.
Remove unused variables and definitions in CMake files
for TSan and DD (deadlock detector).

llvm-svn: 223908
2014-12-10 02:14:15 +00:00
Justin Bogner 55248db0c9 profile: Add low level versions of profile buffer functions
On Darwin, compiler_rt uses magic linker symbols to find the profile
counters in the __DATA segment.  This is a reasonable method for
normal, hosted, userspace programs.  However programs with custom
memory layouts, such as the kernel, will need to tell compiler_rt
explicitly where to find these sections.

Patch by Lawrence D'Anna. Thanks!

llvm-svn: 223840
2014-12-09 22:07:25 +00:00
Kostya Serebryany 83ed889bbd [tsan] remove TSAN_GO in favor of SANITIZER_GO
llvm-svn: 223732
2014-12-09 01:31:14 +00:00
Kostya Serebryany 6c54a6b5dd [asan] move GetRSS from tsan to sanitizer_common
llvm-svn: 223730
2014-12-09 01:22:59 +00:00
Alexey Samsonov 761e22ad8e Update bogus file permissions.
Suggested in http://reviews.llvm.org/D6547.

llvm-svn: 223715
2014-12-08 23:28:07 +00:00
Evgeniy Stepanov 3a9be641d5 [msan] Intercept wcsto*.
Intercept wcstod, wcstof, wcstold, wcstol, wcstoul, wcstoll, wcstoull.

llvm-svn: 223650
2014-12-08 10:41:28 +00:00
Kuba Brecka ddac6cbb34 XFAILing suppression tests on Android. The suppression files are not being transfered to the device.
llvm-svn: 223540
2014-12-05 22:47:44 +00:00
Kuba Brecka b79ccbeb71 Recommit of r223513 and r223514.
Reviewed at http://reviews.llvm.org/D6488

llvm-svn: 223533
2014-12-05 22:19:35 +00:00
Kuba Brecka cd9e81a363 Reverting r223513 and r223514.
llvm-svn: 223519
2014-12-05 21:32:22 +00:00
Peter Collingbourne fd860bc41a [DFSAN][MIPS] adding support of DFSAN for MIPS64
Minor changes to enable DFSAN on MIPS64

Patch by Kumar Sukhani!

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

llvm-svn: 223517
2014-12-05 21:22:36 +00:00
Kuba Brecka 423f3a0bc0 AddressSanitizer - Don't instrument globals from cstring_literals sections. (compiler-rt part)
Reviewed at http://reviews.llvm.org/D6488

llvm-svn: 223514
2014-12-05 21:05:04 +00:00
Kuba Brecka dde00302c7 Implement AddressSanitizer suppressions.
Adds 3 new suppression types, "interceptor_name", "interceptor_via_fun", "interceptor_via_lib".

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

llvm-svn: 223508
2014-12-05 20:26:09 +00:00
Sergey Matveev eba518be94 [ASan] Refactor thread starting code.
Move thread context creation into AsanThread::Create().

llvm-svn: 223483
2014-12-05 17:31:13 +00:00
Sergey Matveev 5a03a9919f [LSan] Rewrite the test from r223419 to not use C++11.
This was causing build failures on llvm-clang-lld-x86_64-centos-6.5 for some
reason. Anyway, the new way is better because we no longer rely on std::thread
implementation details.

llvm-svn: 223480
2014-12-05 17:21:43 +00:00
Sergey Matveev 324ed20dcd [ASan] Fix Win build following r223419.
llvm-svn: 223477
2014-12-05 16:53:58 +00:00
Dmitry Vyukov 362d1202e2 tsan: fix test
this test is flaky because of ASLR
app memory is 7e8000000000-800000000000,
there may or may not be a 1TB hole depending on
where ASLR will choose to map libraries

llvm-svn: 223469
2014-12-05 15:42:17 +00:00
Dmitry Vyukov bf253a3d3f tsan: protect trace memory range on startup
so that user does not map something there ahead of us

llvm-svn: 223456
2014-12-05 10:06:06 +00:00
Sergey Matveev b029c5101f [ASan, LSan] Improve tracking of thread creation.
In the current scheme of things, the call to ThreadStart() in the child
thread is not synchronized with the parent thread. So, if a pointer is passed to
pthread_create, there may be a window of time during which this pointer will not
be discoverable by LSan. I.e. the pthread_create interceptor has already
returneed and thus the pointer is no longer on the parent stack, but we don't
yet know the location of the child stack. This has caused bogus leak reports
(see http://llvm.org/bugs/show_bug.cgi?id=21621/).

This patch makes the pthread_create interceptor wait until the child thread is
properly registered before returning.

llvm-svn: 223419
2014-12-05 00:10:15 +00:00
Hans Wennborg 217cf22cf6 CMake: build DLLs in the right directory and include them in the 'install' target (PR21719)
When CMake builds a dynamic library on Windows, the .dll file's location is
determined by the RUNTIME_OUTPUT_DIRECTORY, which we were previously not
setting.

This means for example that clang_rt.asan_dynamic-i386.dll will get built
and installed in the same directory as the corresponding .lib file,
instead of being built in the bin/ directory and not installed at all.

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

llvm-svn: 223387
2014-12-04 21:01:49 +00:00
Alexander Potapenko 5823daf73d [msan] Put the coverage files for coverage-levels.cc into a temporary dir.
llvm-svn: 223355
2014-12-04 11:35:32 +00:00
Kostya Serebryany 29a2236c7d [msan] allow -fsanitize-coverage=N together with -fsanitize=memory, compiler-rt part
llvm-svn: 223314
2014-12-03 23:29:14 +00:00
Hans Wennborg d59474a6cb ASan CMakeLists.txt: fix bad indent; NFC
llvm-svn: 223258
2014-12-03 19:05:42 +00:00
Evgeniy Stepanov 7395cae005 [msan] Change the way origin ids are built.
Previously, all origin ids were "chained" origins, i.e values of
ChainedOriginDepot. This added a level of indirection for simple
stack and heap allocation, which were represented as chains of
length 1. This costs both RAM and CPU, but provides a joined 2**29
origin id space. It also made function (any instrumented function)
entry non-async-signal-safe, but that does not really matter because
memory stores in track-origins=2 mode are not async-signal-safe anyway.

With this change, the type of the origin is encoded in origin id.
See comment in msan_origin.h for more details. This reduces chained and stack
origin id range to 2**28 each, but leaves extra 2**31 for heap origins.

This change should not have any user-visible effects.

llvm-svn: 223233
2014-12-03 13:58:40 +00:00
Evgeniy Stepanov fc77519c29 [asan] Fix stale_stack_leak.cc test in ASan-UAR mode.
This test does an intentional use-after-return, but this is not the focus of
the test, so ignore it.

llvm-svn: 223230
2014-12-03 13:35:41 +00:00
Evgeniy Stepanov 8a988c40c8 [msan] Add one more test for the handling of stack origins.
llvm-svn: 223229
2014-12-03 13:26:56 +00:00
Evgeniy Stepanov 340347a83f [msan] Re-enable one test.
It has been fixed a long time ago.

llvm-svn: 223226
2014-12-03 12:11:33 +00:00
Kostya Serebryany c93c84e882 [asan] fix four asan tests to run in use-after-return mode
llvm-svn: 223181
2014-12-03 00:08:41 +00:00
Alexey Samsonov 656c29b08f Replace InternalScopedBuffer<char> with InternalScopedString where applicable.
Summary: No functionality change.

Test Plan: make check-all

Reviewers: kcc

Reviewed By: kcc

Subscribers: llvm-commits

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

llvm-svn: 223164
2014-12-02 22:20:11 +00:00
Alexey Samsonov 3da2b06593 Add missing #include to fix Android build.
llvm-svn: 223157
2014-12-02 21:40:41 +00:00
Alexey Samsonov 0e90668f14 Simplify Symbolizer::SymbolizePC() interface.
Return a linked list of AddressInfo objects, instead of using an array of
these objects as an output parameter. This simplifies the code in callers
of this function (especially TSan).

Fix a few memory leaks from internal allocator, when the returned
AddressInfo objects were not properly cleared.

llvm-svn: 223145
2014-12-02 19:48:40 +00:00
Viktor Kutuzov 870e790924 [Tsan] Fix the atomic_race.cc test to pass on systems with high loads
Differential Revision: http://reviews.llvm.org/D6478

llvm-svn: 223122
2014-12-02 15:04:39 +00:00
Viktor Kutuzov fbd6ec09df [Tsan] Do not flush all streams on exit
Differential Revision: http://reviews.llvm.org/D6462

llvm-svn: 223121
2014-12-02 14:59:51 +00:00
Alexey Samsonov 4cdf4eba74 Add override specifiers to Symbolizer methods. NFC.
llvm-svn: 223094
2014-12-01 23:47:51 +00:00
Kuba Brecka 4bd88e3deb Add a HasSuppressionType method into SuppressionContext
Extending SuppressionContext to add a HasSuppressionType method that tells whether a certain suppression type is currently used or not. It's a step to implement issue suppressions for ASan, see http://reviews.llvm.org/D6280.

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

llvm-svn: 222954
2014-11-29 14:18:05 +00:00
Viktor Kutuzov 30bd345613 [Msan] Generalize mapping facilities to add FreeBSD support
Differential Revision: http://reviews.llvm.org/D6387

llvm-svn: 222919
2014-11-28 11:42:55 +00:00
Evgeniy Stepanov a0b6899234 [msan] Fix origin propagation for select of floats.
MSan does not assign origin for instrumentation temps (i.e. the ones that do
not come from the application code), but "select" instrumentation erroneously
tried to use one of those.

https://code.google.com/p/memory-sanitizer/issues/detail?id=78

llvm-svn: 222918
2014-11-28 11:17:58 +00:00
Evgeniy Stepanov f34bad98af [asan] Remove the local copy of Android ucontext.h.
This header is present in the r10c release of the NDK.

llvm-svn: 222915
2014-11-28 10:37:44 +00:00
Viktor Kutuzov d977985e43 [Msan] Fix some interceptors to pass initialization on FreeBSD
Differential Revision: http://reviews.llvm.org/D6417

llvm-svn: 222885
2014-11-27 14:28:57 +00:00
Evgeniy Stepanov b52e3aba3f [asan] Disable preload tests on Android.
They don't test what they claim to because LD_PRELOAD applies to "not" instead
of the actual test binary. And all Android tests run with LD_PRELOAD anyway.

llvm-svn: 222835
2014-11-26 15:44:15 +00:00
Viktor Kutuzov fb61eae0e4 [Asan] Fix the heavy_uar_test.cc test to pass on FreeBSD
Differential Revision: http://reviews.llvm.org/D6406

llvm-svn: 222826
2014-11-26 11:38:45 +00:00
Viktor Kutuzov 38ec0481d2 [Msan] Exclude non-FreeBSD interceptors on FreeBSD
Differential Revision: http://reviews.llvm.org/D6404

llvm-svn: 222822
2014-11-26 10:51:49 +00:00
Viktor Kutuzov 3e4542eac4 [Msan] Check returning value of DTLS_Get()
Differential Revision: http://reviews.llvm.org/D6403

llvm-svn: 222818
2014-11-26 10:42:02 +00:00
Alexey Samsonov 4cc76cb872 [Sanitizer] Bump kMaxPathLength to 4096 and use it more extensively instead of hardcoded constants
llvm-svn: 222803
2014-11-26 01:48:39 +00:00
Alexey Samsonov 9f8d091ea9 [ASan] Fix typo in test
llvm-svn: 222800
2014-11-26 00:23:51 +00:00
Evgeniy Stepanov 089c066bd6 [msan] Remove leftover MSanDR bits in tests.
llvm-svn: 222762
2014-11-25 15:00:23 +00:00
Viktor Kutuzov 28e3d0b6f9 [Sanitizers] Intercept __tls_get_addr() and shmctl() on FreeBSD
Differential Revision: http://reviews.llvm.org/D6384

llvm-svn: 222757
2014-11-25 13:08:02 +00:00
Viktor Kutuzov 9b75b757de [Asan] Pack signal context into a structure
Differential Revision: http://reviews.llvm.org/D6148

llvm-svn: 222756
2014-11-25 13:00:21 +00:00
Jay Foad 0160570a0f [ASan] Fix leak tests on 64-bit targets other than x86-64 (take two)
Summary:
First, remove lit configuration that sets ASAN_OPTIONS to detect_leaks=1
because this is already the default when leak detection is supported.
This removes a bit of duplication between various lit.cfg files.

Second, add a new feature 'leak-detection' if we're targetting x86_64
(not i386) on Linux.

Third, change a couple of tests that need leak detection to require the
new 'leak-detection' feature.

Reviewers: kcc, earthdok, samsonov

Reviewed By: samsonov

Subscribers: llvm-commits

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

llvm-svn: 222738
2014-11-25 07:56:04 +00:00
Yury Gribov 4646b11acf [asan] Improvements for asan deactivated mode: disable asan activation for runtime library on Linux, disable malloc checks.
Reviewed in http://reviews.llvm.org/D6265

llvm-svn: 222732
2014-11-25 07:10:30 +00:00
Alexey Samsonov 49a040a483 [TSan] Deflake test
llvm-svn: 222699
2014-11-24 22:27:34 +00:00
Kostya Serebryany 4cadd4afa0 [asan/coverage] change the way asan coverage instrumentation is done: instead of setting the guard to 1 in the generated code, pass the pointer to guard to __sanitizer_cov and set it there. No user-visible functionality change expected
llvm-svn: 222675
2014-11-24 18:49:53 +00:00
Eric Fiselier 909deebfc8 [compiler-rt] Make the MSAN wmemset intercepter call wmemset instead of memset. Fixes PR 21579
Summary:
Exactly what the title says. I've tested this change against the libc++ test failures and it solves all of them. The check-msan rule also still passes.
I'm not sure why it called memset originally. 

I can add tests if requested but currently there are no tests involving wide chars and they are a c++11 features.

Reviewers: kcc, eugenis

Reviewed By: eugenis

Subscribers: llvm-commits

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

llvm-svn: 222673
2014-11-24 18:17:04 +00:00
Renato Golin 94a272d479 Try to fix ARM buildbots
llvm-svn: 222619
2014-11-22 16:59:03 +00:00
Reid Kleckner 04748b98a6 Don't make check-sanitizer depend on profile on Windows
We don't build the profiling library on Windows, so CMake warns that the
target doesn't exist.

llvm-svn: 222588
2014-11-21 23:09:51 +00:00
Jay Foad e47130e407 [ASan] Get fake stack code working with GCC 4.8.2.
Summary:
TestCases/Linux/heavy_uar_test.cc was failing on my
PowerPC64 box with GCC 4.8.2, because the compiler recognised
a memset-like loop and turned it into a call to memset, which
got intercepted by __asan_memset, which got upset because it was
being called on an address in high shadow memory.

Use break_optimization to stop the compiler from doing this.

Reviewers: kcc, samsonov

Reviewed By: kcc

Subscribers: llvm-commits

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

llvm-svn: 222572
2014-11-21 21:25:09 +00:00