Commit Graph

3426 Commits

Author SHA1 Message Date
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
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
Duncan P. N. Exon Smith 2f234f4908 Fixing ordering of definition of IOSSIM_SDK_PATH
llvm-svn: 195216
2013-11-20 05:36:52 +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
Alexander Potapenko 2b00289bd6 [ASan] Use -isysroot instead of -Wl,-syslibroot to link the ASan iossim runtime
(-Wl,-syslibroot was accidentally overridden by -isysroot from Clang on OSX 10.9)

-isysroot is a Clang/LLVM-GCC-specific option, but hosting libsanitizer for LLVM
with GCC on Darwin shouldn't work anyway, because of the missing blocks support.

llvm-svn: 195132
2013-11-19 14:58:42 +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
Alexander Potapenko 9ff321d18d [ASan] Don't put asan_iossim_dynamic in the list of configurations to build
if the iOS Simulator SDK is missing on the machine.

llvm-svn: 195125
2013-11-19 13:24:29 +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
Alexey Samsonov 1011fe6a6e CMake: make sure compiler-rt headers are copied to build tree if 'compilrer-rt' target is built
llvm-svn: 195002
2013-11-18 10:57:36 +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 3ae5a369d8 Revert premature instructions to build __sync_fetch_*
My commits got a bit twisted when I was working on both embedded support and
__sync stuff on the same branch. Sorry about that.

llvm-svn: 194886
2013-11-15 23:26:29 +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
Alexander Potapenko bf50fbfc21 [ASan] Add the configure+make rules for building the ASan runtime for iOS simulator.
llvm-svn: 194813
2013-11-15 13:13:01 +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
Chandler Carruth 65fd238772 LLVM's GoogleTest copy has moved its source code back to the default
location, update this reference to reflect that.

llvm-svn: 194802
2013-11-15 10:21:15 +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