Commit Graph

4777 Commits

Author SHA1 Message Date
Evgeniy Stepanov 70075620b3 [sanitizer] Never remove the last frame off the stack trace.
It can only make it worse.

llvm-svn: 221520
2014-11-07 12:03:07 +00:00
Alexey Samsonov fbaaed6b58 [Sanitizer] Introduce "stack_trace_format" runtime flag.
This flag can be used to specify the format of stack frames - user
can now provide a string with placeholders, which should be printed
for each stack frame with placeholders replaced with actual data.
For example "%p" will be replaced by PC, "%s" will be replaced by
the source file name etc.

"DEFAULT" value enforces default stack trace format currently used in
all the sanitizers except TSan.

This change also implements __sanitizer_print_stack_trace interface
function in TSan.

llvm-svn: 221469
2014-11-06 18:43:45 +00:00
Will Schmidt ae4236ac6a Use GET_CURRENT_FRAME() to calculate the memory layout for power. This works
for both PPC64 Big and Little endian modes, so also eliminates the need for
the BIG_ENDIAN/LITTLE_ENDIAN #ifdeffery.

By trial and error, it also looks like the kPPC64_ShadowOffset64 value is
valid using (1ULL << 41) for both BE and LE, so that #if/#elif/#endif block
has also been simplified.

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

llvm-svn: 221457
2014-11-06 14:58:06 +00:00
David Majnemer 3400563ea6 UBSan: Teach isDerivedFromAtOffset and findBaseAtOffset about vbases
When the __virtual_mask is set, __offset_flags >> __offset_shift yields
an offset into the vtable.  Dereferencing this vtable slot gets us the
vbase offset.

Adjust a test case to verify that this, in fact, works.

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

llvm-svn: 221445
2014-11-06 08:55:23 +00:00
Alexey Samsonov 70f3897b0a [Sanitizer] Introduce generic stack frame rendering machinery
Summary:
This commit introduces function __sanitizer::RenderFrame()
that allows to render the contents of AddressInfo (essentially, symbolized stack frame)
using the custom format string. This function can be used to
implement stack frame formatting for both ThreadSanitizer and
generic StackTrace::Print(), used in another places. This paves the
way towards allowing user to control the format of stack frames,
obtaining them in any format he desires, and/or enforcing the consistent
output from all sanitizers.

Test Plan: compiler-rt test suite

Reviewers: kcc

Reviewed By: kcc

Subscribers: llvm-commits

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

llvm-svn: 221409
2014-11-05 22:44:36 +00:00
Kuba Brecka fe4e7c1716 Fix failing allow_user_segv.cc test on OS X 10.10
The current ASan testcase Posix/allow_user_segv.cc expects SIGBUS to be triggered on 32-bit Darwin. This has apparently changed on 10.10 to trigger SIGSEGV instead, just as on 64-bit. Let's just install handlers for both SIGSEGV and SIGBUS instead of #ifdef'ing.

Reviewed at http://reviews.llvm.org/D6121

llvm-svn: 221381
2014-11-05 18:58:41 +00:00
Kuba Brecka 0078cea792 Extend the OS X pthread_get_stacksize_np workaround to 10.10
Fixes a failing ASan testcase (TestCases/stack-use-after-return.cc) on OS X 10.10.

Reviewed at http://reviews.llvm.org/D6120

llvm-svn: 221380
2014-11-05 18:55:38 +00:00
Kuba Brecka f4bdbde26f Extend Mac OS versions to Yosemite
This also fixes the test/asan/TestCases/Darwin/malloc_zone-protected.cc test failure on OS X 10.10.

Reviewed at http://reviews.llvm.org/D6119

llvm-svn: 221379
2014-11-05 18:53:22 +00:00
Peter Collingbourne f20091118c [dfsan] Add runtime function for aborting on indirect calls to
uninstrumented vararg functions.

