Commit Graph

3651 Commits

Author SHA1 Message Date
Sergey Matveev 4a03fa4f60 [sanitizer] Intercept if_indextoname() and if_nametoindex().
llvm-svn: 200945
2014-02-06 20:39:33 +00:00
Sergey Matveev f3a8acf38a [sanitizer] Fix build.
llvm-svn: 200942
2014-02-06 19:36:10 +00:00
Sergey Matveev 544d07f861 [sanitizer] One does not simply intercept getifaddrs().
Upgrade the interceptor, and attempt to fix the Android build.

llvm-svn: 200936
2014-02-06 18:48:23 +00:00
Sergey Matveev 07802a090a [sanitizer] Intercept getifaddrs().
llvm-svn: 200926
2014-02-06 17:42:36 +00:00
Sergey Matveev 0c62992d6e [sanitizer] Intercept getresuid and getresgid.
llvm-svn: 200925
2014-02-06 15:12:56 +00:00
Alexander Potapenko 1a0aadcd77 [TSan] Add a regression test for https://code.google.com/p/thread-sanitizer/issues/detail?id=47
llvm-svn: 200923
2014-02-06 14:06:12 +00:00
Alexander Potapenko a1193a50b0 [TSan] Don't flush all file streams on program shutdown to avoid deadlocks on file stream locks.
This should fix https://code.google.com/p/thread-sanitizer/issues/detail?id=47.

llvm-svn: 200922
2014-02-06 13:37:14 +00:00
Dmitry Vyukov 9ba840865f tsan: simplify Go build script
we don't use assembly files

llvm-svn: 200916
2014-02-06 09:23:12 +00:00
Dmitry Vyukov 447bb46e03 tsan: remove unused functions
llvm-svn: 200915
2014-02-06 09:22:50 +00:00
Dmitry Vyukov a5d1fcfde1 tsan: improve error message for Go
llvm-svn: 200914
2014-02-06 09:22:29 +00:00
Kostya Serebryany 1f5d17c57d [asan] fix testing on Mac
llvm-svn: 200910
2014-02-06 07:19:52 +00:00
Kostya Serebryany 1ee681305f [asan] introduce two functions that will allow implementations of C++ garbage colection to work with asan's fake stack
llvm-svn: 200908
2014-02-06 06:56:22 +00:00
Sergey Matveev efefe5e225 [sanitizer] Fix build.
llvm-svn: 200873
2014-02-05 20:04:12 +00:00
Sergey Matveev c5c84a1d86 [sanitizer] Implement ioctl decoding.
When an unknown ioctl is encountered, try to guess the parameter size from the
request id.

llvm-svn: 200872
2014-02-05 19:35:24 +00:00
Kostya Serebryany 9ebd483017 [sanitizer] hide two functions in the __sanitizer namespace to avoid exporting them (gold complained)
llvm-svn: 200844
2014-02-05 15:06:32 +00:00
Dmitry Vyukov 93474a9acd tsan: fix windows alignment check
llvm-svn: 200838
2014-02-05 13:41:09 +00:00
Dmitry Vyukov a54308fc6d tsan: deflake flaky test
llvm-svn: 200833
2014-02-05 12:01:34 +00:00
Dmitry Vyukov 7799eb123b tsan: ensure proper alignment of mmaps on windows
llvm-svn: 200832
2014-02-05 11:37:20 +00:00
Timur Iskhodzhanov 4a25d42a3c [ASan/Win] Add DLL thunks for __asan_{,un}poison_memory_region
llvm-svn: 200809
2014-02-04 23:54:26 +00:00
Timur Iskhodzhanov aeefb6abce [ASan/Win] Fall back to stdout if we can't print the reports to stderr
llvm-svn: 200804
2014-02-04 23:28:30 +00:00
Dmitry Vyukov d7fcee8d8c tsan: add windows native build script
llvm-svn: 200780
2014-02-04 17:52:41 +00:00
Dmitry Vyukov a61c2b0bd5 tsan: fix windows build
llvm-svn: 200779
2014-02-04 17:29:44 +00:00
Dmitry Vyukov a538aac8ce tsan: fix windows build
llvm-svn: 200778
2014-02-04 17:27:29 +00:00
Dmitry Vyukov 2da2cee706 tsan: update Go public interface
in preparation for https://codereview.appspot.com/55100044

llvm-svn: 200766
2014-02-04 14:45:54 +00:00
Alexey Samsonov fafbcb6d4c [CMake] Fixup for r200753
llvm-svn: 200761
2014-02-04 13:24:13 +00:00
Alexander Potapenko 4672bacaef [ASan] Get rid of asan_mac.h, which contents have been moved to sanitizer_mac.h
llvm-svn: 200757
2014-02-04 11:35:59 +00:00
Alexander Potapenko 844a3cf77e [ASan] Use replace_str=0 and replace_intrin=0 in printf-{2,4}.c to avoid triggering a buffer overflow in strlen and memcpy.
This change fixes printf-2.c and printf-4.c under OSX.

llvm-svn: 200756
2014-02-04 11:32:05 +00:00
Dmitry Vyukov 2e1634b69f tsan: fix darwin Go build
llvm-svn: 200755
2014-02-04 11:29:09 +00:00
Justin Bogner ad560c4c11 CMake: Enable -Werror for the -fno-function-sections check
If the -fno-function-sections flag isn't recognized, the compiler
emits a warning. This isn't enough to cause the check to fail, so we
enable -Werror as well.

llvm-svn: 200753
2014-02-04 10:40:46 +00:00
Alexander Potapenko 40fcff653c [ASan] Fix printf-5.c on OSX: fix a compiler warning, avoid intercepting memcpy (which triggers the error report before printf does).
llvm-svn: 200751
2014-02-04 10:36:55 +00:00
Dmitry Vyukov 9244c48b29 tsan: update public Go interface
in preparation for https://codereview.appspot.com/55100044

llvm-svn: 200750
2014-02-04 10:35:23 +00:00
Alexander Potapenko 2e7dc60ee3 [ASan] Replace the call to "vname" with "WRAP(vname)" in FORMAT_INTERCEPTOR_IMPL
It's incorrect to call the function by its name in the interceptor, because that means WRAP(vname) on Linux and REAL(vname) on OSX.

This patch fixes asan/lit_tests/TestCases/printf-3.c on Mac.

llvm-svn: 200749
2014-02-04 09:35:09 +00:00
Kostya Serebryany b965a2fa32 [lsan] simplify use_tls_dynamic.cc test
llvm-svn: 200748
2014-02-04 09:07:16 +00:00
Dmitry Vyukov fd0affac37 tsan: add SANITIZER_INTERFACE_ATTRIBUTE to more callbacks
so that it's possible to override them from a dynamic library.

llvm-svn: 200747
2014-02-04 08:46:09 +00:00
Alexey Samsonov d23c79604e [CMake] Check that compiler supports -fno-function-sections flag
llvm-svn: 200746
2014-02-04 08:28:17 +00:00
Dmitry Vyukov 8aaa44c43d tsan: relax check for errno spoiling more
We do not detect errno spoiling for SIGTERM,
because some SIGTERM handlers do spoil errno but reraise SIGTERM,
tsan reports false positive in such case.
It's difficult to properly detect this situation (reraise),
because in async signal processing case (when handler is called directly
from rtl_generic_sighandler) we have not yet received the reraised
signal; and it looks too fragile to intercept all ways to reraise a signal.

