Commit Graph

7034 Commits

Author SHA1 Message Date
Mike Aizatsky 41c2afe5d9 Revert "[sanitizer] Move *fstat to the common interceptors"
This reverts commit http://reviews.llvm.org/rL269856

llvm-svn: 269863
2016-05-17 23:28:56 +00:00
Mike Aizatsky 924acb50c9 [sanitizer] Move *fstat to the common interceptors
Summary:
Adds *fstat to the common interceptors.

Removes the now-duplicate fstat interceptor from msan/tsan
This adds fstat to asan/esan, which previously did not intercept it.

Reviewers: eugenis, vitalybuka, aizatsky

Subscribers: tberghammer, danalbert, srhines, kubabrecka, bruening, kcc

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

llvm-svn: 269856
2016-05-17 22:26:50 +00:00
Anna Zaks 7d47c990e6 [tsan] Ensure mmap respects ignore_interceptors_accesses
The ignore_interceptors_accesses setting did not have an effect on mmap, so
let's change that. It helps in cases user code is accessing the memory
written to by mmap when the synchronization is ensured by the code that
does not get rebuilt.

(This effects Swift interoperability since it's runtime is mapping memory
which gets accessed by the code emitted into the Swift application by the
compiler.)

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

llvm-svn: 269855
2016-05-17 22:24:55 +00:00
Derek Bruening 1f6d861ac2 [esan] Fix isShadowMem endpoint bug
Fixes a bug in checking the endpoint of a shadow region and removes an
invalid check (both introduced in http://reviews.llvm.org/rL269198).

llvm-svn: 269834
2016-05-17 20:44:09 +00:00
Mike Aizatsky 599eef49e5 [sanitizers] disabling LateInitialize call to fix the build.
http://reviews.llvm.org/rL269291 introduced a memory leak.
Disabling offending call temprorary rather than rolling back the chain
of CLs.

llvm-svn: 269799
2016-05-17 18:44:21 +00:00
Maxim Ostapenko 02c21b3ef9 [asan] Don't raise false alarm to recv/recvfrom when MSG_TRUNC is present.
Fix https://llvm.org/bugs/show_bug.cgi?id=27673.

Currenty ASan checks the return value of real recv/recvfrom to see if the written bytes fit in the buffer. That works fine most of time.
However, there is an exception: (from the RECV(2) man page)

MSG_TRUNC (since Linux 2.2)
    ... return the real length of the packet or datagram, even when it was longer than the passed buffer. ...

Some programs combine MSG_TRUNC, MSG_PEEK and a single-byte buffer to peek the incoming data size without reading (much of) them. In this case,
the return value is usually longer than what's been written and ASan raises a false alarm here. To avoid such false positive reports,
we can use min(res, len) in COMMON_INTERCEPTOR_WRITE_RANGE checks.

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

llvm-svn: 269749
2016-05-17 07:38:27 +00:00
Sean Silva cfec6c6a28 Avoid leak. Free before resetting.
llvm-svn: 269724
2016-05-16 23:28:35 +00:00
Xinliang David Li 21d38c5eaf [profile] Add portability macro for atomic fetch_and_add
This is another enabler patch to support value profiling
without dynamic memory allocation.

llvm-svn: 269719
2016-05-16 23:01:03 +00:00
Vedant Kumar 533a88a5c9 Revert "Reapply^2 "[ProfileData] (compiler-rt) Use Error in InstrProf and Coverage, NFC""
This reverts commit r269696. The llvm commit does not pass the MSVC bot.

llvm-svn: 269702
2016-05-16 21:05:05 +00:00
Vedant Kumar cd5efa593b Reapply^2 "[ProfileData] (compiler-rt) Use Error in InstrProf and Coverage, NFC"
Sync up with "(llvm) Use Error in InstrProf and Coverage".

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

llvm-svn: 269696
2016-05-16 20:50:36 +00:00
Xinliang David Li f90425e73b [profile] minor code restructuring /NFC
This is one of the enabler patch to allow value profiler to 
allocate counter statically.

llvm-svn: 269689
2016-05-16 20:33:30 +00:00
Paul Robinson 595b969c67 [PS4] Change the names of some "environmental" things to what our
licensees actually see in the toolchain we deliver to them.  This will
reduce the set of local patches we have to maintain.  The triple is
not changing.  (The term ORBIS is an internal code name for PS4.)

llvm-svn: 269672
2016-05-16 17:22:32 +00:00
Etienne Bergeron 3df2879232 [compiler-rt] Fix multi-configuration output paths
Summary:
When using a multi-configuration build (i.e. MSVC) the output path where
libraries are dropped is incorrect.

Example:
```
C:\src\llvm\examples>d:\src\llvm\build\Release\bin\clang-cl.exe -fsanitize=address test.cc
LINK : fatal error LNK1181: cannot open input file 'd:\src\llvm\build\Release\bin\..\lib\clang\3.9.0\lib\windows\clang_rt.asan-i386.lib'
```

The dropped executable path contains the configuration 'Release':
```
'd:\src\llvm\build\Release\bin\..\lib\clang\3.9.0\lib\windows\Release\clang_rt.asan-i386.lib'
```


The variable 'RUNTIME_OUTPUT_DIRECTORY' is used to specify the output directory.
But CMAKE is appending the current configuration (i.e. Debug, Release).

see: https://cmake.org/cmake/help/v3.0/prop_tgt/RUNTIME_OUTPUT_DIRECTORY.html
```
"Multi-configuration generators (VS, Xcode) append a per-configuration subdirectory to the specified directory."
```

To avoid this problem, the configuration specific variable must be set:
'RUNTIME_OUTPUT_DIRECTORY_DEBUG', 'RUNTIME_OUTPUT_DIRECTORY_RELEASE', and so on.

Reviewers: ddunbar, chapuni, rnk

Subscribers: kubabrecka, llvm-commits

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

llvm-svn: 269658
2016-05-16 14:58:07 +00:00
Maxim Ostapenko 187043f61e [asan] Fix asan initialization failure with newer (2.23+) glibc in use.
This patch tries to fix https://llvm.org/bugs/show_bug.cgi?id=27310 by using the same hack for malloc as we use for calloc: allocate corresponding memory from internal buffer when ASan is not initialized.
This way we could avoid nasty '==6987==AddressSanitizer CHECK failed: ../../../../libsanitizer/asan/asan_rtl.cc:556 "((!asan_init_is_running && "ASan init calls itself!")) != (0)" (0x0, 0x0)' errors in
environments with glibc 2.23+ in use, where _dl_signal_error, called from dlsym for undefined symbols calls malloc in order to get a buffer for error message.

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

llvm-svn: 269633
2016-05-16 07:20:53 +00:00
Xinliang David Li 6c7bddb28b Use __builtin_alloca with __GNUC__
llvm-svn: 269592
2016-05-15 16:41:58 +00:00
Xinliang David Li fedb0fd907 Fix FreeBSD build failure
llvm-svn: 269587
2016-05-15 04:26:17 +00:00
Xinliang David Li 23a66e45ed [profile] Eliminate dynamic memory allocation for vp writing
This is part-3 of the effort to eliminate dependency on
libc allocator in instr profiler runtime. With this change,
the profile dumper is completely free of malloc/calloc. 
Value profile instr API implementation is the only remaining
piece with calloc dependency.

llvm-svn: 269576
2016-05-14 20:12:42 +00:00
Daniel Sanders 962b2cda9c [mips][ias] Two XFAIL's now pass on 32-bit MIPS.
llvm-svn: 269571
2016-05-14 16:18:16 +00:00
Chandler Carruth a3cd590644 Revert "Reapply "[ProfileData] (compiler-rt) Use Error in InstrProf and Coverage, NFC""
This reverts commit r269493 as the corresponding LLVM commit was
reverted due to lots of warnings. See the review thread for the original
LLVM commit (r269491) for details.

llvm-svn: 269550
2016-05-14 05:40:00 +00:00
Xinliang David Li a16c754e17 minor cleanup -- reset buffer pointer
llvm-svn: 269533
2016-05-14 03:16:47 +00:00
Marcin Koscielnicki bcbba8caed Revert "[MSan] Enable on PowerPC64."
This reverts commit r269522.

This broke dtls_test.c on ppc64le buildbots.

llvm-svn: 269532
2016-05-14 02:17:38 +00:00
Marcin Koscielnicki c4743ff313 [MSan] Enable on PowerPC64.
Differential Revision: http://reviews.llvm.org/D20001

llvm-svn: 269522
2016-05-14 00:18:02 +00:00
Vedant Kumar be1b4e4dc6 Reapply "[ProfileData] (compiler-rt) Use Error in InstrProf and Coverage, NFC"
Sync up with "(llvm) Use Error in InstrProf and Coverage".

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

llvm-svn: 269493
2016-05-13 21:51:06 +00:00
Vedant Kumar bd3c2f25fa Revert "(HEAD -> master, origin/master, origin/HEAD) [ProfileData] (compiler-rt) Use Error in InstrProf and Coverage, NFC"
This reverts commit r269464. It fails two llvm-profdata tests.

llvm-svn: 269469
2016-05-13 20:10:49 +00:00
Vedant Kumar 6ecc10ab80 [ProfileData] (compiler-rt) Use Error in InstrProf and Coverage, NFC
Sync up with "(llvm) Use Error in InstrProf and Coverage".

llvm-svn: 269464
2016-05-13 20:01:38 +00:00
Xinliang David Li 609fae3893 [profile] Eliminate dynamic memory allocation for buffered writer
With this change, dynamic memory allocation is only used
for testing purpose. This change is one of the many steps to
make instrument profiler dynamic allocation free.

llvm-svn: 269453
2016-05-13 18:26:26 +00:00
Xinliang David Li d1dadf6bcf [profile] Code refactoring
Move runtime specific code from the common header file
to runtime source.

llvm-svn: 269357
2016-05-12 21:43:49 +00:00
Xinliang David Li 911af1ce15 Minor code refactoring /NFC
llvm-svn: 269351
2016-05-12 21:18:41 +00:00
Kuba Brecka 7a947b6c6d Update test expectations after r269291 (Fix a crash when demangling Swift symbols).
llvm-svn: 269311
2016-05-12 17:08:25 +00:00
Kuba Brecka a4c5bef998 More fixup for r269288 and r269296. Adding the missing 'return'.
llvm-svn: 269310
2016-05-12 16:58:19 +00:00
Kuba Brecka 11d3926cf6 [sanitizer] Allow nullptr in Swift demangler
The introduction of the Swift demangler now causes an assertion failure when we
try to demangle nullptr, but we used to allow that (and return nullptr back).
This situation is rare, but it can still happen.  Let's allow nullptr.

llvm-svn: 269302
2016-05-12 15:54:33 +00:00
Daniel Sanders 9ede03d4f2 [mips][sanitizer_common] Don't use `ld` in internal_clone() on 32-bit MIPS.
Summary:
On a 32-bit MIPS, the `ld` instruction does not exist. However, GAS has an `ld`
macro that expands to a pair of `lw` instructions which load to a pair of
registers (reg, and reg+1). This macro is not available in the Integrated
Assembler and its use causes -fintegrated-as builds to fail. Even if it were
available, the behaviour on 32-bit MIPS would be incorrect since the current
usage of `ld` causes the code to clobber $5 (which is supposed to hold
child_stack). It also clobbers $k0 which is reserved for kernel use.

Aside from enabling builds with the integrated assembler, there is no functional
change since internal_clone() is only used by StopTheWorld() which is only used
by 64-bit sanitizers.

Reviewers: kcc, sagar

Subscribers: mohit.bhakkad, jaydeep, sagar, llvm-commits

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

llvm-svn: 269297
2016-05-12 14:21:33 +00:00
Kuba Brecka 00dde7563e Fixup for r269288. SleepForSeconds is not available in nolibc builds, let's add an internal_sleep.
llvm-svn: 269296
2016-05-12 14:08:56 +00:00
Kuba Brecka 3a0736e279 Fixup for r269291, which broke the Go TSan build. Let's not use the symbolizer in Go builds.
llvm-svn: 269293
2016-05-12 13:28:45 +00:00
Kuba Brecka 5bdf86ec7c [sanitizer] Fix a crash when demangling Swift symbols, take 2
To invoke the Swift demangler, we use dlsym to locate swift_demangle. However, dlsym malloc's storage and stores it in thread-local storage. Since allocations from the symbolizer are done with the system allocator (at least in TSan, interceptors are skipped when inside the symbolizer), we will crash when we try to deallocate later using the sanitizer allocator again.

To fix this, let's just not call dlsym from the demangler, and call it during initialization. The dlsym function calls malloc, so it needs to be only used after our allocator is initialized. Adding a Symbolizer::LateInitialize call that is only invoked after all other initializations.

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

llvm-svn: 269291
2016-05-12 13:11:03 +00:00
Kuba Brecka 3f6f8de238 [sanitizer] On OS X, exit the forked process gracefully when login_tty fails
We're using forkpty to spawn the atos symbolizer. In some cases, login_tty (part of forkpty) can fail due to security measures (sandboxing). In this case, we should exit with a status code instead of completely crashing the spawned process. Even processing a failed CHECK() is problematic here, because we're post-fork and pre-exec where a lot of things don't work (for multithreaded processes, for OS X GUI apps, etc.).

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

llvm-svn: 269289
2016-05-12 12:53:43 +00:00
Kuba Brecka e0c8256781 [sanitizer] Break infinite recursion in case of recursive failed CHECKs
While debugging ASan and TSan, I sometimes get a recursion during a failed CHECK processing.  CheckFailed can call a lot of code (printing, unwinding a stack trace, symbolicating, ...) and this can fail another CHECK. This means I sometimes see a crash due to a infinite recursion stack overflow. Let's stop after 10 failed CHECKs and just kill the process immediately. I also added a Sleep(2) call before the trap, so that other threads still get a chance to print their failed CHECKs.

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

llvm-svn: 269288
2016-05-12 12:49:53 +00:00
Marcin Koscielnicki 1598698fcd [ASan] [SystemZ] Add -mbackchain to test cflags.
This is needed for proper operation of the fast unwinder, see the discussion
on D18895.

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

llvm-svn: 269277
2016-05-12 08:49:34 +00:00
Xinliang David Li 667de6a84e [profile] profile writing cleanup
Do not precompute value counts for all sites. This 
eliminates one more use of dynamic allocation 
in profiler writer.

llvm-svn: 269254
2016-05-11 23:21:22 +00:00
Xinliang David Li eb836a3dec cleanup: Enforce caller to set total size to avoid redundant size compute
llvm-svn: 269237
2016-05-11 21:16:11 +00:00
Evgeniy Stepanov 556e963e4e [asan] Don't use libcorkscrew on Android L+.
ASan runtime library used libcorkscrew from Android platform for
stack unwinding. Since Android L, this is both unnecessary (the
libgcc unwinder has been fixed) and impossible (the library is not
there any more). Don't even try.

This should have not effect on modern Android devices other than
removing a message about failing to open the library with
ASAN_OPTIONS=verbosity=1.

llvm-svn: 269233
2016-05-11 20:53:43 +00:00
Chris Bieneman 1455de2171 [CMake] Cache check results and avoid duplicate checks
This caches the result of builtin_check_c_compiler_flag, and removes a duplicate check for C99 flag support.

llvm-svn: 269230
2016-05-11 20:37:43 +00:00
Evgeniy Stepanov feb73c8566 [sanitizer] Move *stat to the common interceptors
Adds *stat to the common interceptors.

Removes the now-duplicate *stat interceptor from msan/tsan/esan.
This adds *stat to asan, which previously did not intercept it.

Patch by Qin Zhao.

llvm-svn: 269223
2016-05-11 20:02:15 +00:00
Rong Xu 5da4dab0fc Reapply r268608
Re-enable the tests after IR instrumentation fix (r269146).
Check-in on behalf of davidxl.

llvm-svn: 269219
2016-05-11 18:37:08 +00:00
Derek Bruening 1658c089fd [esan] EfficiencySanitizer shadow memory
Summary:
Adds shadow memory mapping support common to all tools to the new
Efficiencysanitizer ("esan") family of tools.  This includes:

+ Shadow memory layout and mapping support for 64-bit Linux for any
  power-of-2 scale-down (1x, 2x, 4x, 8x, 16x, etc.) that ensures that
  shadow(shadow(address)) does not overlap shadow or application
  memory.

+ Mmap interception to ensure the application does not map on top of
  our shadow memory.

+ Init-time sanity checks for shadow regions.

+ A test of the mmap conflict mechanism.

Reviewers: aizatsky, filcab

Subscribers: filcab, kubabrecka, llvm-commits, vitalybuka, eugenis, kcc, zhaoqin

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

llvm-svn: 269198
2016-05-11 15:47:54 +00:00
Xinliang David Li 32d8dc8261 Revert r268130 -- more bot failure
llvm-svn: 269142
2016-05-10 23:52:02 +00:00
Xinliang David Li b788391260 Reapply r268608 after IR instr bug fix
llvm-svn: 269130
2016-05-10 22:01:20 +00:00
Dmitry Vyukov 2498629e34 tsan: fix another crash due to processors
Another stack where we try to free sync objects,
but don't have a processors is:

  //   ResetRange
  //   __interceptor_munmap
  //   __deallocate_stack
  //   start_thread
  //   clone

Again, it is a latent bug that lead to memory leaks.
Also, increase amount of memory we scan in MetaMap::ResetRange.
Without that the test does not fail, as we fail to free
the sync objects on stack.

llvm-svn: 269041
2016-05-10 11:19:50 +00:00
Xinliang David Li e9a8574da1 Reapply r268840: [profile] Simplify value profile writing
Revert r268864 that reverted 268840 after underlying problem
is fixed for arm bot.

llvm-svn: 268992
2016-05-10 00:17:31 +00:00
Marcin Koscielnicki a407f543c0 [MSan] Add a test for vararg with lots of non-vararg arguments.
This is a testcase for http://llvm.org/PR27646, hitting the bug on x86_64,
aarch64, mips.

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

llvm-svn: 268981
2016-05-09 21:53:47 +00:00