llvm-svn: 221364
2014-11-05 17:21:11 +00:00
Peter Collingbourne 4da39395b0 [dfsan] Add libgo functions to ABI list.
llvm-svn: 221363
2014-11-05 17:21:08 +00:00
Peter Collingbourne 113ff7f309 [dfsan] Upgrade ABI list to Ubuntu 14.04.
This incorporates some of the newer functions used by (e.g.) the Go runtime.

llvm-svn: 221362
2014-11-05 17:21:06 +00:00
Peter Collingbourne 7e3c657f4a [dfsan] Modify build-libc-list.py to filter out local functions in generated
ABI list.

llvm-svn: 221361
2014-11-05 17:21:04 +00:00
Will Schmidt 626963187b When run on a ppc64le based platform, the check-sanitizer build looks for
objects with the powerpc64le name. i.e. asan-powerpc64le.a
This change allows those objects to be built.

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

llvm-svn: 221356
2014-11-05 16:35:23 +00:00
Renato Golin 883abab1e8 Disable XFAIL on ARM since the x86_64 specific code is isolated
llvm-svn: 221347
2014-11-05 14:44:58 +00:00
Jay Foad 70a3841a8f Get the Linux ptrace test working on PowerPC64
The test refers to user_regs_struct.rip so it can only ever have worked
on x86-64. Put this code inside an appropriate #if, and add a similar
case for PowerPC64. (If we do likewise for ARM we can probably remove
the XFAILs, but I have no way of testing that.)

Those changes are enough to get the test working for me on big-endian
PowerPC64 Fedora 19.

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

llvm-svn: 221337
2014-11-05 08:42:48 +00:00
Alexey Samsonov 860a1abf1d [TSan] Refactor/simplify ReportLocation structure.
# Make DataInfo (describing a global) a member of ReportLocation
    to avoid unnecessary copies and allocations.
  # Introduce a constructor and a factory method, so that
    all structure users don't have to go to internal allocator directly.
  # Remove unused fields (file/line).

No functionality change.

llvm-svn: 221302
2014-11-04 22:07:57 +00:00
Alexey Samsonov 0b622f1d64 Correct the usage of DataInfo structure in TSan
llvm-svn: 221297
2014-11-04 21:26:56 +00:00
Alexey Samsonov e3754634c0 [TSan] Make ReportStack contain __sanitizer::AddressInfo object.
AddressInfo contains the results of symbolization. Store this object
directly in the symbolized stack, instead of copying data around and
making unnecessary memory allocations.

No functionality change.

llvm-svn: 221294
2014-11-04 20:52:37 +00:00
Kostya Serebryany c5bd9810cc [asan] [mips] changed ShadowOffset32 for systems having 16kb PageSize; patch by Kumar Sukhani
llvm-svn: 221288
2014-11-04 19:46:15 +00:00
Alexey Samsonov 26ca05ad96 [Sanitizer] Get rid of unnecessary allocations in StripModuleName. NFC.
llvm-svn: 221287
2014-11-04 19:34:29 +00:00
Alexey Samsonov 3931dca7ec [TSan] Keep original function and filename in ReportStack.
TSan used to do the following transformations with data obtained
from the symbolizer:
1) Strip "__interceptor_" prefix from function name.
2) Use "strip_path_prefix" runtime flag to strip filepath.

Now these transformations are performed right before the stack trace
is printed, and ReportStack structure contains original information.

This seems like a right thing to do - stripping is a detail of report
formatting implementation, and should belong there. We should, for
example, use original path to source file when we apply suppressions.

This change also make "strip_path_prefix" flag behavior in TSan
consistent with all the other sanitizers - now it should actually
match *the prefix* of path, not some substring. E.g. earlier TSan
would turn "/usr/lib/libfoo.so" into "libfoo.so" even if strip_path_prefix
was "/lib/".

Finally, strings obtained from symbolizer come from internal allocator,
and "stripping" them early by incrementing a "char*" ensures they can
never be properly deallocated, which is a bug.

