Commit Graph

3272 Commits

Author SHA1 Message Date
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
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
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
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 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
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
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
Will Dietz 3177a7f38a ubsan: Fix typo in 'TypeCheck/vptr.cpp' test to resolve 32bit failure.
llvm-svn: 196799
2013-12-09 19:04:33 +00:00
Sergey Matveev 47b02994f1 Fix Windows build.
llvm-svn: 196780
2013-12-09 13:24:44 +00:00
Alexey Samsonov 9f6218bf44 PR17977: don't assume EOWNERDEAD is always defined
Summary: See details in http://llvm.org/bugs/show_bug.cgi?id=17977

Reviewers: dvyukov

Reviewed By: dvyukov

CC: glider, llvm-commits

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

llvm-svn: 196779
2013-12-09 13:21:43 +00:00
Sergey Matveev b1b8d1aa47 [lsan] Make LSan ignore memory poisoned by ASan.
Summary:
No more (potenital) false negatives due to red zones or fake stack
frames.

Reviewers: kcc, samsonov

Reviewed By: samsonov

CC: llvm-commits, samsonov

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

llvm-svn: 196778
2013-12-09 13:12:10 +00:00
Will Dietz 186507dac6 Fix integer tests on platforms where uint64_t is 'unsigned long long'.
llvm-svn: 196612
2013-12-06 21:49:18 +00:00
Kostya Serebryany 3429f78289 [asan] in SizedStackTest check the death string, also restrict one of the checks to 64-bit
llvm-svn: 196576
2013-12-06 09:33:36 +00:00
Evgeniy Stepanov 67bbf967b0 [msan] Allow strlen() (and similar functions) of shadow memory.
llvm-svn: 196572
2013-12-06 09:19:07 +00:00
Kostya Serebryany cab32309f8 [asan] rewrite asan's stack frame layout, compiler-rt part
llvm-svn: 196569
2013-12-06 09:00:25 +00:00
Alexey Samsonov 5ca3de6e91 PR16532: work around old GCC bug in interception_type_test.cc
llvm-svn: 196506
2013-12-05 13:29:46 +00:00
Alexey Samsonov 2d42b1d693 Run TSan/MSan lit tests only on 64-bit platforms
llvm-svn: 196501
2013-12-05 12:53:36 +00:00
Sergey Matveev 9be70fbda9 [sanitizer] Introduce VReport and VPrintf macros and use them in sanitizer code.
Instead of "if (common_flags()->verbosity) Report(...)" we now have macros.

llvm-svn: 196497
2013-12-05 12:04:51 +00:00
Kostya Serebryany 3b2f702d55 [tsan] fix the old tsan Makefile to build the asm files with includes
llvm-svn: 196495
2013-12-05 11:24:06 +00:00
Alexey Samsonov 58e44a3447 Revert r196490 and fix include paths in makefile-based build
llvm-svn: 196492
2013-12-05 10:40:11 +00:00
Kostya Serebryany d4af5c241d [asan] revert files which I accidentally commited in r196490
llvm-svn: 196491
2013-12-05 09:47:21 +00:00
Kostya Serebryany 9ffa232f06 [tsan] fix the include path that is broken in configure/make build but works in cmake build (PR18144). This is a quick fix. Will need to fix the configure/make build properly
llvm-svn: 196490
2013-12-05 09:42:59 +00:00
Kostya Serebryany f2c93b2973 [sanitizer] fix the ppc32 build (patch by Jakub Jelinek)
llvm-svn: 196489
2013-12-05 08:51:48 +00:00
Kostya Serebryany 14e92c2c62 [sanitizer] support toolchains that don't understand CFI directives
Summary: Support toolchains that don't understand CFI directives.

Reviewers: dvyukov

Reviewed By: dvyukov

CC: llvm-commits

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

llvm-svn: 196480
2013-12-05 07:44:35 +00:00
Lorenzo Martignoni 65550a5dd1 [DFSan] Extend the ABI list to discard new glibc functions
Differential Revision: http://llvm-reviews.chandlerc.com/D2291

llvm-svn: 196389
2013-12-04 16:53:10 +00:00
Lorenzo Martignoni dc601d8f3a [DFSan] Change the way labels are propagated when comparing memory through libc functions.
Differential Revision: http://llvm-reviews.chandlerc.com/D2252

