Commit Graph

6700 Commits

Author SHA1 Message Date
Dmitry Vyukov a029b79e1a tsan: describe heap/data locations in Go
llvm-svn: 262343
2016-03-01 15:38:12 +00:00
Dmitry Vyukov f5fcdd268f sanitizer_common: silence compiler warning
llvm-svn: 262342
2016-03-01 15:36:42 +00:00
Mohit K. Bhakkad 1d1493219c [Compiler-rt][MIPS] Correct Dynamic Thread Vector offset for MIPS
Reviewers: samsonov

Subscribers: dsanders, jaydeep, sagar, llvm-commits

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

llvm-svn: 262303
2016-03-01 05:56:33 +00:00
Mohit K. Bhakkad 94aa4d7e83 [Compiler-rt][MSan] fix param_tls_limit test for platforms where big arguments are sliced in smaller ones
Reviewers: eugenis

Subscribers: dsanders, jaydeep, sagar, llvm-commits

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

llvm-svn: 262302
2016-03-01 05:53:30 +00:00
Evgeniy Stepanov e5ec0623d1 [asan] Retry failed adb commands in android tests.
Add limited retries for push/pull adb commands in android tests.
May help with the adb flakiness.

llvm-svn: 262283
2016-03-01 01:16:03 +00:00
Evgeniy Stepanov aafe4b63d9 [asan] Fix new[]/delete mismatch in tests.
This code is actually never executed because all RUN lines trigger an
earlier heap-use-after-free, but there is still a compiler warning.

llvm-svn: 262276
2016-03-01 00:38:39 +00:00
Reid Kleckner 1456e2581a Avoid use of -fsanitize=vptr in MSVC env, it is not yet supported
llvm-svn: 262251
2016-02-29 20:38:35 +00:00
Maxim Ostapenko d0257b7bf1 [asan] Fix UB in test/asan/TestCases/Linux/recvfrom.cc testcase.
llvm-svn: 262210
2016-02-29 08:56:26 +00:00
Mohit K. Bhakkad 2d14d3b529 Update the link of issue
llvm-svn: 262209
2016-02-29 08:22:55 +00:00
Maxim Ostapenko 8d8f919cf5 [asan] Re-enable test/asan/TestCases/Linux/recvfrom.cc testcase.
This testcase failed on sanitizer-x86_64-linux buildbot in large parallel build due to race on
port 1234 between AddressSanitizer-i386-linux and AddressSanitizer-x86_64-linux instances of recvfrom.cc.
This patch tries to resolve the issue by relying on kernel to choose available port instead of hardcoding
its number in testcase.

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

llvm-svn: 262204
2016-02-29 07:47:35 +00:00
Xinliang David Li 80d4b898d1 Test cleanups
llvm-svn: 262162
2016-02-28 00:54:28 +00:00
Xinliang David Li adbb7b7b57 [PGO] add a test for available_externally functions
llvm-svn: 262161
2016-02-28 00:45:13 +00:00
Filipe Cabecinhas b7692bc3e9 [UBSan] Fix isDerivedFromAtOffset on iOS ARM64
Summary:
iOS on ARM64 doesn't unique RTTI.
Ref: clang's iOS64CXXABI::shouldRTTIBeUnique()

Due to this, pointer-equality will not necessarily work in this
architecture, across dylib boundaries.

dynamic_cast<>() will (as expected) still work, since Apple ships with
one prepared for this, but we can't rely on the type names being
pointer-equal.

I've limited the expensive strcmp check to the specific architecture
which needs it.

Example which triggers this bug:

lib.h:
  struct X {
    virtual ~X() {}
  };
  X *libCall();

lib.mm:
  X *libCall() {
    return new X;
  }

prog.mm:
  int main() {
    X *px = libCall();
    delete px;
  }

Expected output: Nothing
Actual output:
<unknown>: runtime error: member call on address 0x00017001ef50 which does not point to an object of type 'X'
0x00017001ef50: note: object is of type 'X'
 00 00 00 00  60 00 0f 00 01 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
              ^~~~~~~~~~~~~~~~~~~~~~~
              vptr for ‘X’

Reviewers: kubabrecka, samsonov, eugenis, rsmith

Subscribers: aemerson, llvm-commits, rengolin

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

llvm-svn: 262147
2016-02-27 19:57:44 +00:00
Alexey Samsonov 2eff7f788a [CMake] Fix a typo in add_compiler_rt_library.
llvm-svn: 262063
2016-02-26 20:59:40 +00:00
Dmitry Vyukov 7f022ae4c2 tsan: revert r262037
Broke aarch64 and darwin bots.