llvm-svn: 221283
2014-11-04 18:41:38 +00:00
Kuba Brecka 6c22aec23c Use @rpath as LC_ID_DYLIB for ASan dylib on OS X
Change the LC_ID_DYLIB of ASan's dynamic libraries on OS X to be set to "@rpath/libclang_rt.asan_osx_dynamic.dylib" and similarly for iossim. Clang driver then sets the "-rpath" to be the real path to where clang currently has the dylib (because clang uses the relative path to its current executable). This means if you move the compiler or install the binary release, -fsanitize=address will link to the proper library.

Reviewed at http://reviews.llvm.org/D6018

llvm-svn: 221278
2014-11-04 17:34:50 +00:00
Alexey Samsonov 8f1632d5c1 [TSan] Don't strip binary/library name until the moment we print it.
This commit changes the place where TSan runtime turns full path
to binary or shared library into its basename
(/usr/foo/mybinary -> mybinary). Instead of doing it as early as possible
(when we obtained the full path from the symbolizer), we now do it as
late as possible (right before printing the error report).

This seems like a right thing to do - stripping to basename is a detail
of report formatting implementation, and should belong there. Also, we
might need the full path at some point - for example, to match the
suppressions.

llvm-svn: 221225
2014-11-04 01:55:20 +00:00
Alexey Samsonov 7acb67607b [TSan] Remove bogus unused global variables
llvm-svn: 221195
2014-11-03 22:46:13 +00:00
Alexey Samsonov 40733a8024 [TSan] Use StackTrace from sanitizer_common where applicable
Summary:
This change removes `__tsan::StackTrace` class. There are
now three alternatives:
  # Lightweight `__sanitizer::StackTrace`, which doesn't own a buffer
  of PCs. It is used in functions that need stack traces in read-only
  mode, and helps to prevent unnecessary allocations/copies (e.g.
  for StackTraces fetched from StackDepot).
  # `__sanitizer::BufferedStackTrace`, which stores buffer of PCs in
  a constant array. It is used in TraceHeader (non-Go version)
  # `__tsan::VarSizeStackTrace`, which owns buffer of PCs, dynamically
  allocated via TSan internal allocator.

Test Plan: compiler-rt test suite

Reviewers: dvyukov, kcc

Reviewed By: kcc

Subscribers: llvm-commits, kcc

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

llvm-svn: 221194
2014-11-03 22:23:44 +00:00
Alexey Samsonov 46ecdeecc4 [TSan} Build Go version with -std=c++11
llvm-svn: 221192
2014-11-03 22:18:12 +00:00
Alexey Samsonov e6bbcfa3df [TSan] Fix signed-compare warning in the unit test
llvm-svn: 221190
2014-11-03 22:17:39 +00:00
Kostya Serebryany 40aa4a26d1 [asan] increase the initial buffer size in caller-callee dumper
llvm-svn: 220991
2014-10-31 19:49:46 +00:00
Kostya Serebryany b6eae0c2bc [asan] run-time part of the caller-callee coverage instrumentation
llvm-svn: 220975
2014-10-31 17:19:11 +00:00
Peter Collingbourne b190e1b74b Update __dfsw_s{,n}printf custom functions for new calling convention.
Differential Revision: http://reviews.llvm.org/D6029

llvm-svn: 220907
2014-10-30 13:23:01 +00:00
Aaron Ballman d98e197386 Reverting r220517; it seems this broke check-asan.
llvm-svn: 220869
2014-10-29 19:25:20 +00:00
Adrian Prantl 44ed3d04bf Unbreak the darwin build.
Patch by Ismail Pazarbasi!

llvm-svn: 220683
2014-10-27 16:20:59 +00:00
Viktor Kutuzov c8f3435f0e [Tsan] Enable thread sanitizer tests on FreeBSD
Differential Revision: http://reviews.llvm.org/D5995

llvm-svn: 220676
2014-10-27 11:28:53 +00:00
Viktor Kutuzov adf81dbcc6 [Tsan] Fix references to renamed variables in DPrintf()
Differential Revision: http://reviews.llvm.org/D5993

llvm-svn: 220674
2014-10-27 11:22:24 +00:00
Viktor Kutuzov 9deb007191 [Tsan] Make calloc() to not track allocated space unless thread is completely initialized
Differential Revision: http://reviews.llvm.org/D5992