llvm-svn: 200742
2014-02-04 07:10:45 +00:00
Kostya Serebryany f6e085cf89 [sanitizer] make __tls_get_addr interceptor (more) AS-safe. No good test so far, will keep trying.
llvm-svn: 200734
2014-02-04 05:22:00 +00:00
Kostya Serebryany 51f135d820 [sanitizer] Handle TLS sizes for glibc < 2.13; As discussed in http://gcc.gnu.org/PR60038, the hardcoded sizeof(struct thread); patch by Jakub Jelinek
llvm-svn: 200733
2014-02-04 04:09:38 +00:00
Alexander Potapenko f6ff6b0929 [libsanitizer] Workaround for https://code.google.com/p/address-sanitizer/issues/detail?id=261
If pthread_get_stacksize_np() returns 512K for the main thread on Mavericks, obtain the stack size from the current stack rlimit.

llvm-svn: 200703
2014-02-03 16:42:29 +00:00
Alexander Potapenko 8d58767b34 [libsanitizer] Follow-up for r200700: add the new header to CMakeLists.txt and make it empty on non-Mac.
llvm-svn: 200701
2014-02-03 15:45:03 +00:00
Alexander Potapenko 768e315a74 [ASan] Move GetMacosVersion() to sanitizer_common.
llvm-svn: 200700
2014-02-03 15:32:19 +00:00
Evgeniy Stepanov 1fc9e61356 [asan] asan_device_setup.sh: allow overriding adb path.
llvm-svn: 200698
2014-02-03 15:12:09 +00:00
Evgeniy Stepanov 756e1c1e4b [asan] Reinitialize allocator quarantine on activation.
This is covered by AddressSanitizer.UAF_* tests in asan_test
with start_deactivated=1.

llvm-svn: 200696
2014-02-03 14:19:08 +00:00
Evgeniy Stepanov bd2b3177da [sanitizer] Resubmit r200683: disable -ffunction-sections.
llvm-svn: 200686
2014-02-03 11:16:41 +00:00
Evgeniy Stepanov fe437f0a8f Revert r200683.
-fno-function-sections is broken in Clang.

llvm-svn: 200684
2014-02-03 10:52:53 +00:00
Evgeniy Stepanov aa0d7dee77 [sanitizer] Disable -ffunction-sections.
It breaks when a binary is linked with --gc-sections: parts of sanitizer
interface get thrown away and inaccessible from dlopen-ed libs.

llvm-svn: 200683
2014-02-03 10:15:08 +00:00
Evgeniy Stepanov 04e841c047 [msan] Fix a typo.
Spotted by Keno Fischer.

llvm-svn: 200682
2014-02-03 07:27:01 +00:00
Sergey Matveev c18b36625e [sanitizer] Partial revert of recent ioctl changes.
Some build environments are missing the required headers.
This reverts r200544, r200547, r200551. This does not revert the change that
introduced READWRITE ioctl type.

llvm-svn: 200567
2014-01-31 19:19:45 +00:00
Timur Iskhodzhanov 322ce39e39 Remove /FS as it's auto-added by CMake 2.8.12.1; also, remove /wd4221 as 4221 is a linker warning, not a compiler warning
llvm-svn: 200564
2014-01-31 18:25:37 +00:00
Alexander Potapenko ea4a0dbb8d [ASan] Implement __sanitizer::InstallDeadlySignalHandlers() and __asan::AsanOnSIGSEGV() on Windows.
llvm-svn: 200554
2014-01-31 15:11:11 +00:00
Alexander Potapenko c6864e9039 [ASan] Add a failing test that demonstrates that ASan currently breaks dead code stripping on Linux.
See https://code.google.com/p/address-sanitizer/issues/detail?id=260 for more info.

llvm-svn: 200553
2014-01-31 14:58:54 +00:00
Renato Golin b760aa6722 Sorting ARM Sources alphabetically
llvm-svn: 200552
2014-01-31 14:53:52 +00:00
Evgeniy Stepanov a78dbe2e6f [asan] Fix Android build.
llvm-svn: 200551
2014-01-31 14:46:37 +00:00
Evgeniy Stepanov 01cd8ae204 [asan] Read extra flags from a system property on activation on Android.
llvm-svn: 200550
2014-01-31 14:36:55 +00:00
Alexander Potapenko 36b18dfe64 [libsanitizer] Fix compilation for gotsan.
llvm-svn: 200549
2014-01-31 14:30:12 +00:00
Sergey Matveev dffda4cfec [sanitizer] Attempt to fix Android build.
llvm-svn: 200547
2014-01-31 14:28:32 +00:00
Renato Golin 66e2b70e59 Enable compilation of RT on ARM
Adding the ARM RT sources to the CMake files, and enabling some
sanitizers to also build on ARM. This is far from supported or
production quality, but enabling it to build will get us errors
that we can actually fix.

Having said that, the Compiler-RT and the Asan libraries are
know to work on some variations of ARM.

llvm-svn: 200546
2014-01-31 14:25:58 +00:00
Sergey Matveev 6b3397546e [sanitizer] Support most ioctls from /usr/include/sound/.
llvm-svn: 200544
2014-01-31 14:02:21 +00:00
Alexander Potapenko 789e3e1b7c [ASan] Move the SIGSEGV/SIGBUS handling to sanitizer_common
This change is a part of refactoring intended to have common signal handling behavior in all tools.
This particular CL moves InstallSignalHandlers() into sanitizer_common (making it InstallDeadlySignalHandlers()), but doesn't enable default signal handlers for any tool other than ASan.

llvm-svn: 200542
2014-01-31 13:10:07 +00:00
Alexey Samsonov fd99206ee4 [ASan] Run LSan for ASan unit tests only on 64-bit Linux
llvm-svn: 200537
2014-01-31 11:44:32 +00:00
Alexander Potapenko e925e53114 Fix compilation: don't convert NULL to a pointer-incompatible type.
llvm-svn: 200536
2014-01-31 11:44:15 +00:00
Alexander Potapenko d5802fe548 Make signal-related functions use __sanitizer_* structures instead of __sanitizer_kernel_* ones.
Also rename internal_sigaction() into internal_sigaction_norestorer(), as this function doesn't fully
implement the sigaction() functionality on Linux.

This change is a part of refactoring intended to have common signal handling behavior in all tools.

llvm-svn: 200535
2014-01-31 11:29:51 +00:00
Dmitry Vyukov e63a09adb6 tsan: fix Go build
Go linker does not like function-static objects.

llvm-svn: 200534
2014-01-31 11:20:55 +00:00
Timur Iskhodzhanov 00aa75b774 Move /FS to SANITIZER_COMMON_CFLAGS
llvm-svn: 200485
2014-01-30 19:48:13 +00:00
Timur Iskhodzhanov 5b56093acc Quick-fix a typo
llvm-svn: 200483
2014-01-30 19:19:47 +00:00
Timur Iskhodzhanov 45849098eb Add an /FS flag to the lib/interception CMake to make it buildable with VS2013 too
llvm-svn: 200482
2014-01-30 19:19:29 +00:00
Timur Iskhodzhanov 272502656e Add an /FS flag to the sanitizer_common CMake to make it buildable with VS2013
llvm-svn: 200480
2014-01-30 18:56:06 +00:00
Joerg Sonnenberger dde2700cde Copy&paste errors. Found by Thomas Klausner.
llvm-svn: 200477
2014-01-30 18:41:32 +00:00
Timur Iskhodzhanov a1f31460d8 Add an /FS flag to the ASan RTL CMake to make it buildable with VS2013
llvm-svn: 200474
2014-01-30 18:08:41 +00:00
Evgeniy Stepanov 3f6af151df [sanitizer] Fix typo that breaks shmctl() interceptor.
https://code.google.com/p/address-sanitizer/issues/detail?id=259