llvm-svn: 262046
2016-02-26 18:26:48 +00:00
Dmitry Vyukov b8868b9bea tsan: split thread into logical and physical state
Currently ThreadState holds both logical state (required for race-detection algorithm, user-visible)
and physical state (various caches, most notably malloc cache). Move physical state in a new
Process entity. Besides just being the right thing from abstraction point of view, this solves several
problems:
1. Cache everything on P level in Go. Currently we cache on a mix of goroutine and OS thread levels.
This unnecessary increases memory consumption.
2. Properly handle free operations in Go. Frees are issue by GC which don't have goroutine context.
As the result we could not do anything more than just clearing shadow. For example, we leaked
sync objects and heap block descriptors.
3. This will allow to get rid of libc malloc in Go (now we have Processor context for internal allocator cache).
This in turn will allow to get rid of dependency on libc entirely.
4. Potentially we can make Processor per-CPU in C++ mode instead of per-thread, which will
reduce resource consumption.
The distinction between Thread and Processor is currently used only by Go, C++ creates Processor per OS thread,
which is equivalent to the current scheme.

llvm-svn: 262037
2016-02-26 16:57:14 +00:00
Alexander Kornienko ba87c4db30 Use relative lines in CHECKs in race_on_mutex.c
llvm-svn: 262000
2016-02-26 11:09:32 +00:00
Sagar Thakur ce63c2053d [TSAN] XFAIL race_on_mutex.cc for MIPS
This test expects pthread_mutex_init in the frame #0 of thread T1 but we
get memset at frame #0 because memset that is called from pthread_init_mutex
is being intercepted by TSan

llvm-svn: 261986
2016-02-26 07:01:24 +00:00
Mohit K. Bhakkad fac2e248c4 [MSan] Endianness should not matter while printing a byte
Reviewers: eugenis

Subscribers: jaydeep, sagar, llvm-commits

Differential Revision: http://reviews.llvm.org/D17264
Differential Revision: http://reviews.llvm.org/D17563

llvm-svn: 261982
2016-02-26 06:44:10 +00:00
Sagar Thakur 63cecb3653 [MSAN] Fix test SmallPreAllocatedStackThread for MIPS
Summary: Msan was intercepting version 2.1 of the pthread_create function which was making it to crash in libc because __pthread_create_2_1 modifies the stack attributes of the thread. Intercepting the correct version fixes the test SmallPreAllocatedStackThread.

Reviewers: eugenis, samsonov
Subscribers: llvm-commits, mohit.bhakkad, jaydeep
Differential: http://reviews.llvm.org/D17603
llvm-svn: 261980
2016-02-26 05:56:54 +00:00
Vedant Kumar b850251d3e [profile] Compute number of data entries correctly
Compiler-rt miscalculates the number of entries in the __llvm_prf_data section
on i386 Darwin. This results in a number of test failures (which we started
catching after r261344).

The fix we attempted earlier is insufficient (r261683). It caused some tests to
start passing again, but that hid the fact that we drop some data entries.

This patch should fix the real problem. It fixes the way we compute DataSize by
taking into account the way the Darwin linker lays out __llvm_prf_data.

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

llvm-svn: 261957
2016-02-26 02:49:41 +00:00
Xinliang David Li 1a436dd704 Sync up with master
llvm-svn: 261947
2016-02-26 00:56:31 +00:00
Alexey Samsonov 07f9c0f558 [Sanitizer] Protect against compiler-inserted memcpy() in InternalMmapVector::push_back().
llvm-svn: 261909
2016-02-25 18:12:30 +00:00
Bill Seurer 1d180c31f4 [powerpc] reactivate ignore_lib4.cc on powerpc64le
The test case compiler-rt/test/tsan/ignore_lib4.cc fails on powerpc64
big endian but not little endian.

llvm-svn: 261900
2016-02-25 17:41:41 +00:00
Maxim Ostapenko 50ca4464c4 [sanitizer] Fix third parameter in COMMON_INTERCEPTOR_WRITE_RANGE in recv and recvfrom interceptors.
Pass res instead of len as third parameter to COMMON_INTERCEPTOR_WRITE_RANGE,
because otherwise we can write to unrelated memory (in MSan) or get wrong report (in ASan).

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

llvm-svn: 261898
2016-02-25 17:07:38 +00:00
Maxim Ostapenko 640d1fc46c [asan] Disable recvfrom test failing on the bots.
llvm-svn: 261870
2016-02-25 14:58:07 +00:00
Maxim Ostapenko 1f4cea0467 [asan] Disable recvfrom testcase on Android due to buildbot failure.
Trying to fix following error on Android:

FAIL: AddressSanitizer-arm-android :: TestCases/Linux/recvfrom.cc (47 of 350)
...
Command Output (stderr):
--
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/asan/TestCases/Linux/recvfrom.cc:22:22: error: variable has incomplete type 'struct sockaddr_in'
  struct sockaddr_in serveraddr; // server's addr
                     ^
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/asan/TestCases/Linux/recvfrom.cc:22:10: note: forward declaration of 'sockaddr_in'
  struct sockaddr_in serveraddr; // server's addr
         ^
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/asan/TestCases/Linux/recvfrom.cc:29:38: error: use of undeclared identifier 'INADDR_ANY'
  serveraddr.sin_addr.s_addr = htonl(INADDR_ANY);
                                     ^
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/asan/TestCases/Linux/recvfrom.cc:30:25: error: use of undeclared identifier 'htons'
  serveraddr.sin_port = htons(kPortNum);
                        ^
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/asan/TestCases/Linux/recvfrom.cc:45:22: error: variable has incomplete type 'struct sockaddr_in'
  struct sockaddr_in serveraddr; // server's addr
                     ^
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/asan/TestCases/Linux/recvfrom.cc:45:10: note: forward declaration of 'sockaddr_in'
  struct sockaddr_in serveraddr; // server's addr
         ^
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/asan/TestCases/Linux/recvfrom.cc:69:25: error: use of undeclared identifier 'htons'
  serveraddr.sin_port = htons(kPortNum);

llvm-svn: 261855
2016-02-25 10:55:52 +00:00
Maxim Ostapenko b9fd2e0015 [sanitizer] Disable recv and recvfrom interceptors on Windows.
Trying to fix sanitizer-windows buildbot by disabling new interceptors on Windows.

llvm-svn: 261844
2016-02-25 09:36:20 +00:00
Maxim Ostapenko 7389936f57 [sanitizer] Move recvmsg and recv interceptors to sanitizer_common.
This patch moves recv and recvfrom interceptors from MSan and TSan to
sanitizer_common to enable them in ASan.

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

llvm-svn: 261841
2016-02-25 08:44:25 +00:00
Mohit K. Bhakkad 72c3cce484 [Compiler-rt][MSan]Fix shmat testcase: Pass SHMLBA-alligned address to shmat
Reviewers: samsonov

Subscribers: jaydeep, sagar, llvm-commits

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

llvm-svn: 261837
2016-02-25 08:07:44 +00:00
Saleem Abdulrasool 2b972dfebb builtins: adjust the clobbers list for android __clear_cache
Adjust the clobbers list.  This use to work with older versions of gcc, but now
will error on newer versions (tested against 5.3) (as well as clang).

Patch by Tee Hao Wei!

llvm-svn: 261821
2016-02-25 04:04:37 +00:00
Chris Bieneman e8c7d77955 [CMake] Fix a really simple, silly bug from r261797
This should fix bots with CMake older than 2.8.12.

llvm-svn: 261801
2016-02-24 22:42:47 +00:00
Chris Bieneman 956eceae9f [CMake] Default CMAKE_MACOSX_RPATH to On, this is the default with CMP0042
Summary: Building the sanitizer libraries without rpaths causes all sorts of problems when you try to use them. This simple fix should make it all work.

Reviewers: samsonov, zaks.anna

Subscribers: llvm-commits

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

llvm-svn: 261797
2016-02-24 22:29:42 +00:00
Sagar Thakur b6917b42f4 [MSAN] Fix memcmp_test on MIPS
Summary: As per the test the 4th element of both arrays are not initialized and hence will contain garbage values. Memcmp returns the difference between the garbage values of the 4th element which will be different on every run of the test. And since the return value of memcmp is returned from main, we are getting random exit code every time.

Reviewers: kcc, eugenis
Subscribers: mohit.bhakkad, jaydeep, llvm-commits
Differential: http://reviews.llvm.org/D17534
llvm-svn: 261739
2016-02-24 13:48:14 +00:00
Dmitry Vyukov cb35474ba5 tsan: disable ignore_lib4.cc test on powerpc64 and aarch64
Fails on bots:
http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/1555/steps/ninja%20check%201/logs/FAIL%3A%20ThreadSanitizer-powerpc64%3A%3A%20ignore_lib4.cc
http://lab.llvm.org:8011/builders/sanitizer-ppc64be-linux/builds/725/steps/ninja%20check-tsan/logs/stdio
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/1468/steps/ninja%20check%202/logs/FAIL%3A%20ThreadSanitizer-aarch64%3A%3A%20ignore_lib4.cc
http://lab.llvm.org:8011/builders/clang-native-aarch64-full/builds/2787/steps/ninja%20check%202/logs/FAIL%3A%20ThreadSanitizer-aarch64%3A%3A%20ignore_lib4.cc

