Alexey Samsonov
4431d2d566
Enable pipefail for ASan tests
...
llvm-svn: 187877
2013-08-07 09:14:30 +00:00
Sergey Matveev
6459a370a7
[lsan] Add leak_check_at_exit flag.
...
We needed a way to tell LSan to invoke leak checking only if __do_leak_check()
is called explicitly. This can now be achieved by setting
leak_check_at_exit=false.
llvm-svn: 187578
2013-08-01 14:57:07 +00:00
Evgeniy Stepanov
d8a1798b47
[asan] Limit fake stack size to a reasonable value when running with unlimited stack.
...
llvm-svn: 187411
2013-07-30 11:50:26 +00:00
Rafael Espindola
48e479291e
disable pipefail on asan for now.
...
llvm-svn: 187269
2013-07-26 23:19:33 +00:00
Sergey Matveev
9c012165ad
[lsan] Make __lsan_do_leak_check() honor the detect_leaks flag.
...
Also move detect_leaks to common flags.
llvm-svn: 186821
2013-07-22 12:38:17 +00:00
Hans Wennborg
2e304b6ffd
Use --driver-mode=g++ instead of -ccc-cxx; required after Clang r186605
...
llvm-svn: 186607
2013-07-18 20:48:50 +00:00
Alexey Samsonov
79d79da0e1
[ASan] Fix leaks in ASan tests found by LSan
...
llvm-svn: 186577
2013-07-18 12:59:52 +00:00
Alexey Samsonov
9916aa2d95
[Sanitizer] move strcpy and strncpy to common interceptors
...
llvm-svn: 186408
2013-07-16 12:51:53 +00:00
Timur Iskhodzhanov
4245f78fdd
[ASan] Use less shadow on Win 32-bit
...
llvm-svn: 186393
2013-07-16 09:47:39 +00:00
Alexander Potapenko
27155281db
[ASan] Cache the OSX version to avoid calling sysctl() on every GetMacosVersion() call.
...
llvm-svn: 186389
2013-07-16 09:29:48 +00:00
Alexander Potapenko
b137ca157b
[ASan] Add support for OS X Mavericks to GetMacosVersion.
...
llvm-svn: 186386
2013-07-16 08:35:42 +00:00
Timur Iskhodzhanov
d7eb67774e
Fix check_lint warnings in sanitizers' runtime libraries
...
llvm-svn: 186328
2013-07-15 16:11:39 +00:00
Chandler Carruth
1a48dc5ed6
Fix a veritable conucopia of bugs in the readdir_r interceptors.
...
First, the reason I came here: I forgot to look at readdir64_r which had
the exact same bug as readdir_r. However, upon applying the same
quick-fix and testing it I discovered that it still didn't work at all.
As a consequence, I spent some time studying the code and thinking about
it and fixed several other problems.
Second, the code was checking for a null entry and result pointer, but
there is no indication that null pointers are viable here. Certainly,
the spec makes it extremely clear that there is no non-error case where
the implementation of readdir_r fails to dereference the 'result'
pointer and store NULL to it. Thus, our checking for a non-null 'result'
pointer before reflecting that write in the instrumentation was
trivially dead. Remove it.
Third, the interceptor was marking the write to the actual dirent struct
by looking at the entry pointer, but nothing in the spec requires that
the dirent struct written is actually written into the entry structure
provided. A threadlocal buffer would be just as conforming, and the spec
goes out of its way to say the pointer to the *actual* result dirent
struct is stored into *result, so *that* is where the interceptor should
reflect a write occuring. This also obviates the need to even consider
whether the 'entry' parameter is null.
Fourth, I got to the bottom of why nothing at all worked in readdir64_r
-- the interceptor structure for dirent64 was completely wrong in that
it was the same as dirent. I fixed this struct to be correct (64-bit
inode and 64-bit offset! just a 64-bit offset isn't enough!) and added
several missing tests for the size and layout of this struct.
llvm-svn: 186109
2013-07-11 18:51:40 +00:00
Chandler Carruth
28c1b294b8
Fix a bug in the readdir_r interceptor: when we reach the end of the
...
directory stream, the entry is not written to, instead *result is set to
NULL and the entry is not written to at all.
I'm still somewhat suspicious of the correct instrumention here --
I feel like it should be marking the written range as the pointer in
*result and the length (*result)->d_reclen in case the implementation
decides not to use the passed-in entry (if that's even allowed).
Finally, the definition of 'struct dirent' analog used in the
interceptor is wrong in 32-bit mode with _FILE_OFFSET_BITS=64 as it hard
codes the use of a pointer-sized offset.
I've added a somewhat goofy test for the bug I fixed via ASan --
suggestions on how to better test the interceptor logic itself welcome.
llvm-svn: 185998
2013-07-10 09:50:29 +00:00
Peter Collingbourne
2c60538ddd
[asan] Update blacklists to use categories.
...
Differential Revision: http://llvm-reviews.chandlerc.com/D1094
llvm-svn: 185980
2013-07-09 22:04:28 +00:00
Evgeniy Stepanov
faba61a7bc
[sanitizer] Support GLOB_ALTDIRFUNC in glob interceptor.
...
llvm-svn: 185932
2013-07-09 12:07:59 +00:00
Evgeniy Stepanov
77ef78a0a5
[sanitizer] Intercept realpath and canonicalize_file_name.
...
Handle realpath(path, NULL) form.
llvm-svn: 185921
2013-07-09 09:53:37 +00:00
Evgeniy Stepanov
8495b84076
[asan] Fix windows build.
...
llvm-svn: 185917
2013-07-09 09:29:19 +00:00
Sergey Matveev
bdeff959a1
[lsan] Handle fork() correctly.
...
Update the main thread's os_id on every pthread_create, and before
initiating leak checking. This ensures that we have the correct os_id even if we
have forked after Init().
llvm-svn: 185815
2013-07-08 12:57:24 +00:00
Alexander Potapenko
4f73dea69d
[ASan] Close stderr before launching atos in asan_symbolize.py
...
llvm-svn: 185631
2013-07-04 14:21:49 +00:00
Alexander Potapenko
d0c91acb58
[ASan] Do not protect the malloc zone created by malloc_zone_create() on Snow Leopard and earlier systems.
...
Fixes https://code.google.com/p/address-sanitizer/issues/detail?id=208
llvm-svn: 185621
2013-07-04 10:16:12 +00:00
Alexey Samsonov
4798a08df8
[ASan] try to fix Windows build
...
llvm-svn: 185345
2013-07-01 16:38:38 +00:00
Alexey Samsonov
9857ca2564
[ASan] Properly disable strict init-order checking when pthread_create is called
...
llvm-svn: 185342
2013-07-01 16:16:41 +00:00
Alexander Potapenko
0fde89f2aa
[ASan] Cache atos processes to make Darwin symbolication faster.
...
Patch by Jesse Ruderman<jruderman@gmail.com>
llvm-svn: 185325
2013-07-01 10:51:31 +00:00
Alexey Samsonov
c3832f7788
[ASan] Add sanity test for asan_symbolize.py script
...
llvm-svn: 185318
2013-07-01 09:15:19 +00:00
Alexey Samsonov
cc510707af
[ASan] Remove leading underscores from function names in output tests
...
llvm-svn: 185315
2013-07-01 08:41:45 +00:00
Alexey Samsonov
8918140809
Hide mlock/munlock info message under verbosity flag.
...
llvm-svn: 185314
2013-07-01 08:25:29 +00:00
Alexey Samsonov
e71f37c1cd
Define the path to llvm-symbolizer tool in a common config to reduce copy-paste
...
llvm-svn: 185286
2013-06-30 14:47:38 +00:00
Alexey Samsonov
13f89cd19b
[ASan] Remove %symbolize from lit tests: we now use external symbolizer instead of python script
...
llvm-svn: 185163
2013-06-28 15:52:44 +00:00
Alexey Samsonov
002d764f21
[ASan] Migrate lit tests to external symbolizer from asan_symbolize.py script
...
llvm-svn: 185148
2013-06-28 12:50:12 +00:00
Evgeniy Stepanov
dec0f76c14
[sanitizer] Intercept ptrace.
...
llvm-svn: 185142
2013-06-28 11:02:43 +00:00
Alexander Potapenko
2b064a2b4e
[ASan][OSX] Make sure the zones created by malloc_create_zone() are write-protected.
...
Add a test.
llvm-svn: 185140
2013-06-28 10:01:09 +00:00
Alexander Potapenko
593f833e9b
[ASan][OSX] Fix the incorrect malloc_create_zone() implementation that led to out-of-bounds mprotect()s
...
(https://code.google.com/p/address-sanitizer/issues/detail?id=203 )
Add a test.
llvm-svn: 185138
2013-06-28 09:21:31 +00:00
Kostya Serebryany
6a068a715d
[asan] initialize fake_stack lazily and increase its maximal size. This makes -fsanitize=address,use-after-return more robust: all SPEC tests pass now. In the default mode thread stacks become a bit smaller.
...
llvm-svn: 184934
2013-06-26 12:16:05 +00:00
Evgeniy Stepanov
982d56abb8
[sanitizer] Move log_path to common flag and use it in MSan.
...
llvm-svn: 184836
2013-06-25 13:50:44 +00:00
Evgeniy Stepanov
0e8053af08
[sanitizer] Intercept readv, preadv, writev, pwritev.
...
llvm-svn: 184717
2013-06-24 10:43:23 +00:00
Sergey Matveev
4e0215a71c
Revert to C-style callbacks for iteration over allocator chunks.
...
Also clean up LSan code, fix some comments and replace void* with uptr
to bring down the number of reinterpret_casts.
llvm-svn: 184700
2013-06-24 08:34:50 +00:00
Alexey Samsonov
43937b3758
Add cmake rules for building LSan common on Mac OS
...
llvm-svn: 184639
2013-06-22 16:33:52 +00:00
Sergey Matveev
38fa1ff710
[lsan] Try REALLY hard to fix Win build.
...
llvm-svn: 184557
2013-06-21 15:50:49 +00:00
Sergey Matveev
b94d5e2d1c
[asan] Move lsan_disabled out of thread context.
...
Fix for the case where disabler is used in pthread key destructor.
llvm-svn: 184553
2013-06-21 14:51:52 +00:00
Alexey Samsonov
a9db3f9757
[ASan] reimplement strdup() interceptor to get nicer stack traces for memory chunks allocated there
...
llvm-svn: 184546
2013-06-21 14:41:59 +00:00
Alexey Samsonov
f9e6624663
[ASan] make test for LSan annotations Linux-only for now
...
llvm-svn: 184541
2013-06-21 12:18:52 +00:00
Alexey Samsonov
ad25b50a89
[ASan] Check that ASan user may include and use LSan headers
...
llvm-svn: 184540
2013-06-21 11:11:44 +00:00
Sergey Matveev
5e6b9eccce
[asan] Define LSan annotations as no-ops if leak detection is not supported.
...
llvm-svn: 184422
2013-06-20 13:39:42 +00:00
Alexey Samsonov
686c229b03
[ASan] Clear allocation magic value before recycling the chunk. This led to spurious crashes in LSan when it walked through reused chunks. Don't know how to create not-brittle test case for this.
...
llvm-svn: 184404
2013-06-20 08:13:06 +00:00
Alexander Potapenko
29b9fcf0a8
[ASan] Delete excessive 'extern "C"' around mlock* interceptors.
...
llvm-svn: 184294
2013-06-19 11:36:51 +00:00
Evgeniy Stepanov
8fa046e288
[sanitizer] Symbolic ioctl names.
...
Replace hardcoded ioctl request ids with symbolic names.
Disable certain ioctls on platforms where such names are not found in the
system headers.
Fix a bug in ioctl_lookup.
Reenable ioctl test on Mac.
llvm-svn: 184183
2013-06-18 09:22:24 +00:00
Alexey Samsonov
7e325fb477
Properly install LSan interface header, rely on sanitizer header presence in lit tests
...
llvm-svn: 183977
2013-06-14 11:45:36 +00:00
Alexey Samsonov
b0d92b3312
[Sanitizer] Rename InternalVector to InternalMmapVector
...
llvm-svn: 183972
2013-06-14 09:59:40 +00:00
Richard Trieu
5685aa6845
Fix broken header guard.
...
llvm-svn: 183873
2013-06-12 22:37:22 +00:00
Sergey Matveev
978460c12c
[lsan] Harmonized some naming inconsistencies.
...
llvm-svn: 183748
2013-06-11 15:26:20 +00:00
Alexey Samsonov
c8e7364763
[Sanitizer] support running external llvm-symbolizer on Mac
...
llvm-svn: 183730
2013-06-11 08:13:36 +00:00
Alexander Potapenko
152f7edf24
[ASan] Fix unset-insert-libraries-on-exec.cc on 32-bit Darwin.
...
The test used to execute a 64-bit /bin/bash binary and preload a 32-bit dynamic library into it.
Now the arch-specific version of echo-env is executed instead.
llvm-svn: 183662
2013-06-10 14:47:43 +00:00
Alexey Samsonov
f67191b4c3
[ASan] mark ioctl test as xfailing on darwin. remove redundant semicolons
...
llvm-svn: 183655
2013-06-10 14:17:08 +00:00
Kostya Serebryany
02062becea
[asan] fix Android build (mark asan_malloc_usable_size as an interface function)
...
llvm-svn: 183651
2013-06-10 13:28:33 +00:00
Kostya Serebryany
e71982d589
[asan] fix the bug with memalign and malloc_usable_size ( http://code.google.com/p/address-sanitizer/issues/detail?id=193 ); also fix lint
...
llvm-svn: 183647
2013-06-10 10:46:27 +00:00
Alexey Samsonov
4c0ea93725
[ASan] don't use -m{32,64} flag in test case, as it can be run in both 32- and 64-bit modes
...
llvm-svn: 183638
2013-06-10 07:55:12 +00:00
Alexey Samsonov
4fdf8d66a9
[ASan] fix test case to use absolute paths
...
llvm-svn: 183527
2013-06-07 15:44:21 +00:00
Alexander Potapenko
6af3fce55e
[ASan] An early return from InitializeAsanInterceptors() on Mac has been considered unobvious.
...
Remove it and replace ASAN_INTERCEPT_FUNC with a no-op if SANITIZER_MAC==1.
llvm-svn: 183524
2013-06-07 15:10:02 +00:00
Evgeniy Stepanov
0b1f41b6f4
[sanitizer] ioctl interceptor.
...
ASan: disabled by default
MSan: enabled by default
TSan: disabled
llvm-svn: 183517
2013-06-07 13:00:47 +00:00
Alexey Samsonov
575c599554
Drop support for 32-bit PowerPC in sanitizer tools.
...
llvm-svn: 183499
2013-06-07 09:44:43 +00:00
Alexey Samsonov
889e3ab83c
[ASan] create separate configs for running ASan lit tests in both 32- and 64-bit mode. Clean up RUN-lines in tests.
...
llvm-svn: 183498
2013-06-07 09:38:55 +00:00
Sergey Matveev
1c4e214c32
[lsan] Put SANITIZER_INTERFACE_ATTRIBUTE on LSan interface functions.
...
llvm-svn: 183429
2013-06-06 18:40:55 +00:00
Sergey Matveev
ecc4f5ba8e
[lsan] Implement __lsan_ignore_object().
...
Leak annotation similar to HeapChecker's IgnoreObject().
llvm-svn: 183412
2013-06-06 14:17:56 +00:00
Alexey Samsonov
e674320ade
[ASan] make pthread_getschedparam test more robust
...
llvm-svn: 183411
2013-06-06 14:08:40 +00:00
Alexey Samsonov
f6630ecee9
Simplify lit configs for asan/lsan/msan unit tests
...
llvm-svn: 183410
2013-06-06 13:48:20 +00:00
Alexey Samsonov
c05aba7eaa
[ASan] create common autogenerated config for running compiler-rt unit tests, and use it in ASan
...
llvm-svn: 183401
2013-06-06 12:48:20 +00:00
Alexey Samsonov
6a65b18992
[ASan] lit tests: create common autogenerated config for running compiler-rt lit tests, and use it in ASan
...
llvm-svn: 183400
2013-06-06 12:35:48 +00:00
Alexey Samsonov
2874f70250
[ASan] move all lit_tests under TestCases
...
llvm-svn: 183395
2013-06-06 09:23:34 +00:00
Alexey Samsonov
b42b2f5c69
[ASan] Add a few tests for use-after-scope mode
...
llvm-svn: 183391
2013-06-06 08:30:26 +00:00
Alexey Samsonov
7a75e16c27
[ASan] One more fix for realloc: check that reallocated chunk is valid before calling memcpy
...
llvm-svn: 183390
2013-06-06 08:25:31 +00:00
Alexey Samsonov
87a59e5652
[ASan] make free_hook_realloc test more robust
...
llvm-svn: 183387
2013-06-06 07:58:00 +00:00
Evgeniy Stepanov
56050e8f69
[sanitizer] Fix __sanitizer_unaligned_* to work with unaligned data types.
...
llvm-svn: 183224
2013-06-04 13:49:10 +00:00
Alexey Samsonov
8f5138a23f
Call __asan_free_hook() before marking the chunk quarantinned
...
Summary:
With this change, the user may safely call __asan_get_ownership()
from malloc/free hooks and assume it would return "true". If there is a
realloc/free race, free hook might be called twice, but I think it's acceptable,
as it's a data race and would later be reported anyway.
This change also fixes a bug when failing realloc incorrectly marked the
original memory as "quarantinned".
Reviewers: timurrrr, kcc, samsonov
Reviewed By: samsonov
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D913
llvm-svn: 183220
2013-06-04 12:19:31 +00:00
Sergey Matveev
b256ac7584
[asan] Fix invalid thread registry access when checking if LSan is disabled.
...
llvm-svn: 183218
2013-06-04 10:39:24 +00:00
Timur Iskhodzhanov
baf90ccfac
Fix ALIGNED misuse in asan_thread.cc (built on all platforms); also, add a comment to the ALIGNED macro describing the correct usage
...
llvm-svn: 183214
2013-06-04 08:25:17 +00:00
Kostya Serebryany
c1aa0e8f69
[asan] ASan Linux MIPS32 support (compiler-rt part), patch by Jyun-Yan Y
...
llvm-svn: 183105
2013-06-03 14:49:25 +00:00
Sergey Matveev
17ee1abfa7
[lsan] Add __lsan_disable() and __lsan_enable().
...
Objects allocated after a call to __lsan_disable() will be treated as
live memory. Also add a ScopedDisabler.
llvm-svn: 183099
2013-06-03 11:21:34 +00:00
Alexander Potapenko
41cd6102e9
[ASan] Do not buffer stdin in asan_symbolize.py
...
llvm-svn: 183006
2013-05-31 14:55:06 +00:00
Sergey Matveev
69f11803ec
[lsan] Use the fast version of GetBlockBegin for leak checking in LSan and ASan.
...
llvm-svn: 182994
2013-05-31 11:13:45 +00:00
Kostya Serebryany
831a1d7cec
[sanitizer] introduce LargeMmapAllocator::GetBlockBeginFastSingleThreaded, required for LeakSanitizer to work faster. Also fix lint.
...
llvm-svn: 182917
2013-05-30 08:43:30 +00:00
Alexander Potapenko
a8b41762e4
[ASan] Minor cleanup: remove a couple of unused variables.
...
llvm-svn: 182915
2013-05-30 07:30:07 +00:00
Timur Iskhodzhanov
013da5cb37
Replaced 'bool .* = 0;' with '... = false;'
...
llvm-svn: 182868
2013-05-29 17:26:25 +00:00
Sergey Matveev
6a0c722c23
[asan] Fix r182858.
...
llvm-svn: 182862
2013-05-29 15:31:52 +00:00
Sergey Matveev
4161813a50
[asan] Fix r182854: run the unpoison_tls test only on Linux.
...
llvm-svn: 182858
2013-05-29 14:37:04 +00:00
Timur Iskhodzhanov
cc61eefd4b
Fix MSVC W3 compiler warnings
...
llvm-svn: 182857
2013-05-29 14:11:44 +00:00
Sergey Matveev
09886cd17a
[asan] Make ASan report the correct thread address ranges to LSan.
...
This CL enables thread support in LSan when used on top of ASan.
llvm-svn: 182854
2013-05-29 13:09:44 +00:00
Evgeniy Stepanov
08f662845d
[sanitizer] Share TSan accept & accept4 interceptors with other sanitizers.
...
llvm-svn: 182835
2013-05-29 09:09:58 +00:00
Sergey Matveev
39e8a6d87e
[lsan] Begin converting LSan tests to output tests.
...
In this CL all old tests are removed and one LIT test is added.
llvm-svn: 182730
2013-05-27 11:41:46 +00:00
Alexey Samsonov
9c2bcf8c15
Improve support for compiler-rt tests in CMake build.
...
Now compiler-rt tests run correctly if compiler-rt is checked out into
arbitrary directory (not necessarily projects/compiler-rt).
Patch by Greg Fitzgerald!
llvm-svn: 182726
2013-05-27 09:35:24 +00:00
Alexey Samsonov
646ec67e25
Disable init-order checking before destructors are run.
...
We don't want to report initialization-order bugs when a destructor of a global
variable accesses dynamically initialized global from another
(not necessarily initialized) module. We do this by intercepting __cxa_atexit and
registrering our own callback that unpoisons shadow for all dynamically initialized
global variables.
llvm-svn: 182637
2013-05-24 11:46:56 +00:00
Alexander Potapenko
fd7d9f45dd
[ASan] Rename __asan_preinit to __local_asan_preinit to avoid warnings from the linker which is trying to export all the __asan_* symbols
...
llvm-svn: 182567
2013-05-23 09:15:20 +00:00
Kostya Serebryany
6ca6ba2f2c
[asan] fix the reported PCs for powerpc64
...
llvm-svn: 182477
2013-05-22 14:21:34 +00:00
Alexey Samsonov
49eb5700e2
Revert r182465 and add lsan-common library to makefile-based build
...
llvm-svn: 182470
2013-05-22 13:20:37 +00:00
Alexey Samsonov
155dd46e04
[ASan] Temporary remove leak checking from ASan, while we don't have makefile-based build for LSan
...
llvm-svn: 182465
2013-05-22 12:44:57 +00:00
Kostya Serebryany
15fd53fa39
[asan] enhance stack-overflow.cc test: check that the location frame is properly symbolized
...
llvm-svn: 182463
2013-05-22 11:00:56 +00:00
Kostya Serebryany
b93ae15205
[asan] attempting to fix the debian bot (on ubuntu the test builds; on debian it complains that _SC_PAGESIZE is unknown)
...
llvm-svn: 182462
2013-05-22 10:38:51 +00:00
Kostya Serebryany
62debd6d6a
[asan] fix dlclose-test to work with non-4K pages. Properly disable interface_symbols_linux on non-x86
...
llvm-svn: 182461
2013-05-22 10:20:10 +00:00
Kostya Serebryany
8410a867eb
[asan] workaround for asan bug 189 (swapcontext followed by throw gets OOM kill). Also, disable swapcontext_test on non-x86. Fix lint
...
llvm-svn: 182456
2013-05-22 08:54:30 +00:00
Sergey Matveev
20ccf95f80
[lsan] Invoke leak detection with atexit().
...
Keeps it consistent between ASan and LSan.
llvm-svn: 182399
2013-05-21 17:56:45 +00:00
Sergey Matveev
17f5705d3c
[asan] Do not invoke LSan hooks unless CAN_SANITIZE_LEAKS.
...
llvm-svn: 182389
2013-05-21 15:35:34 +00:00
Sergey Matveev
8c235f40d7
[asan] LSan hooks in asan_rtl.
...
llvm-svn: 182384
2013-05-21 14:15:35 +00:00
Sergey Matveev
620744556a
[lsan] Change CMakeLists to build the common LSan module for ASan.
...
Also, define CAN_SANITIZE_LEAKS.
llvm-svn: 182383
2013-05-21 14:12:11 +00:00
Alexey Samsonov
b99085b0b8
[MSan] Add empty default blacklist for MSan
...
llvm-svn: 182382
2013-05-21 13:55:56 +00:00
Alexey Samsonov
e838135b6c
[ASan] create default (empty) ASan blacklist file in resource directory
...
llvm-svn: 182380
2013-05-21 13:48:27 +00:00
Sergey Matveev
7159b2a382
[asan] LSan hooks in asan_allocator2.cc
...
llvm-svn: 182379
2013-05-21 13:46:41 +00:00
Sergey Matveev
65dd62abe5
[asan] LSan hooks in asan_thread.cc
...
llvm-svn: 182378
2013-05-21 13:40:13 +00:00
Alexey Samsonov
3677b18388
[ASan] Mark init-order test as XFAIL on Darwin
...
llvm-svn: 182365
2013-05-21 10:11:17 +00:00
Alexey Samsonov
af456d0c40
[ASan] Don't run fast unwinder tests on 32-bit Linux as fast unwinder may be unexpectedly smart on some hosts
...
llvm-svn: 182363
2013-05-21 09:35:48 +00:00
Alexey Samsonov
1c26f007ed
[ASan] Mark some tests as working only on x86_64 and i386 arches
...
llvm-svn: 182360
2013-05-21 09:01:13 +00:00
Alexey Samsonov
4ca93997f7
Add lit config feature <target>-supported-target to mark target-specific tests
...
llvm-svn: 182355
2013-05-21 08:22:03 +00:00
Evgeniy Stepanov
970be35808
[sanitizer] Intercept pthread_getschedparam.
...
llvm-svn: 182353
2013-05-21 08:12:08 +00:00
Timur Iskhodzhanov
67c918a424
Fix realloc'ing freed/invalid pointers
...
See https://code.google.com/p/address-sanitizer/issues/detail?id=187 for the details
llvm-svn: 182255
2013-05-20 13:05:58 +00:00
Sergey Matveev
6a6c5b6dee
[asan] Modify ASan metadata atomically.
...
We need this to avoid races when ASan and LSan are used together.
llvm-svn: 182252
2013-05-20 11:25:18 +00:00
Timur Iskhodzhanov
667cae7b69
[ASan] Remove an unused ChunkBase field
...
Also fix wrong alignment maths and an outdated comment
llvm-svn: 182238
2013-05-20 08:20:17 +00:00
Kostya Serebryany
3469375e4f
[sanitizer] factor out ByteMap from SizeClassAllocator32 so that it can be later replaced with a more memory-efficient implementation on 64-bit.
...
llvm-svn: 182234
2013-05-20 07:29:21 +00:00
Timur Iskhodzhanov
836a4f3643
Replace CHECK(a == b); with CHECK_EQ(a, b); throughout asan_allocator2.cc
...
llvm-svn: 182198
2013-05-18 18:27:33 +00:00
Peter Collingbourne
ffaf2eac4d
[nolibc] Move all platforms to internal_getpid.
...
Before, we had an unused internal_getpid function for Linux, and a
platform-independent GetPid function. To make the naming conventions
consistent for syscall-like functions, the GetPid syscall wrapper
in sanitizer_posix.cc is moved to sanitizer_mac.cc, and GetPid is
renamed to internal_getpid, bringing the Linux variant into use.
llvm-svn: 182132
2013-05-17 16:56:53 +00:00
Peter Collingbourne
6d4a7d3723
[nolibc] Begin moving sanitizer_common's libc-dependent code to a separate library
...
Introduce a new object library, RTSanitizerCommonLibc, which will contain
the subset of sanitizer_common with libc dependencies. RTSanitizerCommon
contains the remainder of sanitizer_common, and is intended to have no
libc dependencies. Begin moving code to RTSanitizerCommonLibc, starting
with sanitizer_common.cc, whose libc-dependent portion is moved to
sanitizer_common_libcdep.cc, the first member of the new library.
This split affects the CMake build only. The makefile build continues
to produce the full sanitizer_common library.
llvm-svn: 182118
2013-05-17 16:17:19 +00:00
Alexander Potapenko
dd3c583211
[ASan] Make the regression test for time(NULL) Linux-specific, as it crashes on Darwin (and the problem used to occur on Linux).
...
Do not use zero-based shadow for the time() test.
llvm-svn: 182107
2013-05-17 15:11:26 +00:00
Alexander Potapenko
00b44ba778
[ASan] Fix allow_user_segv.cc on Darwin (32-bit build required a SIGBUS handler instead of the SIGSEGV one)
...
llvm-svn: 182080
2013-05-17 08:08:50 +00:00
Alexander Potapenko
12d09f3a3d
[ASan] Fix init-order-dlopen.cc to pass under Mac OS.
...
llvm-svn: 182010
2013-05-16 14:51:01 +00:00
Alexander Potapenko
3917fe0d94
[ASan] Fix interface_symbols_darwin to pass a correct flag to nm.
...
llvm-svn: 182008
2013-05-16 13:49:12 +00:00
Kostya Serebryany
aaf7275677
[asan] symbolize when possible, even if ASAN_SYMBOLIZER_PATH is not provided. On Linux this will use dl_iterate_phdr instead of /proc/self/maps, even if the symbolizer is not installed
...
llvm-svn: 182005
2013-05-16 13:04:29 +00:00
Kostya Serebryany
b7ca536888
[asan] fix ShadowGapTest on PowerPC64
...
llvm-svn: 181991
2013-05-16 07:54:28 +00:00
Kostya Serebryany
2b824f3575
[asan] disable BuiltinLongJmpTest on PowerPC
...
llvm-svn: 181890
2013-05-15 15:01:14 +00:00
Kostya Serebryany
2b42716213
[asan] fix powerpc build and one test; fix lint
...
llvm-svn: 181881
2013-05-15 12:36:29 +00:00
Evgeniy Stepanov
f1efb256f6
Add sanitizer syscall hooks to the tool's export lists.
...
llvm-svn: 181790
2013-05-14 13:55:21 +00:00
Sergey Matveev
ffe38d267c
Quick fix for ASan test build on Android.
...
llvm-svn: 181429
2013-05-08 14:11:12 +00:00
Sergey Matveev
af179b8d63
[sanitizer] Move GetStackTrace from ASan to sanitizer_common.
...
llvm-svn: 181424
2013-05-08 12:45:55 +00:00
Sergey Matveev
0c8ed9ce44
[asan] Common flags in ASan.
...
Some flags that are common to ASan/MSan/TSan/LSan have been moved to
sanitizer_common.
llvm-svn: 181193
2013-05-06 11:27:58 +00:00
Alexey Samsonov
5c38383205
[ASan] Add allow_user_segv_handler to let users override SEGV handler installed by ASan
...
llvm-svn: 180255
2013-04-25 10:52:15 +00:00
Alexey Samsonov
bcd32a9525
[ASan] Disable strict-init-order checker once we have more than one thread, as this mode is thread-hostile
...
llvm-svn: 180106
2013-04-23 13:57:35 +00:00
Alexander Potapenko
262eb01bbf
[ASan] Make wait.cc more Darwin-compatible: fix the header name and the CHECK patterns.
...
llvm-svn: 180097
2013-04-23 12:36:37 +00:00
Alexander Potapenko
15aa1cd1ac
[ASan] Disable AddressSanitizer.AllocDeallocMismatch on Darwin.
...
See https://code.google.com/p/address-sanitizer/issues/detail?id=131 .
llvm-svn: 180093
2013-04-23 12:14:55 +00:00
Alexey Samsonov
e7ea8cfb49
Fixup for r179843: add missing header
...
llvm-svn: 179844
2013-04-19 08:49:05 +00:00
Alexey Samsonov
dcf0ade114
[ASan] Make init-order checker allow access to already initialized globals.
...
This change adds ASan runtime option "strict-init-order" (off by default)
that makes init-order checker bark if global initializer accesses any global from different
translation unit (even if the latter is already initialized). strict init-order checking
doesn't play well with, e.g. LLVM registration machineries, and causes issue
https://code.google.com/p/address-sanitizer/issues/detail?id=178 .
llvm-svn: 179843
2013-04-19 08:35:16 +00:00
Sergey Matveev
0136943e03
[asan] Fix spelling in asan_rtl.cc Test commit.
...
Reviewers: kcc, glider, samsonov
Reviewed By: glider
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D676
llvm-svn: 179595
2013-04-16 14:58:45 +00:00
Evgeniy Stepanov
755eb32a39
[sanitizer] Add syscall handlers to ASan and TSan runtimes.
...
ASan checks addressability of syscall arguments. TSan does nothing for now.
llvm-svn: 179380
2013-04-12 14:57:03 +00:00
Kostya Serebryany
fd27b83ef2
[asan] inline flags(), up to 1% perf gain on malloc-intensive code
...
llvm-svn: 179307
2013-04-11 18:36:04 +00:00
Kostya Serebryany
bb68f2cd65
[asan] make heavy_uar_test even heavier
...
llvm-svn: 179306
2013-04-11 18:27:02 +00:00
Alexey Samsonov
9f3938e271
Explicitly list all sanitizer headers in CMake build rules. Make sure sanitizer lit_tests depend on fresh headers.
...
llvm-svn: 179293
2013-04-11 15:49:52 +00:00
Kostya Serebryany
1c77de3aeb
[asan] improve the UAR reporting (try harder to find the correct frame), try to make the test more stable
...
llvm-svn: 179292
2013-04-11 15:35:40 +00:00
Kostya Serebryany
18f0820552
[asan] make heavy_uar_test a bit more heavy and fix he fake stack to pass this test
...
llvm-svn: 179286
2013-04-11 14:07:02 +00:00
Alexey Samsonov
a672ba6e8f
[ASan] test source-based init-order blacklisting added in r179280
...
llvm-svn: 179281
2013-04-11 13:21:41 +00:00
Kostya Serebryany
3fec2f534a
[asan] fix use-after-return functionality (PR15672) and enable the corresponding test. We still don't guarantee anything with regard to use-after-return checking
...
llvm-svn: 179278
2013-04-11 12:49:38 +00:00
Alexey Samsonov
46cc45a291
[ASan] Symbolize correct address when printint error summary
...
llvm-svn: 179274
2013-04-11 11:45:04 +00:00
Kostya Serebryany
4e0a33c8be
[asan] move fake stack into a separate .h file; actually disable a failing test
...
llvm-svn: 179273
2013-04-11 11:39:19 +00:00
Kostya Serebryany
fd7f924016
[asan] add heavy_uar_test (disabled); fix lint
...
llvm-svn: 179271
2013-04-11 11:29:07 +00:00
Alexander Potapenko
227e22de5a
[ASan] Do not check the shadow of NULL argument in the time() interceptor.
...
Add a test for time().
llvm-svn: 179177
2013-04-10 15:13:00 +00:00
Kostya Serebryany
92684efb1d
[asan] implement callbacks for unaligned loads/stores
...
Reviewers: samsonov
Reviewed By: samsonov
CC: samsonov, llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D652
llvm-svn: 179175
2013-04-10 13:59:32 +00:00
Alexey Samsonov
c0443c5d25
[ASan] fix a typo in legend in error report
...
llvm-svn: 179161
2013-04-10 07:00:25 +00:00
Evgeniy Stepanov
460067823b
[sanitizer] Interceptors for wait*.
...
llvm-svn: 179096
2013-04-09 14:34:59 +00:00
Evgeniy Stepanov
69967c2835
[msan] Intercept glob() with tests.
...
llvm-svn: 179091
2013-04-09 11:35:13 +00:00
Kostya Serebryany
9d28efc1ad
[asan] relax Linux/zero-base-shadow.cc to make it pass on newer Ubuntu; fix lint
...
llvm-svn: 179088
2013-04-09 07:08:05 +00:00
Kostya Serebryany
228ecf46ab
[asan] make huge_negative_hea_oob more meaningful
...
llvm-svn: 178876
2013-04-05 15:16:48 +00:00
Kostya Serebryany
f5407e8d8f
[asan] add a test for huge left oob
...
llvm-svn: 178874
2013-04-05 15:13:23 +00:00
Kostya Serebryany
5b4267f7e7
[sanitizer] found a bug by code inspection: CHECK(a=b) instead of CHECK(a==b). Was puzzled why lint did not catch it. Turns out this check was disabled for asan source. fix all cases and enable the check
...
llvm-svn: 178872
2013-04-05 14:40:25 +00:00
Alexey Samsonov
5afe6aa141
[ASan] init-order checker tests: move constexpr test that requires -std=c++11 to a separate test case. Check that structs with no ctor but non-trivial dtor are ignored.
...
llvm-svn: 178857
2013-04-05 07:51:49 +00:00
Alexey Samsonov
734aab4066
[Sanitizer] Use a common mutex to prevent mixing reports from different sanitizers. This fixes PR15516
...
llvm-svn: 178853
2013-04-05 07:30:29 +00:00
Kostya Serebryany
eef8bd4355
[asan] nuke the old unused allocator code
...
llvm-svn: 178758
2013-04-04 11:32:49 +00:00
Kostya Serebryany
13b07733b1
[asan] fill first 4K of malloc-ed memory with garbage, implement flags max_malloc_fill_size and malloc_fill_byte
...
llvm-svn: 178757
2013-04-04 11:17:14 +00:00
Alexey Samsonov
21cb74318c
[ASan] Kill the remainders of platform defines in favor of SANITIZER_ defines
...
llvm-svn: 178629
2013-04-03 07:29:53 +00:00
Alexey Samsonov
e624795558
[ASan] More careful reports for globals that are ASCII strings
...
llvm-svn: 178458
2013-04-01 08:57:38 +00:00
Timur Iskhodzhanov
07d06d7cf5
Remove all 'static' before ALWAYS_INLINE
...
llvm-svn: 178290
2013-03-28 21:16:09 +00:00
Timur Iskhodzhanov
a6788325cf
Make all the ALWAYS_INLINE users Windows-friendly; also, avoid ALWAYS_INLINE INLINE combinations
...
llvm-svn: 178266
2013-03-28 18:52:40 +00:00
Alexey Samsonov
a88c60b085
[ASan] Speed-up initialization-order checking: create and use fast versions of PoisonShadow functions, store copies of __asan_global descriptors in a vector instead of list of pointers. This gives 3x speedup on both benchmarks and real binaries with lots of globals.
...
llvm-svn: 178239
2013-03-28 15:42:43 +00:00
Alexey Samsonov
e586170e86
Fix unmatching ASan runtime flag for init-order checking exposed by r178158. Add a test for r178158.
...
llvm-svn: 178229
2013-03-28 09:11:20 +00:00
Alexey Samsonov
7152debedd
[ASan] Demangle global names in error reports.
...
llvm-svn: 178131
2013-03-27 10:41:22 +00:00
Alexey Samsonov
56a784d2f6
[ASan] Change the ABI of __asan_before_dynamic_init function: now it takes pointer to private string with module name. This string serves as a unique module ID in ASan runtime. compiler-rt part
...
llvm-svn: 178014
2013-03-26 13:06:12 +00:00
Dmitry Vyukov
6f4b34bcf4
asan/tsan: move strcasecmp() interceptor to sanitizer_common
...
llvm-svn: 178010
2013-03-26 12:40:23 +00:00
Kostya Serebryany
88b2b45ec8
[asan] print thread number while reporting invalid-free and double-free; add tests; also add a test for use-after-poison
...
llvm-svn: 177993
2013-03-26 08:01:37 +00:00
Alexey Samsonov
961b636cf1
[ASan] Use dynamic symbol table when checking exported ASan runtime symbols
...
llvm-svn: 177868
2013-03-25 13:47:53 +00:00
Alexey Samsonov
9328ba400a
[ASan] mark local function as static
...
llvm-svn: 177862
2013-03-25 11:38:42 +00:00
Richard Smith
c91e327cba
Build and install .syms files alongside sanitizer runtimes. These are used to
...
specify which symbols are exported to DSOs when the sanitizer is statically
linked into a binary.
llvm-svn: 177784
2013-03-23 00:31:07 +00:00
Timur Iskhodzhanov
fb74020cea
Revert 177745 as it was incorrect
...
llvm-svn: 177746
2013-03-22 18:16:57 +00:00
Timur Iskhodzhanov
e117eef77f
Band-aid fix for the Windows build caused by r177710. Long-term, atomic_compare_exchange_strong should be a template on Windows too...
...
llvm-svn: 177745
2013-03-22 18:05:28 +00:00
Kostya Serebryany
667a34a120
[asan] Change the way we report the alloca frame on stack-buff-overflow.
...
Before: the function name was stored by the compiler as a constant string
and the run-time was printing it.
Now: the PC is stored instead and the run-time prints the full symbolized frame.
This adds a couple of instructions into every function with non-empty stack frame,
but also reduces the binary size because we store less strings (I saw 2% size reduction).
This change bumps the asan ABI version to v3.
compiler-rt part, llvm part will follow.
Example of report (now):
==31711==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fffa77cf1c5 at pc 0x41feb0 bp 0x7fffa77cefb0 sp 0x7fffa77cefa8
READ of size 1 at 0x7fffa77cf1c5 thread T0
#0 0x41feaf in Frame0(int, char*, char*, char*) stack-oob-frames.cc:20
#1 0x41f7ff in Frame1(int, char*, char*) stack-oob-frames.cc:24
#2 0x41f477 in Frame2(int, char*) stack-oob-frames.cc:28
#3 0x41f194 in Frame3(int) stack-oob-frames.cc:32
#4 0x41eee0 in main stack-oob-frames.cc:38
#5 0x7f0c5566f76c (/lib/x86_64-linux-gnu/libc.so.6+0x2176c)
#6 0x41eb1c (/usr/local/google/kcc/llvm_cmake/a.out+0x41eb1c)
Address 0x7fffa77cf1c5 is located in stack of thread T0 at offset 293 in frame
#0 0x41f87f in Frame0(int, char*, char*, char*) stack-oob-frames.cc:12 <<<<<<<<<<<<<< this is new
This frame has 6 object(s):
[32, 36) 'frame.addr'
[96, 104) 'a.addr'
[160, 168) 'b.addr'
[224, 232) 'c.addr'
[288, 292) 's'
[352, 360) 'd'
llvm-svn: 177723
2013-03-22 10:36:24 +00:00
Alexey Samsonov
f1311dfce1
[ASan] fix-up for r177634 on Windows.
...
llvm-svn: 177711
2013-03-22 07:48:23 +00:00
Alexey Samsonov
a5eb3cb721
[ASan] Fix an error on invalid deallocation in ASan allocator. When ASan checks if memory freed by user was indeed previously allocated, it first does an atomic write to presumed location of chunk header. This is wrong, as if the free is invalid, we may overwrite some valuable data (like other fields of the chunk header). Fix this by using atomic_compare_exchange instead.
...
llvm-svn: 177710
2013-03-22 07:40:34 +00:00
Dmitry Vyukov
a7e42b5be5
asan: fix lint warning about line length
...
llvm-svn: 177709
2013-03-22 07:29:59 +00:00
Alexey Samsonov
54afba8b62
[ASan] Switch ASan to generic ThreadRegistry from sanitizer_common. Delete ASan-specific AsanThreadRegistry.
...
llvm-svn: 177634
2013-03-21 11:23:41 +00:00
Alexey Samsonov
920b3b9a0c
[ASan] Move malloc stats collection away from AsanThreadRegistry class.
...
llvm-svn: 177508
2013-03-20 10:11:24 +00:00
Alexey Samsonov
cf025cb2e6
[ASan] Move GetCurrentThread/SetCurrentThread from AsanThreadRegistry class into plain functions: they don't actually use registry
...
llvm-svn: 177501
2013-03-20 09:23:28 +00:00
Evgeniy Stepanov
9a8f0f55d5
[asan] s/ASAN_POSIX/SANITIZER_POSIX/
...
llvm-svn: 177407
2013-03-19 15:26:41 +00:00
Evgeniy Stepanov
95eaa21637
[sanitizer] More renamed macros.
...
llvm-svn: 177401
2013-03-19 14:54:17 +00:00
Evgeniy Stepanov
0af672326a
[sanitizer] Replace more platform checks with SANITIZER_ constants.
...
llvm-svn: 177400
2013-03-19 14:33:38 +00:00
Evgeniy Stepanov
d3b56605f1
[sanitizer] Move ASan platform macros to sanitizer_common and rename them appropriately.
...
llvm-svn: 177397
2013-03-19 13:54:41 +00:00
Kostya Serebryany
9138f75d0a
[asan] make the __asan_get_heap_size more robust
...
llvm-svn: 177270
2013-03-18 10:52:25 +00:00
Evgeniy Stepanov
6488b2b257
[asan] Switch to allocator2 on Android.
...
llvm-svn: 177263
2013-03-18 09:22:58 +00:00
Kostya Serebryany
c4722a65a5
[asan] while generating the description of a global variable, emit the module name in a separate field, thus not duplicating this information if every description. This decreases the binary size (observed up to 3%). https://code.google.com/p/address-sanitizer/issues/detail?id=168 . This changes the asan API version. compiler-rt part, llvm-part will follow
...
llvm-svn: 177253
2013-03-18 08:04:55 +00:00
Alexey Samsonov
3a6b6b9d55
[Sanitizer] Don't intercept frexpf and frexpl on Windows. Add frexp declaration to asan_intercepted_functions.h
...
llvm-svn: 177155
2013-03-15 14:02:21 +00:00
Kostya Serebryany
d332d42372
[asan] remove one redundant malloc stress test, unify the usage of ASAN_LOW_MEMORY macro in tests, slightly reduce test memory usage (all to make 32-bit runs consume less RAM)
...
llvm-svn: 177069
2013-03-14 13:16:09 +00:00
Alexey Samsonov
1dc928e1b1
[ASan] remove -fsanitize=init-order from lit tests as now it's implied by -fsanitize=address
...
llvm-svn: 177064
2013-03-14 12:43:03 +00:00
Alexey Samsonov
963be1ddd8
[ASan] turn off checking initialization order in ASan runtime by default. Instead, it should be turned on by default in the compiler
...
llvm-svn: 177058
2013-03-14 11:49:40 +00:00
Alexey Samsonov
140cd84155
[ASan] make ASan assume ASAN_OPTIONS=symbolize=1 if ASAN_EXTERNAL_SYMBOLIZER is defined
...
llvm-svn: 177036
2013-03-14 10:07:40 +00:00
Alexey Samsonov
d7ab381f53
[Sanitizer] Build ASan, TSan and MSan runtimes with -fno-rtti.
...
llvm-svn: 176940
2013-03-13 09:18:30 +00:00
Kostya Serebryany
67b1478914
[asan] use 4Tb of address space for the asan allocator instead of 1Tb. This increases the memory available for a single size class from 16Gb to 64Gb. The total VM footprint becomes 20Tb
...
llvm-svn: 176857
2013-03-12 09:04:49 +00:00
Evgeniy Stepanov
f5d8c90f57
[asan] Revert r176255, r176264.
...
New allocator has 1.5x memory overhead of the old one.
llvm-svn: 176340
2013-03-01 09:33:05 +00:00
Evgeniy Stepanov
3305b177e6
[asan] Lower memory usage in LargeMallocTest on Android.
...
llvm-svn: 176264
2013-02-28 15:54:58 +00:00