llvm-svn: 200468
2014-01-30 14:31:26 +00:00
Sergey Matveev be68311660 [msan] Intercept *getxattr and *listxattr.
llvm-svn: 200464
2014-01-30 12:21:12 +00:00
Kostya Serebryany b22298af9a [asan] re-enable __tls_get_addr interceptor with a proper fix (use __attribute__((tls_model(initial-exec))))
llvm-svn: 200463
2014-01-30 09:25:48 +00:00
Kostya Serebryany 409d26ac5e [asan] disable __tls_get_addr interceptor while I am investigating why it causes trouble; few more debugging
llvm-svn: 200462
2014-01-30 09:00:42 +00:00
Joerg Sonnenberger ce0f2175d7 Support ARMv4 in the remaining non-VFP routines.
llvm-svn: 200397
2014-01-29 13:54:54 +00:00
Joerg Sonnenberger deeb8dc593 Move JMP/JMPc definition into assembly.h's ARM block.
llvm-svn: 200396
2014-01-29 13:54:16 +00:00
Joerg Sonnenberger d8f7fb94a7 Optimized implementation of __clzdi2 and __clzsi2 for ARM. Written in
collaboration with Matt Thomas.

Differential Revision: http://llvm-reviews.chandlerc.com/D2630

llvm-svn: 200394
2014-01-29 13:46:28 +00:00
Evgeniy Stepanov aeefe8c1bb Remove -arm-enable-ehabi from Android build rules. It's enabled by default.
llvm-svn: 200392
2014-01-29 12:36:45 +00:00
Kostya Serebryany 336d97146a [asan] increase the buffer size for printing asan legend, add a test for legend
llvm-svn: 200387
2014-01-29 11:12:09 +00:00
Kostya Serebryany cda06acd31 [asan] fix build on Mac (hopefully)
llvm-svn: 200386
2014-01-29 10:26:38 +00:00
Kostya Serebryany 71788fac2a [asan] experimental intercetor for __tls_get_addr. So far it does nothing interesting, actual usage will come later. See https://groups.google.com/forum/#!topic/address-sanitizer/BfwYD8HMxTM for background
llvm-svn: 200384
2014-01-29 09:29:16 +00:00
Evgeniy Stepanov 422944fdbd [asan] Fix asan_device_setup.sh failure on userdebug Android.
llvm-svn: 200382
2014-01-29 09:16:48 +00:00
Timur Iskhodzhanov 50672ac9cb Add support for more instruction prefixes so we can intercept functions in the VS2013 RTL
llvm-svn: 200366
2014-01-29 02:00:58 +00:00
Alexander Potapenko b0930f5c04 [ASan] Reinstate ASAN_LOW_MEMORY, which has nothing to do with signal handling and thus should not be moved to common.
llvm-svn: 200319
2014-01-28 14:17:16 +00:00
Alexander Potapenko 31e24962f4 [ASan] Remove an accidentally added include of signal.h
llvm-svn: 200318
2014-01-28 14:10:06 +00:00
Joerg Sonnenberger 05d8a22cf6 Cache invalidation for AARCH64. Disabled for Apple for now as requested
by Tim Northover. Written by Matt Thomas.

Differential Revision: http://llvm-reviews.chandlerc.com/D2631

llvm-svn: 200317
2014-01-28 14:02:22 +00:00
Sergey Matveev 1394f2da85 [msan] Rewrite strto* interceptors and add a few more.
Express the strto* interceptors though macros. This removes a lot of
duplicate code and fixes a couple of copypasto bugs (where "res" was declared of
a different type than the actual return type). Also, add a few more interceptors
for strto*_l.

llvm-svn: 200316
2014-01-28 13:45:58 +00:00
Alexander Potapenko 77f5c20a5b [ASan] Fix compilation.
llvm-svn: 200312
2014-01-28 12:23:14 +00:00
Alexander Potapenko d8d490ed50 [ASan] Move the sigaltstack() bits to sanitizer_common.
This change is a part of refactoring intended to have common signal handling behavior in all tools.
Note that this particular change doesn't enable use_sigaltstack support in every tool.

llvm-svn: 200310
2014-01-28 11:12:29 +00:00
Dmitry Vyukov dc96a0fada tsan: remove interceptor stats
They seems to be unused, but cause maintenance pain.

llvm-svn: 200308
2014-01-28 11:02:04 +00:00
Dmitry Vyukov 7c9621c0be tsan: relax checking of errno spoiling in signal handlers
allow SIGABRT to spoil errno, because some real programs
reset SIGABRT handler in the handler, re-raise SIGABRT and return from the handler

llvm-svn: 200304
2014-01-28 09:49:48 +00:00
Alexander Potapenko cf4bef3161 [ASan] Move the signal handling-related flags to sanitizer_common.
This change is a part of refactoring intended to have common signal handling behavior in all tools.