llvm-svn: 196388
2013-12-04 16:48:09 +00:00
Sergey Matveev 7bc300c8fc [sanitizer] Fix log_path behavior with StopTheWorld.
Summary:
Fix race on report_fd/report_fd_pid between the parent process and the
tracer task.

Reviewers: samsonov

Reviewed By: samsonov

CC: llvm-commits, kcc, dvyukov

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

llvm-svn: 196385
2013-12-04 14:37:01 +00:00
Timur Iskhodzhanov b8c367b49d [ASan] Use 'extern "C"' rather than 'extern' for global variables exposed in the interface
llvm-svn: 196379
2013-12-04 12:51:42 +00:00
Kostya Serebryany 5b66bad259 [asan] require __i686__ for the SSE test; also make weaker claims about stack buffer overflows in another test
llvm-svn: 196375
2013-12-04 10:48:16 +00:00
Kostya Serebryany 32b0b21790 [asan] revert 196373: committed to many files by mistake
llvm-svn: 196374
2013-12-04 10:47:14 +00:00
Kostya Serebryany 0060391a63 [asan] require __i686__ for the SSE test; also make weaker claims about stack buffer overflows in another test
llvm-svn: 196373
2013-12-04 10:44:13 +00:00
Alexey Samsonov e958f9e480 [ASan] Return interface attribute to __sanitizer_print_stack_trace
llvm-svn: 196364
2013-12-04 08:17:45 +00:00
Yuchen Wu a5de343c79 compiler-rt: Added support for function checksums.
llvm-svn: 196357
2013-12-04 06:00:04 +00:00
Sergey Matveev 12d2143dbc [asan] Fix build error.
llvm-svn: 196303
2013-12-03 18:44:50 +00:00
Sergey Matveev d8fb4d8f91 [sanitizer] Expose __sanitizer_print_stack_trace().
Expose a new interface function for debugging code built with sanitizer tools.
Add an ASan implementation.

llvm-svn: 196302
2013-12-03 18:24:28 +00:00
Joerg Sonnenberger 24f4a7dbec For libkern and libsa on NetBSD, the normal system headers can't be
used. Adjust.

llvm-svn: 196292
2013-12-03 16:19:14 +00:00
Alexey Samsonov 907eb5b630 [Sanitizer] Use more appropriate InternalScopedString in GetCodeRangeForFile
llvm-svn: 196264
2013-12-03 09:29:23 +00:00
Alexey Samsonov 8dd33a27c3 [Sanitizer] Fix a bug introduced in r196112. Add a test.
llvm-svn: 196263
2013-12-03 09:21:08 +00:00
Sergey Matveev b748d46019 [sanitizer] Allow InternalMmapVector construction with zero capacity.
llvm-svn: 196112
2013-12-02 15:41:04 +00:00
Evgeniy Stepanov c0378e72d1 [sanitizer] Intercept textdomain.
Patch by Alexander Taran.

llvm-svn: 196098
2013-12-02 13:43:26 +00:00
Kostya Serebryany 5236c79932 [asan] disable AddressSanitizer.HugeMallocTest if ASAN_AVOID_EXPENSIVE_TESTS is set
llvm-svn: 196097
2013-12-02 13:22:27 +00:00
Kostya Serebryany dc58090213 [asan] dump coverage even if asan has reported an error
llvm-svn: 195959
2013-11-29 14:49:32 +00:00
Kostya Serebryany 5774faf5b0 [sanitizer] disable shmctl intercetor in 32-bit -- it is rotten (bug filed)
llvm-svn: 195958
2013-11-29 14:09:13 +00:00
Timur Iskhodzhanov 5ca41e3800 Increase the LocatePcInTrace PC threshold now that GET_STACK_TRACE_WITH_PC_AND_BP has grown
llvm-svn: 195957
2013-11-29 13:15:25 +00:00
Timur Iskhodzhanov a10c46f2ae Fix current stack unwinding when using DRASan
llvm-svn: 195956
2013-11-29 12:53:30 +00:00
Timur Iskhodzhanov bbf2ff8193 [ASan] Also print <empty stack> when size==0
llvm-svn: 195955
2013-11-29 12:08:59 +00:00
Evgeniy Stepanov f2cddc3e64 [sanitizer] Disable iconv interceptor in OSX.
iconv is defined in an optional DSO, and our interception logic on OSX does not
support that.