llvm-svn: 261728
2016-02-24 09:14:46 +00:00
Mohit K. Bhakkad 2c56f33dbf [MSan] fix process_vm_readv test: Exit silently if syscall is not implemeted
Reviewers: eugenis

Subscribers: jaydeep, sagar, llvm-commits

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

llvm-svn: 261723
2016-02-24 08:14:41 +00:00
Mohit K. Bhakkad 28bb3d9046 [MSan] Mark dlerror.cc expected failure for MIPS
Reviewers: samsonov

Subscribers: jaydeep, sagar, llvm-commits, aemerson

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

llvm-svn: 261721
2016-02-24 07:08:33 +00:00
Alexey Samsonov ee7023f79a [tests] Portability fixup for r261713.
llvm-svn: 261715
2016-02-24 01:28:51 +00:00
Alexey Samsonov 0dc3d24d5d [tests] Resolve old TODOs in ASan unit tests.
llvm-svn: 261713
2016-02-24 00:41:29 +00:00
Alexey Samsonov 41172a304a [tests] Don't compile CFI C tests in C++ mode.
llvm-svn: 261708
2016-02-24 00:16:57 +00:00
Chris Bieneman 497a0ac23f [CMake] Support component-based installation for runtime libraries
This enables targets like "install-ubsan" and "install-asan" to install all associated runtime libraries.

llvm-svn: 261700
2016-02-23 21:55:38 +00:00
Chris Bieneman 86792ea718 [CMake] Assign components and dependencies during add_compiler_rt_resource_file
This makes it so that component-based installations will include resource files (i.e. blacklists). My next patch will add support for component-based installations.

llvm-svn: 261699
2016-02-23 21:50:39 +00:00
Vedant Kumar 120f6301ed [profile] Fix iteration over profile data entries
Fix a crash when gathering value profile data on i386 Darwin.

The Darwin linker shrinks sections containing aligned structures when
padding is not explicitly added to the end of the structure. When
iterating over these structures, be sure to not walk past the end of the
section.

No tests added, since running `ninja check-profile` on i386 Darwin is
enough to reproduce the original crash.

llvm-svn: 261683
2016-02-23 20:46:14 +00:00
Dmitry Vyukov 0c202893ae tsan: clean up code after r261658
llvm-svn: 261660
2016-02-23 17:58:23 +00:00
Dmitry Vyukov b2be098026 tsan: fix signal handling in ignored libraries
The first issue is that we longjmp from ScopedInterceptor scope
when called from an ignored lib. This leaves thr->in_ignored_lib set.
This, in turn, disables handling of sigaction. This, in turn,
corrupts tsan state since signals delivered asynchronously.
Another issue is that we can ignore synchronization in asignal
handler, if the signal is delivered into an IgnoreSync region.
Since signals are generally asynchronous, they should ignore
memory access/synchronization/interceptor ignores.
This could lead to false positives in signal handlers.

llvm-svn: 261658
2016-02-23 17:16:26 +00:00
Alexey Samsonov 4d35491a12 [tests] Run test that uses gnu asm syntax on Posix only.
llvm-svn: 261609
2016-02-23 04:10:53 +00:00
Alexey Samsonov 4e796d0c9f [tests] Remove "supported-target" in favor of "target-arch" lit features.
Test cases definitely should not care about the complete set of architectures
supported by compiler-rt - they should only care about current
architecture that the test suite was configured for.

Introduce new lit feature to reflect this, and convert tests to use it.

llvm-svn: 261603
2016-02-23 01:58:56 +00:00
Alexey Samsonov e26c87d10e [tests] Always specify correct config.target_arch when configuring test suite.
llvm-svn: 261601
2016-02-23 01:34:17 +00:00
Alexey Samsonov 8e3cbde27d [Sanitizer] Introduce ListOfModules object and use it to replace GetListOfModules().
Summary:
This removes the hard limit on the number of loaded modules (used to be
16K), and makes it easier to use LoadedModules w/o causing a memory
leak: ListOfModules owns the modules, and makes sure to properly clean
them in destructor.

Remove filtering functionality that is only needed in one place (LSan).

Reviewers: aizatsky

Subscribers: llvm-commits, kcc

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

llvm-svn: 261554
2016-02-22 18:52:51 +00:00
Mohit K. Bhakkad 452417ac12 [MSan] Make unaligned load/store functions compatible for both endians
Reviewers: eugenis

Subscribers: jaydeep, sagar, llvm-commits

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

llvm-svn: 261513
2016-02-22 06:16:28 +00:00