llvm-svn: 220673
2014-10-27 11:19:08 +00:00
Viktor Kutuzov a58fed9ab7 [Tsan] Fix guessing data range on FreeBSD
Differential Revision: http://reviews.llvm.org/D5990

llvm-svn: 220672
2014-10-27 11:14:24 +00:00
Alexey Samsonov e853b4f2e4 [Sanitizer] Return code that calculates hash for stacktrace back to StackDepot implementation
llvm-svn: 220663
2014-10-27 03:10:27 +00:00
Hans Wennborg f89a3f8623 Try to fix the Windows build after r220637
llvm-svn: 220643
2014-10-26 19:27:02 +00:00
Alexey Samsonov 3741ab82ba Change StackDepot interface to use StackTrace more extensively
llvm-svn: 220637
2014-10-26 06:23:07 +00:00
Alexey Samsonov 6e7af8156f Fixup deadlock sanitizer after r220635
llvm-svn: 220636
2014-10-26 05:43:17 +00:00
Alexey Samsonov 9c85927012 [Sanitizer] Make StackTrace a lightweight reference to array of PCs, and
introduce a BufferedStackTrace class, which owns this array.

Summary:
This change splits __sanitizer::StackTrace class into a lightweight
__sanitizer::StackTrace, which doesn't own array of PCs, and BufferedStackTrace,
which owns it. This would allow us to simplify the interface of StackDepot,
and eventually merge __sanitizer::StackTrace with __tsan::StackTrace.

Test Plan: regression test suite.

Reviewers: kcc, dvyukov

Reviewed By: dvyukov

Subscribers: llvm-commits

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

llvm-svn: 220635
2014-10-26 03:35:14 +00:00
Saleem Abdulrasool d888169d75 builtins: avoid endian.h in favour of compiler builtins
Use the __BYTE_ORDER__ macro which has been available in GCC since 4.6 and is
available in clang as well.

llvm-svn: 220626
2014-10-25 20:54:51 +00:00
Alexey Samsonov 3ca50c34ec Add runtime flag 'symbolize_inline_frames' to disable symbolization of inlined frames done in llvm-symbolizer
llvm-svn: 220582
2014-10-24 18:34:43 +00:00
Dmitry Vyukov e9a5f03716 tsan: support mmap(MAP_32BIT)
Allow user memory in the first TB of address space.
This also enabled non-pie binaries and freebsd.
Fixes issue:
https://code.google.com/p/thread-sanitizer/issues/detail?id=5

llvm-svn: 220571
2014-10-24 17:07:29 +00:00
Viktor Kutuzov a836924be4 [Tsan] Do not intercept non-FreeBSD functions on FreeBSD
Differential Revision: http://reviews.llvm.org/D5858

llvm-svn: 220554
2014-10-24 10:55:03 +00:00
Viktor Kutuzov f266601ce9 [Tsan] Fix the thread_name tests to build on FreeBSD
Differential Revision: http://reviews.llvm.org/D5855

llvm-svn: 220552
2014-10-24 09:27:34 +00:00
Viktor Kutuzov 6a9dec2aa2 [Tsan] Intercept pthread_set_name_np on FreeBSD
Differential Revision: http://reviews.llvm.org/D5932

llvm-svn: 220551
2014-10-24 09:23:06 +00:00
Viktor Kutuzov 9003426e2f [Tsan] Fix the signal_recursive.cc test to build on FreeBSD
Differential Revision: http://reviews.llvm.org/D5841

llvm-svn: 220550
2014-10-24 09:20:20 +00:00
Evgeniy Stepanov 7900202e14 [sanitizer] Add a bunch of sanity checks.
llvm-svn: 220528
2014-10-23 22:29:51 +00:00
Aaron Ballman e927a17022 Cmake variables are global, which is why we would get crud like /machine:X86 in the list of compiler options for MSVC. Clear out the variable before attempting to enumerate arguments and set them.
llvm-svn: 220522
2014-10-23 22:13:52 +00:00