llvm-svn: 195919
2013-11-28 14:42:59 +00:00
Evgeniy Stepanov b56c5cd95e [sanitizer] Intercept times.
llvm-svn: 195918
2013-11-28 14:41:22 +00:00
Evgeniy Stepanov 9c1f8323ae [sanitizer] Intercept iconv.
llvm-svn: 195917
2013-11-28 14:14:48 +00:00
Dmitry Vyukov 25ecfcf00c tsan: deflake more tests
llvm-svn: 195916
2013-11-28 10:12:16 +00:00
Dmitry Vyukov 8d1eb705c7 tsan: add support for passing file descriptors over UNIX domain sockets
tsan was missing new fd's arrived from recvmsg(),
and thus was reporting false positives due to missed synchronization on the fd's

llvm-svn: 195914
2013-11-28 09:09:42 +00:00
Dmitry Vyukov 0fea3ad0c7 tsan: deflake more tests
llvm-svn: 195913
2013-11-28 09:06:55 +00:00
Dmitry Vyukov c03868615b tsan: clarify "thread ended with ignores enabled" message
llvm-svn: 195858
2013-11-27 18:23:52 +00:00
Timur Iskhodzhanov c085e99385 Add a DLL thunk for __asan_handle_no_return
llvm-svn: 195845
2013-11-27 14:36:44 +00:00
Alexey Samsonov e0e31c4a30 [ASan] Clarify that AsanThread objects are allocated only via mmap(). No functionality change.
llvm-svn: 195840
2013-11-27 13:22:21 +00:00
Evgeniy Stepanov b76b687628 [sanitizer] Intercept __xpg_strerror_r.
llvm-svn: 195839
2013-11-27 12:29:10 +00:00
Lorenzo Martignoni 085bf66e60 Added missing lib/dfsan/scripts/check_custom_wrappers.sh
llvm-svn: 195838
2013-11-27 11:50:44 +00:00
Alexey Samsonov 1c256cbcc4 [Sanitizer] Add rudimentary support for using libbacktrace in symbolizer.
More steps are needed to actually make it usable:
* sanitizer runtimes should be compiled with -DSANITIZER_LIBBACKTRACE.
* libbacktrace headers should be installed.
* user has to manually link in libbacktrace.a into the executable.

We can easily solve the first two problems in the build system, but
detecting/linking libbacktrace to all the tests we have and end-user programs
is more challenging (and will unlikely work w/o Driver support).

Based on the patch by Jakub Jelinek!

llvm-svn: 195837
2013-11-27 11:46:58 +00:00
Dmitry Vyukov 3238e1c913 tsan: better diagnostics if thread finishes with ignores enabled
print thread creation stack
and stacks where ignores were enabled.

llvm-svn: 195836
2013-11-27 11:30:28 +00:00
Dmitry Vyukov 44be414d69 asan: fix android build
android does not seem to have IOCB_CMD_PREADV

llvm-svn: 195835
2013-11-27 11:20:55 +00:00
Dmitry Vyukov 89117e1fcc tsan: do not leave verbosity>0 in tests
llvm-svn: 195833
2013-11-27 10:05:22 +00:00
Dmitry Vyukov 51b35901fd tsan: minor refactoring
use common helper macro

llvm-svn: 195832
2013-11-27 09:59:11 +00:00
Dmitry Vyukov 7bd319cc08 tsan: fix flags parsing
- running_on_valgrind was not parsed in some contexts
- refactor code a bit
- add comprehensive tests for flags parsing

llvm-svn: 195831
2013-11-27 09:54:10 +00:00
Dmitry Vyukov ee882ba4a1 tsan: support synchronization by means of linux aio
http://llvm-reviews.chandlerc.com/D2269

llvm-svn: 195830
2013-11-27 09:10:47 +00:00
Alexey Samsonov d5144879f9 [Sanitizer] Improve external symbolizer behavior.
1) Don't start external symbolizer subprocess until we actually try to
   symbolize anything.
2) Allow to turn off external symbolizer by providing empty ?SAN_SYMBOLIZER_PATH
   environment variable.

