Commit Graph

3862 Commits

Author SHA1 Message Date
Evgeniy Stepanov a6eb1bb59e [sanitizer] Intercept __bzero on Mac.
This should make memset_test pass on Mac.

llvm-svn: 204929
2014-03-27 14:20:34 +00:00
Evgeniy Stepanov 1189734413 [sanitizer] Fix Android build.
llvm-svn: 204927
2014-03-27 14:06:15 +00:00
Evgeniy Stepanov 89602651e8 [msan] Implement __msan_set_death_callback.
llvm-svn: 204926
2014-03-27 14:04:58 +00:00
Timur Iskhodzhanov e6303d1224 Add support for _expand[_dbg] so we don't crash when _aligned_* allocation functions are used
llvm-svn: 204925
2014-03-27 14:01:11 +00:00
Evgeniy Stepanov 9dcd5a353a [msan] Intercept several malloc-related functions.
llvm-svn: 204923
2014-03-27 13:29:29 +00:00
Kostya Serebryany d093b5ac43 [asan] add a test case for r204897.
llvm-svn: 204903
2014-03-27 08:51:32 +00:00
Kostya Serebryany 88d0eac412 [asan] Do not sanitize kernel area on 32-bit targets, patch by Yuri Gribov
llvm-svn: 204897
2014-03-27 07:36:26 +00:00
Greg Fitzgerald ffa4b7993f Revert r204877 "Allow the user to override the compiler used for testing"
Unbreak the sanitizer-x86_64-linux bot.

Change-Id: Ie03f1b93fae45c54b142003731ff4f5d4f6b62f8
llvm-svn: 204886
2014-03-27 01:11:12 +00:00
Greg Fitzgerald 6ff4f89af3 Allow the user to override the compiler used for testing
Change-Id: Ida62c2d85f541260f505c3dbd5d71a4b2a6004f4
llvm-svn: 204877
2014-03-26 23:51:44 +00:00
Peter Collingbourne 5d167dae7d Add function to get the number of DFSan labels allocated.
Expose the number of DFSan labels allocated by adding function dfsan_get_label_count().

Patch by Sam Kerner!

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

llvm-svn: 204854
2014-03-26 21:09:53 +00:00
Dmitry Vyukov e31dd3473e tsan: deflake test
llvm-svn: 204824
2014-03-26 15:51:11 +00:00
Rafael Espindola 5e46070516 Avoid aliases to weak aliases in interceptors.
The interceptors had code that after macro expansion ended up looking like

extern "C" void memalign()
    __attribute__((weak, alias("__interceptor_memalign")));
extern "C" void __interceptor_memalign() {}
extern "C" void __interceptor___libc_memalign()
    __attribute__((alias("memalign")));

That is,
* __interceptor_memalign is a function
* memalign is a weak alias to __interceptor_memalign
* __interceptor___libc_memalign is an alias to memalign

Both gcc and clang produce assembly that look like

__interceptor_memalign:
...
        .weak   memalign
memalign = __interceptor_memalign
        .globl  __interceptor___libc_memalign
__interceptor___libc_memalign = memalign

What it means in the end is that we have 3 symbols pointing to the
same position in the file, one of which is weak:

     8: 0000000000000000     1 FUNC    GLOBAL DEFAULT    1
__interceptor_memalign
     9: 0000000000000000     1 FUNC    WEAK   DEFAULT    1 memalign
    10: 0000000000000000     1 FUNC    GLOBAL DEFAULT    1
__interceptor___libc_memalign

In particular, note that __interceptor___libc_memalign will always
point to __interceptor_memalign, even if we do link in a strong symbol
for memalign. In fact, the above code produces exactly the same binary
as

extern "C" void memalign()
    __attribute__((weak, alias("__interceptor_memalign")));
extern "C" void __interceptor_memalign() {}
extern "C" void __interceptor___libc_memalign()
    __attribute__((alias("__interceptor_memalign")));

If nothing else, this patch makes it more obvious what is going on.

llvm-svn: 204823
2014-03-26 15:48:59 +00:00
Dmitry Vyukov 4bfb4cb1e7 tsan: add pthread_barrier_t test
llvm-svn: 204810
2014-03-26 14:13:49 +00:00
Dmitry Vyukov 5da31e03bf tsan: fix deadlock during fork
ReportRace takes the two mutexes in the opposite order

llvm-svn: 204809
2014-03-26 14:13:31 +00:00
Dmitry Vyukov b979a55607 tsan: fix another compiler-injected memset
newer gcc inserts memset here