llvm-svn: 200295
2014-01-28 09:28:57 +00:00
Evgeniy Stepanov 0b09c623c1 [msan] Replace assert() with GTest ASSERT_* in msan_test.
llvm-svn: 200293
2014-01-28 08:51:39 +00:00
Joerg Sonnenberger 92ce6e83fc Rename fabs to local_fabs to not conflict with the builtin.
llvm-svn: 200245
2014-01-27 20:09:03 +00:00
Kostya Serebryany 7fe86589f1 [sanitizer] revert r200197: the buggy kernel (https://bugzilla.kernel.org/show_bug.cgi?id=67651) is almost unusable with asan even with this workaround (too slow), so this workaround makes no sense. The asan/msan bootstrap bot was changed to use a non-buggy kernel
llvm-svn: 200217
2014-01-27 13:05:09 +00:00
Evgeniy Stepanov 067f54718f [msan] Disable mmap outside of application address range.
llvm-svn: 200200
2014-01-27 09:12:22 +00:00
Evgeniy Stepanov aecead9d4f [asan] Android setup: do "adb root" before "adb remount".
llvm-svn: 200199
2014-01-27 08:20:28 +00:00
Kostya Serebryany 0a5049b780 [sanitizer] increase the mmap granularity in sanitizer allocator from 2^16 to 2^18. This is a partial workaround for the fresh Kernel bug https://bugzilla.kernel.org/show_bug.cgi?id=67651
llvm-svn: 200197
2014-01-27 07:35:32 +00:00
Tim Northover 7449bda3d9 ARM: also remove useless .arm directive from other files
llvm-svn: 200044
2014-01-24 22:04:15 +00:00
Tim Northover 5386cae6b7 ARM: remove unnecessary .arm directive
It was redundant (since ARM mode is the default) and misleading since
(e.g.) Cortex-A15 would not satisfy the #ifdef but would be in ARM
mode regardless.

llvm-svn: 200043
2014-01-24 21:58:22 +00:00
Bob Wilson 1b39261990 Fix a typo "endi" -> "endif" in r200035.
llvm-svn: 200039
2014-01-24 21:04:05 +00:00
Joerg Sonnenberger 2fb149b901 Don't use .arm for ARMv7M, which will use the hwdiv path. Non-hwdiv
remains ARM mode only, supporting thumb requires explicit it prefixes
for the predicted adds/subs and adjusting the offset computation for the
different block sizes.

llvm-svn: 200035
2014-01-24 20:45:18 +00:00
Dmitry Vyukov 3ee32e7647 tsan: fix test for -O2
otherwise races are suppressed due to "same stack"

llvm-svn: 200015
2014-01-24 16:30:53 +00:00
Dmitry Vyukov 80240acd77 tsan: fix test for -O2
llvm-svn: 200012
2014-01-24 15:58:20 +00:00
Evgeniy Stepanov 9504304f2d [asan] Add an ASan-on-Android installation script.
llvm-svn: 200009
2014-01-24 15:24:24 +00:00
Joerg Sonnenberger db99eee490 Add end-of-function markers.
llvm-svn: 200007
2014-01-24 14:42:55 +00:00
Joerg Sonnenberger 2a10033ae7 Add end-of-function markers.
llvm-svn: 200006
2014-01-24 14:40:53 +00:00
Joerg Sonnenberger 171e9cfb0e Mechanically add end-of-function markers.
llvm-svn: 200005
2014-01-24 14:33:42 +00:00
Dmitry Vyukov 1b3862ab06 tsan: fix signal handling
We left ignore_interceptors>0 when calling signal handlers
from blocking interceptors, this leads to missing synchronization in such signal handler.

llvm-svn: 200003
2014-01-24 14:16:00 +00:00
Dmitry Vyukov 041510b290 tsan: fix test relying on assert
llvm-svn: 200002
2014-01-24 14:14:28 +00:00
Joerg Sonnenberger 59611a8b20 Provide support for ARMv4, lacking bx and clz. Unroll the
test-and-subtract loop and compute the initial block as address,
shaving off between 5% and 10% on Cortex A9 and 30%+ a Raspberry Pi.
Code written by Matt Thomas and Joerg Sonnenberger.

Differential Revision: http://llvm-reviews.chandlerc.com/D2595

llvm-svn: 200001
2014-01-24 13:43:35 +00:00
Joerg Sonnenberger 1f8cb3ee67 Implement __ARM_ARCH if the compiler lacks it. Add feature tests for bx and clz.
llvm-svn: 199998
2014-01-24 13:39:51 +00:00
Tim Northover 5a8af3e136 Darwin: add x86_64h slice for Haswell.
llvm-svn: 199996
2014-01-24 13:10:55 +00:00
Dmitry Vyukov 16e7a758b0 tsan: do not deadlock on fork
Currently correct programs can deadlock after fork, because atomic operations and async-signal-safe calls are not async-signal-safe under tsan.
With this change:
- if a single-threaded program forks, the child continues running with verification enabled (the tsan background thread is recreated as well)
- if a multi-threaded program forks, then the child runs with verification disabled (memory accesses, atomic operations and interceptors are disabled); it's expected that it will exec soon anyway
- if the child tries to create more threads after multi-threaded fork, the program aborts with error message
- die_after_fork flag is added that allows to continue running, but all bets are off

http://llvm-reviews.chandlerc.com/D2614

llvm-svn: 199993
2014-01-24 12:33:35 +00:00
Kostya Serebryany e402b431c0 [msan] add __libc_memalign interceptor; add a regression test for the existing bug with dtls support in msan
llvm-svn: 199980
2014-01-24 09:14:11 +00:00
Alexey Samsonov c496eba75f Don't create check-ubsan and check-dfsan commands if they are not supported on this platform
llvm-svn: 199979
2014-01-24 08:06:21 +00:00
Joerg Sonnenberger 25468a2ab4 Add end of function marker, which can be used on ELF to correctly set
the function size.

llvm-svn: 199914
2014-01-23 18:31:46 +00:00
Sergey Matveev 9b068a2c06 [lsan] Expand a comment to document our dynamic TLS hack.
llvm-svn: 199900
2014-01-23 15:10:35 +00:00
Alexey Samsonov 1d028b8a9f [Sanitizer] Fix false positive in snprintf interceptor - take the number of actually written symbols from real snprintf call.
llvm-svn: 199899
2014-01-23 15:09:38 +00:00
Alexey Samsonov 902bb51612 [Sanitizer] Fix false positive in printf interceptors: properly handle precision for %s
llvm-svn: 199895
2014-01-23 14:35:28 +00:00
Evgeniy Stepanov 20513c0937 [asan] More buffering in report printing.
llvm-svn: 199888
2014-01-23 11:51:03 +00:00
Evgeniy Stepanov 350fe4b1af [asan] Android logging.
This change duplicates all ASan output to system log on Android.

llvm-svn: 199887
2014-01-23 11:34:41 +00:00
Evgeniy Stepanov 6975704f62 [sanitizer] Replace inline with INLINE.
llvm-svn: 199883
2014-01-23 11:22:04 +00:00
Evgeniy Stepanov 04c5a836a2 [sanitizer] Add a sanity check.
llvm-svn: 199880
2014-01-23 11:01:07 +00:00
Evgeniy Stepanov 43d1888285 [sanitizer] Fix format string mismatches found by format attributes added in r199874.
llvm-svn: 199879
2014-01-23 10:57:08 +00:00
Evgeniy Stepanov 631bd92292 [asan] Print shadow memory and legend as a single printf call.
llvm-svn: 199878
2014-01-23 10:52:33 +00:00
Evgeniy Stepanov 4819d28e53 [asan] clang-format part of asan_report.cc
llvm-svn: 199877
2014-01-23 10:49:47 +00:00
Evgeniy Stepanov 29b7866c6c [sanitizer] Add printf format attributes.
These were lost in a refactoring a long time ago.

llvm-svn: 199874
2014-01-23 08:58:34 +00:00
Evgeniy Stepanov b1fa81047a [msan] Fix GCC warnings.
warning: ISO C99 requires rest arguments to be used [enabled by default]
 INTERCEPTOR(char *, dlerror) {

warning: invoking macro INTERCEPTOR argument 3: empty macro arguments are undefined in ISO C90 and ISO C++98 [enabled by default]
llvm-svn: 199873
2014-01-23 08:43:12 +00:00
Evgeniy Stepanov 1a9f5720d8 [asan] Enable replacement new/delete on Android.
New/delete implementations in system libraries almost always are built without
frame pointers. As we switched to frame pointer based unwinder on ARM, they no
longer work for us, resulting in broken allocation/deallocation stacks.

Note that this does not work with statically linked
libstdc++/libc++/libstlport.

llvm-svn: 199872
2014-01-23 08:14:20 +00:00
Dmitry Vyukov db1ad12ae2 asan: fix atomic operations on ARM
implement correct atomic load/store for ARM
add test for atomic load/store
http://llvm-reviews.chandlerc.com/D2582

llvm-svn: 199802
2014-01-22 14:13:37 +00:00
Alexey Samsonov 8c03475f01 [Sanitizer] try harder to fix Werror build break after r199729
llvm-svn: 199736
2014-01-21 13:06:38 +00:00
Alexey Samsonov 39dbd7cc2c [Sanitizer] Update file names now that we intercept both scanf and printf
llvm-svn: 199735
2014-01-21 13:01:20 +00:00
Tim Northover bea1cafde8 Macho-embedded: update build script for newer Clang behaviour.
Clang now uses the *-apple-macho triples for embedded targets using MachO. The
environment makes less pretences to be running an actual Mach kernel with all
the support that would imply, so a few changes are needed to the build scripts:
    
+ The Apple way of detecting endianness applies in all cases so drop the
  __MACH__ test.
+ A quick rename since "darwin_embedded" no longer makes any sense. If there's
  no Mach going on, there's certainly no Darwin.
+ Change how we test for support for a platform. The functions we build don't
  need any SDK support (stdio.h, ...) so we don't need to check for it.

llvm-svn: 199731
2014-01-21 12:38:02 +00:00
Alexey Samsonov 20494ca293 Fix unused function warning from r199729
llvm-svn: 199730
2014-01-21 12:16:19 +00:00
Alexey Samsonov 00cd273c46 Sanitize printf functions.
Intercept and sanitize arguments passed to printf functions in ASan and TSan
(don't do this in MSan for now). The checks are controlled by runtime flag
(off by default for now).

Patch http://llvm-reviews.chandlerc.com/D2480 by Yuri Gribov!

llvm-svn: 199729
2014-01-21 11:58:33 +00:00
Evgeniy Stepanov e676aadecf [asan] Enable frame pointer based unwinder on ARM.
This code works with AAPCS-style {fp, lr} frames. Unlike linux perf, it does
not unwind through code compiled with -mapcs-frame (which Clang does not
support anyway).

llvm-svn: 199725
2014-01-21 11:04:58 +00:00
Alexey Samsonov 0714b7b31b [Sanitizer] Support %.*s in internal printf implementation. Patch by Yuri Gribov.
llvm-svn: 199724
2014-01-21 10:59:44 +00:00
Kostya Serebryany 9fcb4c4a6e [asan] one more test for https://code.google.com/p/address-sanitizer/issues/detail?id=258
llvm-svn: 199723
2014-01-21 10:57:07 +00:00
Kostya Serebryany 4871067a55 [asan] relax the checks inside __sanitizer_annotate_contiguous_container: they are too optimistic due to https://code.google.com/p/address-sanitizer/issues/detail?id=258.
llvm-svn: 199715
2014-01-21 09:53:49 +00:00
Evgeniy Stepanov e98f9099a9 [msandr] Access app TLS directly in native exec mode.
In optimized hybrid execution we do not use DynamoRIO private loader, which
mangles TLS access, so we can access the application's TLS directly.

Patch by Qin Zhao.

llvm-svn: 199655
2014-01-20 13:09:29 +00:00
Nick Lewycky 62fd6778f5 Fix think-o from r199332 -- write to the new_filename we're building, not
filename the global variable.

llvm-svn: 199572
2014-01-19 07:37:29 +00:00
Kostya Serebryany 123994c4a6 [asan] use correct type when computing shadow address in allocator (caused SEGV when asan run-time is built with gcc 4.8.2 on 32-bit arch)
llvm-svn: 199544
2014-01-18 09:38:31 +00:00
Joerg Sonnenberger a9b3aee516 Support NetBSD/ARM.
llvm-svn: 199492
2014-01-17 14:06:22 +00:00
Kostya Serebryany 714c67c31e [asan] extend asan-coverage (still experimental).
- add a mode for collecting per-block coverage (-asan-coverage=2).
   So far the implementation is naive (all blocks are instrumented),
   the performance overhead on top of asan could be as high as 30%.
 - Make sure the one-time calls to __sanitizer_cov are moved to function buttom,
   which in turn required to copy the original debug info into the call insn.

Here is the performance data on SPEC 2006
(train data, comparing asan with asan-coverage={0,1,2}):

                             asan+cov0     asan+cov1      diff 0-1    asan+cov2       diff 0-2      diff 1-2
       400.perlbench,        65.60,        65.80,         1.00,        76.20,         1.16,         1.16
           401.bzip2,        65.10,        65.50,         1.01,        75.90,         1.17,         1.16
             403.gcc,         1.64,         1.69,         1.03,         2.04,         1.24,         1.21
             429.mcf,        21.90,        22.60,         1.03,        23.20,         1.06,         1.03
           445.gobmk,       166.00,       169.00,         1.02,       205.00,         1.23,         1.21
           456.hmmer,        88.30,        87.90,         1.00,        91.00,         1.03,         1.04
           458.sjeng,       210.00,       222.00,         1.06,       258.00,         1.23,         1.16
      462.libquantum,         1.73,         1.75,         1.01,         2.11,         1.22,         1.21
         464.h264ref,       147.00,       152.00,         1.03,       160.00,         1.09,         1.05
         471.omnetpp,       115.00,       116.00,         1.01,       140.00,         1.22,         1.21
           473.astar,       133.00,       131.00,         0.98,       142.00,         1.07,         1.08
       483.xalancbmk,       118.00,       120.00,         1.02,       154.00,         1.31,         1.28
            433.milc,        19.80,        20.00,         1.01,        20.10,         1.02,         1.01
            444.namd,        16.20,        16.20,         1.00,        17.60,         1.09,         1.09
          447.dealII,        41.80,        42.20,         1.01,        43.50,         1.04,         1.03
          450.soplex,         7.51,         7.82,         1.04,         8.25,         1.10,         1.05
          453.povray,        14.00,        14.40,         1.03,        15.80,         1.13,         1.10
             470.lbm,        33.30,        34.10,         1.02,        34.10,         1.02,         1.00
         482.sphinx3,        12.40,        12.30,         0.99,        13.00,         1.05,         1.06

llvm-svn: 199488
2014-01-17 11:00:30 +00:00
Evgeniy Stepanov 755fc5c313 [asan] Link runtime library with -lm -Wl,-z,defs to ensure that it declares all its dependencies.
llvm-svn: 199483
2014-01-17 09:38:46 +00:00
Alexey Samsonov a64851bccb [Sanitizer] Remove empty method
llvm-svn: 199481
2014-01-17 08:39:05 +00:00
Evgeniy Stepanov 877bb8ba59 [asan] Fix a build warning on windows.
llvm-svn: 199390
2014-01-16 14:21:17 +00:00
Joerg Sonnenberger da93c0f37c Add missing __aeabi_fcmpun alias to match C version.
llvm-svn: 199386
2014-01-16 13:55:24 +00:00
Alexey Samsonov 4d075df406 [Sanitizer] Add basic support for using libbacktrace in symbolizer.
This change allows to compile sanitizer sources so that *san runtime
will attempt to use libbacktrace and/or libiberty for symbolization
(instead of communicating with llvm-symbolizer).

I've tested this patch by manually defining SANITIZER_LIBBACKTRACE and/or
SANITIZER_CP_DEMANGLE, linking with necessary libraries and verifying that
all tests from ASan test suite work.

Based on patches by Jakub Jelinek!

llvm-svn: 199384
2014-01-16 13:48:15 +00:00
Evgeniy Stepanov 364bfdf4c9 [asan] Fix a bunch of style issues.
llvm-svn: 199380
2014-01-16 13:17:13 +00:00
Evgeniy Stepanov fe906a1df6 [asan] Restore lost -pie in Android tests.
llvm-svn: 199379
2014-01-16 13:11:37 +00:00
Evgeniy Stepanov c61623b170 [asan] Implement delayed activation of AddressSanitizer
This change adds ASAN_OPTIONS=start_deactivated=1 flag. When present, ASan will
start in "deactivated" mode, with no heap poisoning, no quarantine, no stack
trace gathering, and minimal redzones. All this features come back when
__asan_init is called for the constructor of an instrumented library.

The primary use case for this feature is Android. Code itself is not
Android-specific, and this patch includes a Linux test for it.

llvm-svn: 199377
2014-01-16 12:31:50 +00:00
Evgeniy Stepanov 780d85a8ef [asan] Remove leftover use of -fsanitize-address-zero-base-shadow.
llvm-svn: 199373
2014-01-16 11:42:40 +00:00
Evgeniy Stepanov e259b658e4 [asan] Nuke ASAN_FLEXIBLE_MAPPING_AND_OFFSET.
llvm-svn: 199370
2014-01-16 10:16:19 +00:00
Joerg Sonnenberger ef0cbe9366 ARM's @ comment mode strikes again. Use %function on ARM.
llvm-svn: 199342
2014-01-16 00:36:49 +00:00
Bob Wilson e38cc76c32 Remove support for armv7f slice. <rdar://problem/12478440>
This was never used for anything so we should just get rid of it.

llvm-svn: 199333
2014-01-15 21:05:20 +00:00
Joerg Sonnenberger c989455e6d Avoid shadowing the global filename. Reorg mangle_filename to be more
precise in the length accounting and use memcpy instead of
strcpy/strcat.

Differential Revision: http://llvm-reviews.chandlerc.com/D2547

llvm-svn: 199332
2014-01-15 20:57:10 +00:00
Kostya Serebryany 06222915cf [lsan] remove LeakSanitizerIsTurnedOffForTheCurrentProcess (this was a bad idea), leave __lsan_is_turned_off
llvm-svn: 199304
2014-01-15 08:04:21 +00:00
Evgeniy Stepanov fc0ba53531 [msan] Fix an incorrect comment.
llvm-svn: 199300
2014-01-15 06:49:40 +00:00
Joerg Sonnenberger 197568a02f Declare assembler functions as symbols of type function for ELF.
Fixes dynamically linked programs on NetBSD/i386.

llvm-svn: 199273
2014-01-14 23:31:23 +00:00
Kostya Serebryany 6e53cfc1ac [tsan] one more explicit memset in tsan rtl (to please gcc 4.8.2)
llvm-svn: 199216
2014-01-14 15:00:10 +00:00
Kostya Serebryany 19e6e4a445 [tsan] reduce the size of stack frame in MapRodata to please gcc 4.8.2
llvm-svn: 199200
2014-01-14 10:25:42 +00:00
Kostya Serebryany 47d5569de1 [asan] Include <sys/stat.h> if __x86_64__ is defined
struct stat defined in <asm/stat.h> is incorrect for x32.  <asm/stat.h>
is included to get struct __old_kernel_stat.  But struct __old_kernel_stat
isn't used for x86-64 nor x32.  This patch includes <sys/stat.h> instead
of <asm/stat.h> and comments out size check of struct __old_kernel_stat
for x86-64.

Patch by H.J. Lu

llvm-svn: 199192
2014-01-14 07:38:53 +00:00
Sergey Matveev 3a47244c94 [lsan] Add __lsan_default_suppressions() to the public interface header.
llvm-svn: 199121
2014-01-13 17:26:57 +00:00
Kostya Serebryany e8699fcd8e [sanitizer] fix comment
llvm-svn: 199112
2014-01-13 15:06:20 +00:00
Kostya Serebryany d651412cd4 [asan] fix the ppc32 build (by Jakub Jelinek). Note that the LLVM build still builds only for 64-bit PowerPC, and not for 32-bit
llvm-svn: 199090
2014-01-13 10:19:12 +00:00
Kostya Serebryany 2b76278d38 [lsan] handle 'new T[0]' where T is a type with DTOR; fixes https://code.google.com/p/address-sanitizer/issues/detail?id=257
llvm-svn: 198932
2014-01-10 10:48:01 +00:00
Kostya Serebryany 27f5b8800d [lsan] rename __lsan_is_turned_off to LeakSanitizerIsTurnedOffForTheCurrentProcess (leave the old variant for now for compatibility)
llvm-svn: 198921
2014-01-10 07:58:25 +00:00
Evgeniy Stepanov 3ee789cbbb [msan] Temporarily disable two tests that are failing with new glibc.
llvm-svn: 198919
2014-01-10 07:34:16 +00:00
Evgeniy Stepanov 219719a2da [asan] Implement max_redzone runtime flag.
llvm-svn: 198873
2014-01-09 14:41:03 +00:00
Justin Bogner d46fd08690 SDKs: Add inttypes.h to the darwin SDK stub
This unbreaks the configure build on darwin, where we build with the
stub SDK in -isysroot. Oddly, the cmake build doesn't have this
restriction, which probably means the cmake configs are out of date.

llvm-svn: 198676
2014-01-07 05:42:09 +00:00
Justin Bogner 3e69e13092 Revert "Only include inttypes.h on platforms for which PRIu64 isn't in stdint.h"
This reverts commit e7778e08878d0c61903205428eeb131db9d11b3c.

llvm-svn: 198657
2014-01-07 01:46:49 +00:00
Justin Bogner 1917588d0c Revert "Explicitly enable PRIu64 by defining __STDC_FORMAT_MACROS if it isn't"
This reverts commit d1b5d3b0e885ef057643fcea99bff8b6cce04b93.

llvm-svn: 198656
2014-01-07 01:46:46 +00:00
Kaelyn Uhrain 9ee39534aa Explicitly enable PRIu64 by defining __STDC_FORMAT_MACROS if it isn't
yet defined.

llvm-svn: 198650
2014-01-07 00:29:19 +00:00
Kaelyn Uhrain 88d8974152 Only include inttypes.h on platforms for which PRIu64 isn't in stdint.h
llvm-svn: 198647
2014-01-06 23:37:31 +00:00
Kaelyn Uhrain 617499fe6c Use the PRIu64 macro for printing a uint64_t.
Otherwise on (some) 64-bit systems, -Wformat will trigger a warning
because uint64_t is an 'unsigned long' not an 'unsigned long long'.
Consequently, PGOProfiling.c would fail to build if -Werror and
-Wformat are both enabled.

llvm-svn: 198644
2014-01-06 23:17:27 +00:00
Justin Bogner 65bb804f05 profile: Rudimentary suppport for PGO instrumentation
This is fairly minimal support for instrumentation based PGO. The data
format is inefficient, and the output file name is hardcoded to
pgo-data.

llvm-svn: 198638
2014-01-06 22:27:03 +00:00
NAKAMURA Takumi d40d387fb1 Update the copyright credits -- Happy new year 2014!
FIXME: Dragonegg may be updated at non-trivial changes.
llvm-svn: 198274
2014-01-01 08:27:31 +00:00
Dmitry Vyukov 5b57ea7a24 tsan: fix Go build
Currently fails with:
gotsan.cc:7686:40: error: the address of 'int __sanitizer_pthread_attr_getstack(void*, void**, size_t*)' will always evaluate as 'true' [-Werror=address]

llvm-svn: 198261
2013-12-31 09:38:23 +00:00
Chandler Carruth a989fb5ce7 Fix an ODR violation in the sanitizer runtimes.
A helper function is a C++ function, and so even though one of the two
definitions is weak, it still technically triggers the ODR. Perhaps
these two definitions are ODR equivalent, but I'm not even confident in
that.

Instead, just define the function once, declare it as weak, and use
a wrapper that is clearly file-local. This avoids two definitions. Also
make the function extern "C" so that we can't even mess up the type
signature somehow or otherwise fail to match up the weak declaration
here with the interceptor defined elsewhere.

llvm-svn: 198253
2013-12-30 23:36:11 +00:00
Alexander Potapenko 79bb924e17 [libsanitizer] fix lint errors
llvm-svn: 198209
2013-12-30 11:12:11 +00:00
Alexander Potapenko e93e87369f [libsanitizer] Remove the redundant spaces between '#' and 'define'.
These definitions weren't included in any #ifdef blocks, and the spaces were placed inconsistently.

llvm-svn: 198207
2013-12-30 09:22:06 +00:00
Alexander Potapenko c87794d055 [ASan] Delete asan_intercepted_functions.h, move the code into asan_interceptors.h
Fixes https://code.google.com/p/address-sanitizer/issues/detail?id=188.

llvm-svn: 198048
2013-12-26 15:34:31 +00:00
Kostya Serebryany 2b5fddbc75 [asan] allow asan to use SizeClassAllocator32 on a 64-bit platform (if SANITIZER_CAN_USE_ALLOCATOR64=0). No functionality change by default is intended
llvm-svn: 198044
2013-12-26 13:52:38 +00:00
Alexey Samsonov 23347de6ef [Sanitizer] Add Symbolizer::GetModuleNameAndOffsetForPC() and use it in LSan suppression matching.
This allows us to avoid retrieving file/line info for suppressed modules.

llvm-svn: 198025
2013-12-25 20:15:46 +00:00
Alexander Potapenko 9d989d6b05 [ASan] Add a test for __asan_gen_ globals labels on Darwin.
Per Nick Kledzik (http://llvm.org/bugs/show_bug.cgi?id=17976):
"""
For MacOSX, the labels in __cstring section should be 'L' labels, and the labels
in the __const section should be non-L or 'l' labels.  The later ('l') will cause
the linker to remove the label in the final executable.
"""

, so we need to ensure that the globals emitted by ASan have appropriate labels.

llvm-svn: 198022
2013-12-25 17:20:22 +00:00
Sergey Matveev 7eab734554 [lsan] Minor code health stuff.
- introduce logging macros
- fix incorrect vector construction

llvm-svn: 198021
2013-12-25 17:14:40 +00:00
Alexander Potapenko 4f0335f863 [ASan] Fix the test for __asan_gen_ globals and actually fix http://llvm.org/bugs/show_bug.cgi?id=17976
by setting the correct linkage (as stated in the bug).

llvm-svn: 198018
2013-12-25 16:46:27 +00:00
Alexander Potapenko daf96ae81b [ASan] Make sure none of the __asan_gen_ global strings end up in the symbol table, add a test.
This should fix http://llvm.org/bugs/show_bug.cgi?id=17976
Another test checking for the global variables' locations and prefixes on Darwin will be committed separately.

llvm-svn: 198017
2013-12-25 14:22:15 +00:00
Alexey Samsonov 782ad0eb71 [Sanitizer] Remove now unused symbolization functionality from MemoryMappingLayout
llvm-svn: 198014
2013-12-25 12:11:06 +00:00
Alexey Samsonov 5746c07629 [Sanitizer] Use different MemoryMappingLayout::DumpListOfModules on Linux and Mac.
Make a unit test added in r198004 more robust.

llvm-svn: 198012
2013-12-25 11:29:19 +00:00
Alexey Samsonov bf658026c1 [Sanitizer] Properly specify linux-only unit test.
llvm-svn: 198007
2013-12-25 09:31:42 +00:00
Alexey Samsonov ca7a213118 [Sanitizer] Don't use MemoryMappingLayout in StackTrace::PrintStack - it is now a responsibility of Symbolizer class.
llvm-svn: 198006
2013-12-25 09:29:54 +00:00
Alexey Samsonov ceeb0e0657 [TSan] fix Go build
llvm-svn: 198005
2013-12-25 08:56:08 +00:00
Alexey Samsonov 64ffa598ce [Sanitizer] Teach MemoryMappingLayout to dump all loaded modules.
Use this to implement GetListOfModules() on Mac and on Android
(on Linux we use dl_iterate_phdr).

llvm-svn: 198004
2013-12-25 08:39:38 +00:00
Alexey Samsonov 2f392d237c [Sanitizer] Move OS-specific code for MemoryMappingLayout into separate source files.
llvm-svn: 198003
2013-12-25 08:01:16 +00:00
Alexey Samsonov 6322e036aa [Sanitizer] Replace Symbolizer::IsAvailable and Symbolizer::IsExternalAvailable with Symbolizer::CanReturnFileLineInfo.
Remove now redundant checks in symbolizer initialization in TSan and MSan.

llvm-svn: 198000
2013-12-25 07:09:44 +00:00
Dmitry Vyukov 6971fef2f9 tsan: fix false positive in pthread stack manupulation
pthread uses internal cache, we do not see synchronization in it

llvm-svn: 197982
2013-12-24 14:38:12 +00:00
Dmitry Vyukov ce3721057d tsan: remove in_rtl counter
This is intended to address the following problem.
Episodically we see CHECK-failures when recursive interceptors call back into user code. Effectively we are not "in_rtl" at this point, but it's very complicated and fragile to properly maintain in_rtl property. Instead get rid of it. It was used mostly for sanity CHECKs, which basically never uncover real problems.
Instead introduce ignore_interceptors flag, which is used in very few narrow places to disable recursive interceptors (e.g. during runtime initialization).

llvm-svn: 197979
2013-12-24 12:55:56 +00:00
Sergey Matveev 27aea0b0b7 [lsan] Refactor the LeakReport class.
Those methods were too damn bloated.

llvm-svn: 197978
2013-12-24 12:42:15 +00:00
Sergey Matveev 625875d256 [lsan] Make the report_objects flag more useful.
Print the list of leaked objects after each leak report. Previously we
printed only a joint list of all leaked objects. As a bonus, suppressed objects
are no longer reported.

llvm-svn: 197977
2013-12-24 12:03:02 +00:00
Dmitry Vyukov d8540f7e82 tsan: deflake another test
llvm-svn: 197965
2013-12-24 07:49:33 +00:00
Kostya Serebryany 6f69c73db1 [asan] clean up at the end of the shmget/shmctl test
llvm-svn: 197901
2013-12-23 07:32:23 +00:00
Kostya Serebryany a650116adb [asan] convert a CHECK failure in __sanitizer_annotate_contiguous_container into a proper warning message
llvm-svn: 197899
2013-12-23 07:01:43 +00:00
Evgeniy Stepanov 09021e02bc [msan] Add missing visibility attribute to MSan new/delete interceptors.
llvm-svn: 197809
2013-12-20 13:18:07 +00:00
Evgeniy Stepanov 42cebb00da [sanitizer] Use the new sanitizer_interception.h header in all interceptors.
llvm-svn: 197808
2013-12-20 13:17:31 +00:00
Evgeniy Stepanov 3d0edea4e1 [sanitizer] Add missing file comment.
llvm-svn: 197807
2013-12-20 13:13:49 +00:00
Evgeniy Stepanov 66297cac72 [msan] Wrap indirect calls to REAL(x) in interceptors.
llvm-svn: 197806
2013-12-20 12:20:15 +00:00
Evgeniy Stepanov 61628196e4 [msan] Replace wrap_indirect_calls runtime flag with an interface method.
llvm-svn: 197799
2013-12-20 11:05:19 +00:00
Alexey Samsonov f2c7659cf8 [ASan] Get rid of ASan-specific functions for printing stack traces
llvm-svn: 197672
2013-12-19 11:25:05 +00:00
Alexey Samsonov 3efe401db0 [Sanitizer] Delete unused StackTrace::PrintStack argument
llvm-svn: 197671
2013-12-19 11:14:26 +00:00
Alexey Samsonov cef2e14382 [ASan] Get rid of __asan_symbolize function
llvm-svn: 197670
2013-12-19 11:08:47 +00:00
Evgeniy Stepanov 3a28dc7158 Fix -Werror compilation.
It was broken in r197601.

llvm-svn: 197665
2013-12-19 08:57:24 +00:00
Lorenzo Martignoni f073541819 [DFSan] New custom wrappers
Added the following custom wrappers:
  strstr
  strrchr
  memchr
  nanosleep
  socketpair

Tweaked a couple of existing wrappers: if a wrapper returns a pointers derived
from an input pointer, then return the label of the input pointer

Sorted tests invocation

Differential Revision: D2354

llvm-svn: 197601
2013-12-18 19:25:34 +00:00
Timur Iskhodzhanov caf7c0cdcd [Sanitizers] Fix CL compile-time warning in the symbolizer
llvm-svn: 197573
2013-12-18 14:39:23 +00:00
Timur Iskhodzhanov 1c84bd64db [Sanitizer] Implement Symbolizer class on Windows
llvm-svn: 197571
2013-12-18 14:29:16 +00:00
Timur Iskhodzhanov b5f983e4b0 [Sanitizers] Rename Symbolizer::SymbolizeCode to Symbolizer::SymbolizePC
llvm-svn: 197569
2013-12-18 14:17:39 +00:00
Evgeniy Stepanov a164bf5e89 [msan] Disable DynamoRio detection.
This code is not robust enough and triggers when simply linking with
libdynamorio.so, without any code translation at all. Disabling it is safe
(i.e. we may unpoison too much memory and see false negatives, but never false
positives).

llvm-svn: 197568
2013-12-18 13:25:45 +00:00
Sergey Matveev 149b794ec6 [lsan] Remove the LSan-specific verbosity flag.
It conflicted with the verbosity flag we had in common flags. We don't need an
LSan-specific flag anyway.

Also, shift some logging levels and remove some unnecessary code.

llvm-svn: 197512
2013-12-17 18:18:32 +00:00
Sergey Matveev b5769dbb86 [lsan] Introduce print_suppressions flag.
Introduce a flag to either always or never print matched suppressions.
Previously, matched suppressions were printed unconditionally if there were
unsuppressed leaks. Also, verbosity=1 no longer has the semantics of "always
print suppressions and summary".

llvm-svn: 197510
2013-12-17 18:01:45 +00:00
Alexey Samsonov 33a2cc1e10 Fix gen_dynamic_list.py for Python 3. Patch by Marcoen Hirschberg.
llvm-svn: 197493
2013-12-17 12:19:16 +00:00
Alexey Samsonov 25d010a98d [Sanitizer] Always initialize a Symbolizer (even if 'symbolize' is false).
If 'symbolize' flag is not set, we still want to transform virtual address
to module+offset pair in the call to Symbolizer::SymbolizeCode().
See https://code.google.com/p/address-sanitizer/issues/detail?id=251 for
more details.

llvm-svn: 197491
2013-12-17 11:15:39 +00:00
Sergey Matveev 7237879926 [lsan] Introduce __lsan_(un)register_root_region().
Add an interface for telling LSan that a region of memory is to be treated as a
source of live pointers. Useful for code which stores pointers in mapped memory.

llvm-svn: 197489
2013-12-17 11:11:23 +00:00
Alexey Samsonov 5069790b24 [LSan] Add a real test for suppressions file instead of duplicated test case.
llvm-svn: 197488
2013-12-17 11:02:52 +00:00
Evgeniy Stepanov 59bb0878e2 [msan] Tweak gethostbyname_r interceptor some more.
This is covered by msan_test depending on glibc version and/or resolver setup.

llvm-svn: 197484
2013-12-17 09:13:54 +00:00
Evgeniy Stepanov cb98c5f6f0 [msan] Relax gethostbyname_r test condition.
Apparently, its return value depends on the glibc version.

llvm-svn: 197390
2013-12-16 15:01:31 +00:00
Evgeniy Stepanov 43fc44007d [msan] Fix gethostbyname_r and similar interceptors.
*h_errno is written not on success, but on failure.
In fact, it seems like it can be written even when return value signals
success, so we just unpoison it in all cases.

llvm-svn: 197383
2013-12-16 13:24:33 +00:00
Kostya Serebryany 4eaa0492ca [asan] fix the test so that it works even if stack size is unlimited by default
llvm-svn: 197372
2013-12-16 09:09:31 +00:00
Kostya Serebryany 1aedf6c9e6 [asan] replace the flag uar_stack_size_log with two flags min_uar_stack_size_log/max_uar_stack_size_log
llvm-svn: 197370
2013-12-16 08:42:08 +00:00
Evgeniy Stepanov 3158ec4002 [msan] Fix strncat interceptor, add missing tests.
llvm-svn: 197244
2013-12-13 16:31:59 +00:00
Kostya Serebryany 57bfdb080b [asan] add flag uar_noreserve to use noreserve mmap for fake stack. uar_noreserve=1 will save some memory but also negatively affect performance
llvm-svn: 197233
2013-12-13 15:03:49 +00:00
Evgeniy Stepanov a643a754be [sanitizer] Disable call wrapping when building for Go.
llvm-svn: 197232
2013-12-13 14:58:21 +00:00
Evgeniy Stepanov 879c552dd9 [msan] Wrap indirect calls from sanitizer rtl when running under DR.
llvm-svn: 197226
2013-12-13 13:13:46 +00:00
Evgeniy Stepanov c8ccef49cc [msan] Add a check for recursive __msan_init.
llvm-svn: 197218
2013-12-13 09:11:14 +00:00
Evgeniy Stepanov 86d8fb5ba1 [msan] Clean stack and TLS shadow on thread exit.
llvm-svn: 197156
2013-12-12 13:48:47 +00:00
Kostya Serebryany e55d388e71 [asan] when a fake stack is being unmapped also flush the corresponding shadow
llvm-svn: 197040
2013-12-11 14:26:41 +00:00
Kostya Serebryany 7a3a93f112 [asan] if verbosity>=2, print the fake stack usage stats at thread exit; No functionality change in non-verboze mode
llvm-svn: 197037
2013-12-11 13:54:01 +00:00
Evgeniy Stepanov 9fc2b966ac [msandr] Remove one more use of std::string and put all STL headers under ifdef.
llvm-svn: 197031
2013-12-11 11:38:49 +00:00
Evgeniy Stepanov 88adc5e815 [msandr] Remove std::string in dr_init for optimized hybrid execution.
Patch by Qin Zhao.

llvm-svn: 197029
2013-12-11 11:36:05 +00:00
Tim Northover 638a424b56 Only build embedded darwin variants if the compiler supports them
We need to filter out architectures that the compiler hasn't been built to
target (most likely the ARM ones) before attemptint to build a version of
libcompiler_rt.

This can result in a completely empty library (e.g. soft-float doesn't have any
x86 variants), in which case we shouldn't even try the build

llvm-svn: 197028
2013-12-11 11:25:53 +00:00
Evgeniy Stepanov cd07898cf8 [msan] Get stack limits with pthread_create interceptor.
Before we did it lazily on the first stack unwind in the thread.
It resulted in deadlock when the unwind was caused by memory allocation
inside pthread_getattr_np:
  pthread_getattr_np   <<< not reentable
  GetThreadStackTopAndBottom
  __interceptor_realloc
  pthread_getattr_np
  

llvm-svn: 197026
2013-12-11 10:55:42 +00:00
Alexey Samsonov 4fc8098979 [TSan] Move declarations of __tsan_atomic functions to a public header
llvm-svn: 197015
2013-12-11 08:18:50 +00:00
Alexey Samsonov 2424dfa688 [TSan] Replace __tsan::OverrideFlags with __tsan::OnInitialize
llvm-svn: 197014
2013-12-11 07:31:36 +00:00
Matt Arsenault d326252d29 Fix minor gcc warnings.
C++ style comments not allowed in C90,
signed unsigned comparision.

llvm-svn: 196948
2013-12-10 19:05:43 +00:00
Kostya Serebryany b00a0e2971 [asan] relax HugeMallocTest so that it does not fail on small-RAM machines
llvm-svn: 196904
2013-12-10 10:34:55 +00:00
Kostya Serebryany b2eb3d3177 [asan] remove one test from SizedStackTest which relied on a now-wrong assumption that the left stack redzone is >= 32 bytes (PR18195)
llvm-svn: 196900
2013-12-10 09:49:31 +00:00
Timur Iskhodzhanov 89a346c2a1 [ASan] Fix StackTrace::SlowUnwindStack on Windows
llvm-svn: 196894
2013-12-10 08:30:39 +00:00
Chandler Carruth 3f697191bb Revert a final patch that was committed without the author contributing
it to the LLVM project through the appropriate channels.

This reverts:
r195837: "[Sanitizer] Add rudimentary support for using libbacktrace in ..."

llvm-svn: 196875
2013-12-10 04:40:39 +00:00
Richard Smith ab788cdc81 Unbreak build by adding an implementation of PopStackFrames function.
llvm-svn: 196809
2013-12-09 19:52:39 +00:00
Chandler Carruth 736f9fd229 Revert three patches which were committed without explicit contribution
by their authors.

This may break builds where others added code relying on these patches,
but please *do not* revert this commit. Instead, we will prepare patches
which fix the failures.

Reverts the following commits:
r168306: "[asan] support x32 mode in the fast stack unwinder. Patch by H.J. Lu"
r168356: "[asan] more support for powerpc, patch by Peter Bergner"
r196489: "[sanitizer] fix the ppc32 build (patch by Jakub Jelinek)"

llvm-svn: 196802
2013-12-09 19:25:51 +00:00