llvm-svn: 195771
2013-11-26 16:24:53 +00:00
Lorenzo Martignoni 895454e1e4 Implement a bunch of custom glibc wrappers & corresponding tests
llvm-svn: 195749
2013-11-26 11:45:58 +00:00
Timur Iskhodzhanov 895392d03f [ASan] Use ExitProcess rather than _exit on Windows to avoid calling global dtors etc
llvm-svn: 195723
2013-11-26 09:40:39 +00:00
Peter Collingbourne 4184a471f2 build-libc-list.py: Replace --{,usr,gcc}lib with flags for specific libraries.
This should allow us to cope with newer versions of GCC (and more esoteric
directory layouts).

llvm-svn: 195695
2013-11-25 23:50:05 +00:00
Sergey Matveev 5170bca73c [lsan] Unbreak lsan_testlib.cc.
Also, add missing logging output.

llvm-svn: 195652
2013-11-25 15:54:31 +00:00
Alexey Samsonov c700e76278 [UBSan] Fix warning by specifying __extension__ before __int128
llvm-svn: 195648
2013-11-25 15:12:40 +00:00
Dmitry Vyukov 8cb7d46d98 tsan: filter out more bogus fd values
people do close(sysconf(_SC_OPEN_MAX)) after fork, where _SC_OPEN_MAX=1200000.

llvm-svn: 195645
2013-11-25 14:53:29 +00:00
Sergey Matveev 6b0f6af374 [lsan] Add a missing file.
llvm-svn: 195643
2013-11-25 14:30:37 +00:00
Sergey Matveev 2d3f8d7840 [lsan] Unbreak standalone LSan's initialization by making it more like ASan's.
No longer allow interceptors to be called during initialization, use the preinit
array (instead of initializing at the first call to an intercepted function) and
adopt the calloc() hack from ASan.

llvm-svn: 195642
2013-11-25 14:25:36 +00:00
Kostya Serebryany ccfc0481f1 [sanitizer] Implement TwoLevelByteMap and use it for the internal allocator on 64-bit.
Summary:
Implement TwoLevelByteMap and use it for the internal allocator on 64-bit.
This reduces bss on 64-bit by ~8Mb because we don't use FlatByteMap on 64-bits any more.

Dmitry, please check my understanding of atomics.

Reviewers: dvyukov

Reviewed By: dvyukov

CC: samsonov, llvm-commits

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

llvm-svn: 195637
2013-11-25 11:33:41 +00:00
Timur Iskhodzhanov 0d419293e2 [ASan] Follow-up fix: use #if SANITIZER_WINDOWS, not #ifdef
llvm-svn: 195625
2013-11-25 07:56:05 +00:00
Timur Iskhodzhanov 25cc3c55cc [ASan] Un-break the Windows build
llvm-svn: 195624
2013-11-25 07:54:55 +00:00
Sergey Matveev 634a75b63e [sanitizer] Do not clear memory which comes from secondary allocator.
Secondary allocator is mmap-based, so the memory is already zeroed.

llvm-svn: 195571
2013-11-24 14:45:38 +00:00
Sergey Matveev 10548681c0 [lsan] Use real memset to clear memory in standalone LSan.
Performance improvement. Also, the allocator was using CompactSizeClassMap for
no good reason, so I switched it to DefaultSizeClassMap.

llvm-svn: 195570
2013-11-24 14:28:18 +00:00
Kostya Serebryany a2fde9484f [sanitizer] use 16-byte aligned bzero in performance critical place (mostly for lsan)
llvm-svn: 195549
2013-11-23 12:49:19 +00:00
Alexander Potapenko 32474d6226 [ASan] Fix large_allocator_unpoisons_on_free.cc to pass correct parameters to mmap() on OSX.
llvm-svn: 195443
2013-11-22 11:19:28 +00:00
Evgeniy Stepanov 8f944b6672 [sanitizer] Fix kernel headers compatibility on powerpc64.
llvm-svn: 195442
2013-11-22 11:01:43 +00:00
Kostya Serebryany b1118e5952 Call real pthread_attr_getstack instead of the interceptor
Summary:
Call real pthread_attr_getstack instead of the interceptor
when we do intercept pthread_attr_getstack.

Reviewers: samsonov, eugenis

Reviewed By: samsonov