llvm-svn: 204808
2014-03-26 14:13:00 +00:00
Evgeniy Stepanov 16d89fc356 [sanitizer] Intercept __aeabi_mem(set|cpy|move).
llvm-svn: 204800
2014-03-26 12:14:34 +00:00
Viktor Kutuzov 9068dfa6a7 Define uintptr_t in the profiling sources on x86_64 FreeBSD in 32-bit mode
llvm-svn: 204799
2014-03-26 12:00:44 +00:00
Alexander Potapenko 7caa0b9e36 [ASan] Fix a thinko spotted by Evgeniy Stepanov: use REAL(memcpy) on non-OSX systems.
llvm-svn: 204794
2014-03-26 11:18:25 +00:00
Evgeniy Stepanov 1382fabd97 [msan] Enable SelectPartial test.
Fixed in r204716.

llvm-svn: 204717
2014-03-25 13:09:14 +00:00
Evgeniy Stepanov 1611ed8879 [tsan] Fix more warnings in TSan tests.
llvm-svn: 204715
2014-03-25 13:01:32 +00:00
Evgeniy Stepanov 0f08043aeb [tsan] Fix compiler warnings in TSan tests.
llvm-svn: 204712
2014-03-25 11:17:14 +00:00
Evgeniy Stepanov 517ff05ffb [msan] Fix compiler warning in msan_test.cc.
llvm-svn: 204708
2014-03-25 10:03:39 +00:00
Evgeniy Stepanov 90384ad60e [msan] A disabled test for inexact "select" instrumentation.
llvm-svn: 204707
2014-03-25 09:36:15 +00:00
Duncan P. N. Exon Smith 21b98a6c83 InstrProf: Change the extension of the default profile
Change the name of the default profile dumped by compiler-rt to
default.profraw.  This distinguishes it more clearly from the
(incompatible) format output by llvm-profdata that is read by clang
-fprofile-instr-use.

llvm-svn: 204676
2014-03-24 21:53:42 +00:00
Dmitry Vyukov d23118c3b2 tsan: optimize vector clock operations
Make vector clock operations O(1) for several important classes of use cases.
See comments for details.
Below are stats from a large server app, 77% of all clock operations are handled as O(1).

Clock acquire                     :         25983645
  empty clock                     :          6288080
  fast from release-store         :         14917504
  contains my tid                 :          4515743
  repeated (fast)                 :          2141428
  full (slow)                     :          2636633
  acquired something              :          1426863
Clock release                     :          2544216
  resize                          :             6241
  fast1                           :           197693
  fast2                           :          1016293
  fast3                           :             2007
  full (slow)                     :          1797488
  was acquired                    :           709227
  clear tail                      :                1
  last overflow                   :                0
Clock release store               :          3446946
  resize                          :           200516
  fast                            :           469265
  slow                            :          2977681
  clear tail                      :                0
Clock acquire-release             :           820028

llvm-svn: 204656
2014-03-24 18:54:20 +00:00
Dmitry Vyukov f49921ba53 tsan: reorder SyncVar members to reduce contention
llvm-svn: 204655
2014-03-24 18:51:37 +00:00
Dmitry Vyukov 781eca5f71 tsan: use read lock instead of write in atomic operations when possible
llvm-svn: 204654
2014-03-24 18:51:13 +00:00
Dmitry Vyukov 775b11cc53 tsan: reduce default number of threads in benchmarks
buildbots seem to OOM with that many threads

llvm-svn: 204610
2014-03-24 15:23:05 +00:00
Dmitry Vyukov 238bd23534 tsan: add benchmarks for synchronization handling
llvm-svn: 204608
2014-03-24 14:32:59 +00:00
Alexey Samsonov c41ca6d31a [CMake] Rename the variable
llvm-svn: 204602
2014-03-24 13:29:20 +00:00
Timur Iskhodzhanov 59ce9e07a4 Fix a VS compile-time warning
warning C4345: behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized

llvm-svn: 204597
2014-03-24 10:47:37 +00:00
Viktor Kutuzov 276fefb8d9 A fix for sanitizers' TLS support on FreeBSD
llvm-svn: 204595
2014-03-24 10:01:54 +00:00
Alexey Samsonov 1847401332 [CMake] Respect CMAKE_CXX_FLAGS in custom clang_compile commands
llvm-svn: 204593
2014-03-24 09:42:12 +00:00
Alexey Samsonov 8c956460d3 Make MSan unittest -Werror=sign-compare clean
llvm-svn: 204592
2014-03-24 09:41:11 +00:00
Evgeniy Stepanov ce002ad3b2 [asan] Disable setjmp/sigsetjmp tests.
Failing due to PR19207.