CC: llvm-commits

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

llvm-svn: 195441
2013-11-22 10:44:31 +00:00
Evgeniy Stepanov db643d7678 [sanitizer] Add kernel_stat definitions for arm.
llvm-svn: 195436
2013-11-22 10:09:34 +00:00
Evgeniy Stepanov f3aa5b5257 [sanitizer] Restore perf_event_attr handling.
This time in a forward/backward compatible way.

llvm-svn: 195434
2013-11-22 09:32:39 +00:00
Evgeniy Stepanov c53407de3c [sanitizer] Fix build.
llvm-svn: 195433
2013-11-22 09:26:10 +00:00
Evgeniy Stepanov 39cc337e20 [sanitizer] Change the way we use certain linux kernel headers.
Some linux headers are broken on older kernels.
Instead of depending on the constants and types from such headers directly,
we provide our own definitions and then verify them with compile-time
assertions. This makes the dependency on the headers test-only and would allow
switching to some other way of testing on older kernels, or even disable the
tests as the last resort (after all, kernel interfaces are supposed to be
stable).

llvm-svn: 195427
2013-11-22 09:01:50 +00:00
Evgeniy Stepanov fe8ed4a591 [sanitizer] Add missing header dependencies.
llvm-svn: 195425
2013-11-22 08:55:33 +00:00
Peter Collingbourne f09d5d03fd Revert r195381, "Implement a bunch of custom glibc wrappers & corresponding tests."
It broke a buildbot.

llvm-svn: 195392
2013-11-21 23:48:19 +00:00
Peter Collingbourne 0a14a71061 Implement a bunch of custom glibc wrappers & corresponding tests.
- Introduce several new custom glibc wrappers
- Implement some of the not yet implemented wrappers
- Refactor and extend the tests
- Add script to make sure all declare custom glibc wrappers are implemented & tested.

Patch by Lorenzo Martignoni!

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

llvm-svn: 195381
2013-11-21 23:18:03 +00:00
Kostya Serebryany 67968632ba [asan] rename contiguous-container-buffer-overflow (too long) to container-overflow
llvm-svn: 195352
2013-11-21 12:23:52 +00:00
Dmitry Vyukov 5f1a783914 tsan: deflake tests
the tests produce episodic flakes
the hypothesis is that it's due to our "racy" race detection algorithm
sleeps should remove the flakes

llvm-svn: 195351
2013-11-21 12:23:17 +00:00
Evgeniy Stepanov 1bdf5c93e1 [msan] Test for r195349.
llvm-svn: 195350
2013-11-21 12:01:07 +00:00
Dmitry Vyukov 70fcec46e9 tsan: remove debug output from test
llvm-svn: 195347
2013-11-21 11:50:45 +00:00
Dmitry Vyukov 5fa72d4c3f tsan: add -lm to output test build script
as common sanitizer interceptors now require it

llvm-svn: 195346
2013-11-21 11:49:08 +00:00
Dmitry Vyukov 4ca8ee692e tsan: fix handling of setjmp
It's incorrect to take address of setjmp,
because it may not (ligally) present in libc.
Fixes http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59188

llvm-svn: 195345
2013-11-21 11:48:29 +00:00
Kostya Serebryany 53c51a1675 [tsan] use FileCheck in race_on_speculative_load.cc
llvm-svn: 195331
2013-11-21 09:09:47 +00:00
Kostya Serebryany 95f3e54066 [tsan] add a run-time-side regression test for https://code.google.com/p/thread-sanitizer/issues/detail?id=40 (tsan-hostile load speculation)
llvm-svn: 195325
2013-11-21 07:31:12 +00:00
Evgeniy Stepanov 3e29c6bf22 [asan] Fix OSX tests.
llvm-svn: 195250
2013-11-20 14:21:56 +00:00
Evgeniy Stepanov 0958ecca7e [msan] Tweak io_submit syscall hook.
llvm-svn: 195246
2013-11-20 13:04:23 +00:00
Evgeniy Stepanov 584fd96e9e [msan] Unpoison memory that is returned to the OS and flush its shadow.
llvm-svn: 195244
2013-11-20 12:51:14 +00:00
Evgeniy Stepanov 115ef14548 [asan] Test that LargeAllocator unpoisons memory before releasing it to the OS.
llvm-svn: 195243
2013-11-20 12:49:53 +00:00
Yuchen Wu ea7611c53c compiler-rt: Support for file checksum in GCDAProfiling.cpp.
Takes file checksum as an argument to write to .gcda file.

llvm-svn: 195190
2013-11-20 04:14:48 +00:00
Dmitry Vyukov 2918b67029 tsan: fix WTFAnnotateBenignRaceSized annotation
actually use the passed size

llvm-svn: 195133
2013-11-19 16:03:15 +00:00
Kostya Serebryany 3771a3dd73 [asan] remove a fixed FIXME; extend the comment around __sanitizer_annotate_contiguous_container
llvm-svn: 195131
2013-11-19 14:54:14 +00:00
Evgeniy Stepanov bfb2016c83 [msan] Fix origin tracking in unaligned load/store.
llvm-svn: 195130
2013-11-19 14:47:56 +00:00
Kostya Serebryany 7b664299f0 [asan] new shadow poison magic for contiguous-container-buffer-overflow, addressed Alexey Samsonov's comments for r195011
llvm-svn: 195117
2013-11-19 08:40:07 +00:00
Peter Collingbourne 01b337dc2d [dfsan] Tweaks for the ABI list
- Add a bunch of glibc functions to the ABI list
- Group similar functions in the ABI

Patch by Lorenzo Martignoni!

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

llvm-svn: 195110
2013-11-19 06:33:13 +00:00
Alexey Samsonov 59243333de [ASan] Run one of UAS tests in UAR mode as well
llvm-svn: 195015
2013-11-18 14:54:50 +00:00
Kostya Serebryany 60ecf38133 [asan] fix Windows build
llvm-svn: 195012
2013-11-18 14:26:13 +00:00
Kostya Serebryany 3d97c2040d [asan] introduce __sanitizer_annotate_contiguous_container
llvm-svn: 195011
2013-11-18 14:02:05 +00:00
Kostya Serebryany a92b07d684 [asan] support __hppa__ (by John David Anglin)
llvm-svn: 194995
2013-11-18 08:20:13 +00:00
Alexey Samsonov be9d20b7a9 [ASan] Build ASan on Windows only if MSVC is used
llvm-svn: 194963
2013-11-17 12:18:35 +00:00
Alexey Samsonov 5d3fda728d CMake: don't build sanitizer runtimes on 64-bit Windows (it's unsupported for now)
llvm-svn: 194958
2013-11-17 10:12:23 +00:00
Alexey Samsonov 4985d5274a [DFSan] Don't include public headers in dfsan runtime code
Summary:
Definitions we use in public sanitizer headers may
slightly conflict with the ones we use in private sanitizer runtimes.
Moreover, we generally forbid to include any system headers (like <stdint.h>)
in sanitizer runtime headers. This leads to inevitable duplication of selected
interface function declarations, but we decided to live with it.

Reviewers: pcc

Reviewed By: pcc

CC: kcc, llvm-commits

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

llvm-svn: 194955
2013-11-17 09:41:47 +00:00
Tim Northover 084647d4c0 Add clang_darwin_embedded platform for embedded projects
This should build a separate set of embedded runtime libraries, supporting the
option product:

    {PIC, static} x { Hard-float, soft-float }

The emphasis is on ARM platforms (Cortex-M4F, Cortex-M3, Cortex-M0) but X86
variants are also built where possible.

rdar://problem/10817205

llvm-svn: 194873
2013-11-15 23:00:42 +00:00
Bob Wilson 99d8fa92c3 Remove #include of net/ip_mroute.h for SANITIZER_MAC.
This header has not been supported at all for the last 2 major OS X releases.
Removed its include and the capture of related symbols.

<rdar://problem/15303348>

llvm-svn: 194841
2013-11-15 19:13:08 +00:00
Dmitry Vyukov 4bbe6dc8a9 tsan: add support for robust mutexes
llvm-svn: 194823
2013-11-15 16:58:12 +00:00
Kostya Serebryany b41503253b [asan] helper script to dump/merge coverage data
llvm-svn: 194809
2013-11-15 11:51:08 +00:00
Alexey Samsonov a6e8322fb1 [Sanitizer] Make slow unwinder on Linux more robust
llvm-svn: 194805
2013-11-15 10:57:56 +00:00
Dmitry Vyukov 0b76e408b4 tsan: add proper cfi directives to assembly code
this allows gdb to unwind through our hacky call