llvm-svn: 204590
2014-03-24 08:30:59 +00:00
Evgeniy Stepanov d7f06ee3c7 [asan] Fix a comment.
llvm-svn: 204589
2014-03-24 08:27:31 +00:00
Duncan P. N. Exon Smith 96cf6c3892 InstrProf: Indicate pointer size in raw profile
Since the profile can come from 32-bit machines, the reader needs to
check the pointer size.  Change the magic number to facilitate this.

<rdar://problem/16400648>

llvm-svn: 204556
2014-03-23 03:38:05 +00:00
David Blaikie 089b5c9174 Avoid GCC's "cast from pointer to integer of different size" warning.
This is a bit of a stab in the dark as I'm not sure I've got these
source files compiling correctly locally. (and the warning only
reproduces on a 32bit build anyway)

llvm-svn: 204521
2014-03-21 21:45:49 +00:00
Duncan P. N. Exon Smith 8d02a2ac21 InstrProf: Remove MSVC-specific logic
Apparently, MSVC has stdint.h now?  Let's see if the buildbots complain.
I'm not convinced that the build system is even set up for MSVC to build
this file, but...

llvm-svn: 204515
2014-03-21 20:59:08 +00:00
Duncan P. N. Exon Smith a128956243 InstrProf: Change magic number to have non-text characters
Include non-text characters in the magic number so that text files can't
match.

<rdar://problem/15950346>

llvm-svn: 204514
2014-03-21 20:42:40 +00:00
Duncan P. N. Exon Smith f1c9361326 InstrProf: __ => _ in header guards
llvm-svn: 204502
2014-03-21 18:47:23 +00:00
Duncan P. N. Exon Smith 812dcae09c InstrProf: Unify logic in two profile writers
<rdar://problem/15943240>

llvm-svn: 204500
2014-03-21 18:29:24 +00:00
Duncan P. N. Exon Smith 117cf2bd1f InstrProf: Write the __llvm_profile_write_buffer()
Write __llvm_profile_write_buffer(), which uses the same logic as
__llvm_profile_write_file(), but writes directly to a provided `char*`
buffer instead.

<rdar://problem/15943240>

llvm-svn: 204499
2014-03-21 18:29:22 +00:00
Duncan P. N. Exon Smith cf4bb960bd InstrProf: If libc is available, use it; no functionality change
It was misguided to plan to rely on __llvm_profile_write_buffer() in
__llvm_profile_write_file().  It's less complex to duplicate the writing
logic than to mmap the file.

Since it's here to stay, move `FILE*`-based writing logic into
InstrProfilingFile.c.

<rdar://problem/15943240>

llvm-svn: 204498
2014-03-21 18:29:19 +00:00
Duncan P. N. Exon Smith be0a5e176b InstrProf: Reorganize files; no functionality change
Move functions around to prepare for some other changes.

  - Merge InstrProfilingExtras.h with InstrProfiling.h.  There's no
    benefit to having these split.

  - Rename InstrProfilingExtras.c to InstrProfilingFile.c.

  - Split actual buffer writing code out of InstrProfiling.c into
    InstrProfilingBuffer.c.

  - Drive-by corrections of a couple of header comments.

<rdar://problem/15943240>

llvm-svn: 204497
2014-03-21 18:29:15 +00:00
Duncan P. N. Exon Smith 76e8731b09 InstrProf: Write raw binary profile from runtime
Write a raw binary profile from the runtime.

<rdar://problem/15950346>

llvm-svn: 204495
2014-03-21 18:25:56 +00:00
Alexander Potapenko 25e204e194 [libsanitizer] Add descriptions for the common flags.
Use new(allocator_for_flags) instead of allocator_for_flags.Allocate()
Fix the description output format a bit.

llvm-svn: 204484
2014-03-21 17:28:12 +00:00
Kostya Serebryany 3df5d87da4 [sanitizer] print threads in deadlock report
llvm-svn: 204461
2014-03-21 13:00:18 +00:00
Kostya Serebryany 7317d9499b [sanitizer] more human-readable deadlock reports
llvm-svn: 204454
2014-03-21 11:37:43 +00:00
Sergey Matveev fa76f3b3a5 [MSan] Add __msan_unpoison_string() to the public interface.
Using __msan_unpoison() on null-terminated strings is awkward because
strlen() can't be called on a poisoned string. This case warrants a special
interface function.

llvm-svn: 204448
2014-03-21 10:12:17 +00:00