llvm-svn: 194803
2013-11-15 10:25:53 +00:00
Alexey Samsonov 352d0e52f5 Don't build unsupported compiler-rt pieces on Windows
llvm-svn: 194796
2013-11-15 09:09:23 +00:00
Bob Wilson a08e9ac927 Reapply asan coverage changes 194702-194704.
I still don't know what is causing our bootstrapped LTO buildbots to fail,
but llvm r194701 seems to be OK and I can't imagine that these changes could
cause the problem.

llvm-svn: 194790
2013-11-15 07:18:15 +00:00
Bob Wilson abc91eacac Speculatively revert asan coverage changes 194702-194704.
Apple's bootstrapped LTO builds have been failing, and these changes (along
with llvm 194701) are the only things on the blamelist.  I will either reapply
these changes or help debug the problem, depending on whether this fixes the
buildbots.

llvm-svn: 194779
2013-11-15 03:26:28 +00:00
Dmitry Vyukov 2e7e5801a7 asan: disable pthread_setname_np interceptor
it does not work anyway and can cause significant slowdown

llvm-svn: 194711
2013-11-14 16:48:22 +00:00
Kostya Serebryany c46f281f83 [asan] unbreak dfsan, which includes sanitizer/common_interface_defs.h into internal sources (although it shoudn't)
llvm-svn: 194704
2013-11-14 13:44:43 +00:00
Kostya Serebryany 599f0c1309 [asan] disable CovDump on Windows for now (fails to compile)
llvm-svn: 194703
2013-11-14 13:37:54 +00:00
Kostya Serebryany 91c52d9552 [asan] Poor man's coverage that works with ASan (compiler-rt part)
llvm-svn: 194702
2013-11-14 13:28:17 +00:00
Evgeniy Stepanov 5912fa4c4b [msan] A test for r194697.
llvm-svn: 194699
2013-11-14 12:31:18 +00:00
Alexey Samsonov 164841036d [UBSan] Make sure ASan and UBSan interact properly by running each test from UBSan test suite with and without ASan
llvm-svn: 194698
2013-11-14 12:30:09 +00:00
Alexey Samsonov 003c4bfc42 [ASan] Introduce a top-level target to collect all ASan runtimes and deps
llvm-svn: 194696
2013-11-14 12:24:12 +00:00
Alexey Samsonov 84dbdc0d8e [UBSan] Update UBSan location rendering to match r194686
llvm-svn: 194687
2013-11-14 09:54:10 +00:00
Alexey Samsonov 4d369187ec [Sanitizer] Print symbolized stack frame using a single Printf() call.
This reduces the number of "write" syscalls performed to print a single
stack frame description, and makes sanitizer output less intermixed with
program output. Also, add a number of unit tests.

llvm-svn: 194686
2013-11-14 09:41:24 +00:00
Alexey Samsonov 498e5906ad [Sanitizer] Add print_summary runtime flag to disable error summaries (UBSan doesn't need them)
llvm-svn: 194685
2013-11-14 08:56:59 +00:00
Alexander Potapenko 0706e5dd36 [ASan] Remove the stale dependency on the Foundation framework from the dynamic ASan runtime.
llvm-svn: 194583
2013-11-13 15:52:39 +00:00
Alexey Samsonov cf6ac12e23 [Sanitizer] Use same PC threshold in slow unwinder on all platforms
llvm-svn: 194580
2013-11-13 15:20:10 +00:00
Alexey Samsonov 9ff4598225 [ASan] Do not rely on malloc context in allocator reports.
Invoke a fatal stack trace unwinder when ASan prints allocator-relevant
error reports (double-free, alloc-dealloc-mismatch, invalid-free).
Thus we'll be able to print complete stack trace even if allocation/free
stacks are not stored (malloc_context_size=0).

Based on the patch by Yuri Gribov!

llvm-svn: 194579
2013-11-13 14:46:58 +00:00
Alexey Samsonov 41f7c404c9 [ASan] Use new feature of FileCheck: provide multiple --check-prefix args
llvm-svn: 194578
2013-11-13 14:16:40 +00:00
Alexander Potapenko fa82ba91f9 [ASan] Don't call __asan_init() from certain interceptors on Darwin.
Fixes http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58994, which hadn't
manifested in LLVM because libclang_rt.asan_osx_dynamic.dylib used to depend on
the Foundation framework.
Without that dependency some interceptors may be called from the system
libraries before libSystem_initializer() is called, which lead to assertion
failures in sanitizer_mac.cc (_NSGetEnviron() returns NULL).

To fix the problem we fall back to the original functions in the common
libsanitizer interceptors and the __cxa_atexit() interceptor on Darwin.

This patch also prints a better error message in the case _NSGetEnviron()
returns NULL.

llvm-svn: 194573
2013-11-13 13:34:53 +00:00
Kostya Serebryany 04a1767a2e [asan] fix a leak in tds (https://code.google.com/p/address-sanitizer/issues/detail?id=233)
llvm-svn: 194572
2013-11-13 13:27:44 +00:00
Yuchen Wu 61a1bfcd61 Added summary info to GCDAProfiling.
This function will be called by GCOVProfiling to write and update object
and program summaries to be read in by llvm-cov.

llvm-svn: 194499
2013-11-12 18:45:50 +00:00
Alexey Samsonov 6345150992 [Sanitizer] Specify a default value for each common runtime flag
llvm-svn: 194479
2013-11-12 13:59:08 +00:00
Evgeniy Stepanov 90e12a6cb2 [sanitizer] Avoid needless use of stringification (#symver) in INTERCEPT_FUNCTION_VER.
This is a workaround for clang-format bug (PR17874).

llvm-svn: 194468
2013-11-12 10:21:52 +00:00
Tim Northover 38a0cb5201 ARM: make assembly files compile Thumb2 with nop IT block.
ARM's UAL syntax allows the same assembly file to be compiled in both ARM and
Thumb mode. Conditional execution is handled by requiring the Thumb IT blocks,
but essentially ignoring them when compiling for ARM.

llvm-svn: 194429
2013-11-11 22:50:13 +00:00
Evgeniy Stepanov 5a29068b97 [msan] One more test for r194374.
llvm-svn: 194375
2013-11-11 13:38:24 +00:00
Evgeniy Stepanov b69699eb58 [sanitizer] Warn if interception fails.
This includes a clang-format pass over common interceptors.

llvm-svn: 194372
2013-11-11 11:28:30 +00:00
Evgeniy Stepanov bfdb9b2ec6 [msan] Sanity check for non-PIE.
llvm-svn: 194370
2013-11-11 09:27:20 +00:00
Evgeniy Stepanov 987f59b5c3 [asan] Bypass pthread_attr_getdetachstate interceptor in compiler_rt code.
llvm-svn: 194369
2013-11-11 08:56:49 +00:00
Timur Iskhodzhanov e87f5701bb Remove a FIXME now that I can't reproduce the problem
llvm-svn: 194331
2013-11-09 15:01:23 +00:00
Timur Iskhodzhanov 1f1c7ec400 [Sanitizers] Share some stack walking code between Windows and Linux
Reviewed at http://llvm-reviews.chandlerc.com/D2126

llvm-svn: 194326
2013-11-09 13:59:12 +00:00
Alexander Potapenko 49034e3c33 [ASan] Add CMake configs for libclang_rt.asan_iossim_dynamic.dylib
CMake changes to build the ASan runtime for the iOS simulator. This is a universal library targeting the same architectures as the OSX ASan runtime does, thus the iossim version can't live in the same universal libclang_rt.asan_osx_dynamic.dylib

The difference between the OSX and iossim builds is in the -mios-simulator-version-min and -ios_simulator_version_min flags that tell Clang to compile and link iossim code.

The iossim runtime can only be built on a machine with both Xcode and the iOS Simulator SDK installed. If xcodebuild -version -sdk iphonesimulator Path returns a nonempty path, it is used when compiling and linking the iossim runtime.

llvm-svn: 194199
2013-11-07 10:08:19 +00:00
Alexey Samsonov b3d939902a [Sanitizer] Make StackTrace::Unwind the only public way to unwind a stack trace.
llvm-svn: 194196
2013-11-07 07:28:33 +00:00