Alexander Potapenko
814451909a
Initial support for malloc_zone_statistics. All counters are set to zero now.
...
This is required to overcome a crash in mstats() (http://code.google.com/p/address-sanitizer/issues/detail?id=109 )
llvm-svn: 163690
2012-09-12 09:38:51 +00:00
Alexey Samsonov
694633e19b
[Sanitizer] first effort to start building ASan runtime with -Werror in CMake build
...
llvm-svn: 163686
2012-09-12 07:38:47 +00:00
Evgeniy Stepanov
1a8f8fa6c0
CMake build rules for ASan Android runtime and tests.
...
llvm-svn: 163613
2012-09-11 11:55:45 +00:00
Alexey Samsonov
eeec3c11b5
[compiler-rt] Install support for CMake build of compiler-rt
...
llvm-svn: 163607
2012-09-11 10:26:54 +00:00
Alexey Samsonov
5c6b93bc33
[Sanitizer] Get rid of dependency between sanitizer_common and asan/tsan runtimes: implement tool-specific Die and CheckFailed functions via callbacks
...
llvm-svn: 163603
2012-09-11 09:44:48 +00:00
Chandler Carruth
b156b56a28
Revert r163411 based on review discussion.
...
In code review, it looked like these warnings do not actually fire with
modern Clang or GCC. However, the pragma is flat out rejected by GCC in
many configurations (-Werror) so it ended up causing more problems than
it fixed.
Daniel agreed with reverting this, but I think didn't have time to get
to it.
llvm-svn: 163583
2012-09-11 01:13:51 +00:00
Alexander Potapenko
67192d41ee
Allow to call strchr() from __asan_init().
...
Fixes PR13794.
llvm-svn: 163493
2012-09-10 08:35:12 +00:00
Daniel Dunbar
9d098bc09a
[asan] Use a relative include path instead of requiring build system involvement.
...
llvm-svn: 163414
2012-09-07 19:57:32 +00:00
Daniel Dunbar
44b3474b0e
build: Teach Makefile build system about asan/dynamic subdir.
...
llvm-svn: 163413
2012-09-07 19:57:28 +00:00
Daniel Dunbar
04ab17b0cd
[asan] Suppress some bogus -Winvalid-noreturn diagnostics.
...
llvm-svn: 163411
2012-09-07 19:57:20 +00:00
Alexander Potapenko
38c3f9ef2f
Remove the infinite recursion check for now, as we don't have __thread on Mac, and TSD is an overkill.
...
llvm-svn: 163393
2012-09-07 15:50:19 +00:00
Alexander Potapenko
c5adb8a700
Two minor changes:
...
-- exit from infinite recursion in CHECK()
-- print a verbose message if mapping of the shadow memory has failed.
llvm-svn: 163391
2012-09-07 15:34:40 +00:00
Evgeniy Stepanov
6e6817a823
[asan] Raise quarantine size a bit with ASAN_LOW_MEMORY.
...
Our tests expect that a 16M block will fit in the quarantine.
llvm-svn: 163384
2012-09-07 12:13:52 +00:00
Alexey Samsonov
f42e860c51
[ASan] hack initialization-bug test so that it stably passes on both Linux and Mac: make the bug appear independent of the translation unit order
...
llvm-svn: 163381
2012-09-07 09:24:29 +00:00
Alexey Samsonov
0f5f1d5bfa
[ASan] add Linux-specific test for initialization order that checks that we find a bug independently of translation units order
...
llvm-svn: 163379
2012-09-07 09:04:31 +00:00
Alexander Potapenko
35bc23ce58
Fix two compiler warnings: must use at least one argument for "..." in a variadic macros, signed vs. unsigned comparison.
...
llvm-svn: 163314
2012-09-06 13:31:13 +00:00
Evgeniy Stepanov
65fb0a5425
[asan] Use __ANDROID__ guard in asan_test.
...
llvm-svn: 163313
2012-09-06 12:50:28 +00:00
Alexander Potapenko
3ecf916c33
Use the return value of dladdr() to avoid Clang warning.
...
llvm-svn: 163311
2012-09-06 12:18:45 +00:00
Kostya Serebryany
f9caa28ccf
[asan] increase max stack size to 256 (+test)
...
llvm-svn: 163308
2012-09-06 10:57:03 +00:00
Alexey Samsonov
36853a7a3b
[ASan] actually remove old makefile
...
llvm-svn: 163300
2012-09-06 09:30:09 +00:00
Alexey Samsonov
ac87a5bddc
[ASan] Nuke output_tests/ in favor of lit_tests/. Stop using Makefile.old.
...
llvm-svn: 163294
2012-09-06 06:39:02 +00:00
Kostya Serebryany
ae350f66d4
[asan] increase the maximal size of malloc/free stack
...
llvm-svn: 163291
2012-09-06 04:46:47 +00:00
Alexey Samsonov
2947b84743
[ASan] Hack ASan lit config to allow running lit on tests manually
...
llvm-svn: 163209
2012-09-05 10:41:25 +00:00
Kostya Serebryany
4d45b9b784
[asan] added tests for asan-initialization-order, patch by Reid Watson
...
llvm-svn: 163207
2012-09-05 09:07:02 +00:00
Alexey Samsonov
d83ccd067d
[ASan] hoist more compile flags to SANITIZER_COMMON_CFLAGS var and add the rest of flags/defs from old Makefile to CMake
...
llvm-svn: 163204
2012-09-05 09:00:03 +00:00
Alexey Samsonov
ab2c76711d
[ASan] Add CMake support for building ASan benchmarks
...
llvm-svn: 163201
2012-09-05 08:07:18 +00:00
Alexey Samsonov
c402cb62fd
[ASan] Add print_full_thread_history runtime option (on by default) that prints all full thread creation paths for threads involved in ASan error report
...
llvm-svn: 163200
2012-09-05 07:37:15 +00:00
Alexey Samsonov
de827cb42b
[Sanitizer] Remove lint checkers from our old makefiles in favor of buildbot
...
llvm-svn: 162981
2012-08-31 08:10:28 +00:00
Alexey Samsonov
c3a8119a41
Whitespace/lint
...
llvm-svn: 162909
2012-08-30 14:22:21 +00:00
Alexey Samsonov
608a4b5def
[ASan] fix flakiness of Linux-specific clone_test: waitpid should better be provided with __WCLONE option, otherwise it didn't wait for the subprocess, returned -1, and we went crushing the subprocess stack
...
llvm-svn: 162842
2012-08-29 15:48:14 +00:00
Alexander Potapenko
5a9b616d6b
For invalid pointers passed to free_common check whether they are actually skewed to hold an additional CFAllocatorRef.
...
If so, fix the pointer and pass it to asan_free.
See http://code.google.com/p/address-sanitizer/issues/detail?id=70 for more background.
llvm-svn: 162839
2012-08-29 12:36:24 +00:00
Kostya Serebryany
e4d9c7b940
[asan] fix asan's Makefile.old -- our build bot still uses it (hopefully, will soon migrate to cmake completely)
...
llvm-svn: 162831
2012-08-29 08:06:27 +00:00
Chandler Carruth
1aa4fef601
Relocate the external headers provided by ASan and the common sanitizer
...
library.
These headers are intended to be available to user code when built with
AddressSanitizer (or one of the other sanitizer's in the future) to
interface with the runtime library. As such, they form stable external
C interfaces, and the headers shouldn't be located within the
implementation.
I've pulled them out into what seem like fairly obvious locations and
names, but I'm wide open to further bikeshedding of these names and
locations.
I've updated the code and the build system to cope with the new
locations, both CMake and Makefile. Please let me know if this breaks
anyone's build.
The eventual goal is to install these headers along side the Clang
builtin headers when we build the ASan runtime and install it. My
current thinking is to locate them at:
<prefix>/lib/clang/X.Y/include/sanitizer/common_interface_defs.h
<prefix>/lib/clang/X.Y/include/sanitizer/asan_interface.h
<prefix>/lib/clang/X.Y/include/sanitizer/...
But maybe others have different suggestions?
Fixing the style of the #include between these headers at least unblocks
experimentation with installing them as they now should work when
installed in these locations.
llvm-svn: 162822
2012-08-29 02:27:54 +00:00
Chandler Carruth
c1c9d5818f
Some flag cleanup for the sanitizer runtimes.
...
This hoists most of the CFLAGS into a common variable. It also adds
detection for -Wno-c99-extensions and uses it to silence a pile of
warnings.
Finally, it switches to the proper flag -rdynamic.
With this, the cmake build is warning free on my bootstrap Linux build.
llvm-svn: 162809
2012-08-29 00:13:11 +00:00
Kostya Serebryany
66a37f3aef
[asan] one more fix for windows build
...
llvm-svn: 162762
2012-08-28 15:25:07 +00:00
Kostya Serebryany
27dcb2379f
[asan] fix Windows build
...
llvm-svn: 162758
2012-08-28 14:14:30 +00:00
Kostya Serebryany
7575968aa4
[asan] actually move StackTrace to sanitizer_common
...
llvm-svn: 162757
2012-08-28 14:11:57 +00:00
Kostya Serebryany
a57b4e823a
[asan] even more refactoring to move StackTrace to sanitizer_common
...
llvm-svn: 162754
2012-08-28 13:49:49 +00:00
Kostya Serebryany
ee92877f17
[asan] more refactoring to move StackTrace to sanitizer_common
...
llvm-svn: 162752
2012-08-28 13:25:55 +00:00
Alexey Samsonov
50e8a6a7df
[ASan] CMake build: share more compile flags between instrumented and non-instrumented tests
...
llvm-svn: 162750
2012-08-28 12:38:17 +00:00
Kostya Serebryany
6b0d775229
[asan] some renaming before we move StackTrace into sanitizer_common
...
llvm-svn: 162747
2012-08-28 11:54:30 +00:00
Kostya Serebryany
bb6f165952
[asan] get rid of AsanPrintf in favor of Printf from sanitizer_common
...
llvm-svn: 162746
2012-08-28 11:34:40 +00:00
Kostya Serebryany
4bfe954d14
[asan] improve SetErrorReportCallbackTest to actually catch missing functionality in __asan_set_error_report_callback
...
llvm-svn: 162745
2012-08-28 11:21:01 +00:00
Evgeniy Stepanov
f72f08affc
CMake build rules for ASan/Android runtime.
...
llvm-svn: 162675
2012-08-27 14:28:27 +00:00
Alexey Samsonov
e67a5dd8e1
[Sanitizer] Use low-level allocator in flag parsing to avoid calling malloc() before ASan/TSan initialization is done
...
llvm-svn: 162673
2012-08-27 14:04:54 +00:00
Alexey Samsonov
cc62211fbf
[Sanitizer] Rename ProcessMaps to MemoryMappingLayout and fix Windows build by providing stub implementation
...
llvm-svn: 162671
2012-08-27 13:48:48 +00:00
Alexey Samsonov
c74289db2b
[ASan] add missing build dependency on sanitizer_common headers
...
llvm-svn: 162670
2012-08-27 13:47:28 +00:00
Evgeniy Stepanov
be01398612
A few tweaks for building ASanRT against Android NDK.
...
llvm-svn: 162666
2012-08-27 11:15:55 +00:00
Alexey Samsonov
dc8d1f1039
[Sanitizer] move low-level (mmap-based) allocator to sanitizer_common
...
llvm-svn: 162663
2012-08-27 09:30:58 +00:00
Alexander Potapenko
00492cab3e
Revert the erroneous changes made to Makefile.old in r162547
...
Remove a spare newline from asan_rtl.cc
llvm-svn: 162548
2012-08-24 09:31:53 +00:00
Alexander Potapenko
fefc1e989c
If the program is linked to a dynamic ASan runtime which is not present in DYLD_INSERT_LIBRARIES
...
(which, in turn, is required for our interceptors to take effect), re-exec the program with
DYLD_INSERT_LIBRARIES set.
llvm-svn: 162547
2012-08-24 09:22:05 +00:00
Alexander Potapenko
d79d80b4a0
Add add_clang_runtime_shared_library() CMake function and use it to put the shared ASan runtime in the appropriate place.
...
llvm-svn: 162546
2012-08-24 07:49:22 +00:00
Alexander Potapenko
2ebe619340
Re-implement the wrappers for libdispatch functions using blocks where appropriate
...
(kudos to Anna Zaks for a good example).
This simplifies the code much and lets us not implement internal parts of libdispatch.
All ASan tests from t32 and t64 should pass with the dylib runtime now.
llvm-svn: 162439
2012-08-23 09:34:40 +00:00
Alexey Samsonov
419f610a74
[Sanitizer] Switch the symbolization strategy that would be used by sanitizer tools family: as compiling in-process symbolizer into runtime involves certain difficulties, we may instead launch an external symbolizer program (fork + execl) in a subprocess and communicate with it via pipe.
...
llvm-svn: 162437
2012-08-23 07:32:06 +00:00
Alexey Samsonov
4d520640ba
[ASan] use write instead of puts in malloc hooks test for ASan, as puts calls malloc on Mac
...
llvm-svn: 162359
2012-08-22 13:32:37 +00:00
Alexey Samsonov
a85b6b8154
[ASan] get rid of ASAN_USE_EXTERNAL_SYMBOLIZER compiler def in favor of __asan_set_symbolize_callback interface function. Now the user doesn't have to recompile ASan runtime to provide its own symbolizer
...
llvm-svn: 162358
2012-08-22 13:31:37 +00:00
Alexey Samsonov
de17f86655
[ASan] make ASan malloc/free hooks weak interface functions, overridable by user. Now the user can control malloc/free hooks without recompiling ASan runtime
...
llvm-svn: 162355
2012-08-22 10:12:47 +00:00
Kostya Serebryany
68d9c9da40
[asan] fix mac build
...
llvm-svn: 162279
2012-08-21 14:43:36 +00:00
Kostya Serebryany
676bcdb838
[asan] run-time part of the initialization order checker. Patch by Reid Watson with some bits from kcc. The sub-pass is off by default for now. On simple tests it works fine.
...
llvm-svn: 162278
2012-08-21 14:10:25 +00:00
Kostya Serebryany
55b4dd314f
[asan] update asan-rt to match the interface change in LLVm (r162268)
...
llvm-svn: 162269
2012-08-21 08:24:35 +00:00
Kostya Serebryany
6b745b5281
[asan] fix lint
...
llvm-svn: 162258
2012-08-21 06:43:44 +00:00
Alexander Potapenko
02e6f03236
Dynamic interceptors for dispatch_async and dispatch_after.
...
llvm-svn: 162202
2012-08-20 11:59:26 +00:00
Alexander Potapenko
1233d558dc
Minor refactoring: reduce code duplication by introducing a macro for dispatch_sync_f, dispatch_async_f, dispatch_barrier_async_f bodies.
...
llvm-svn: 162199
2012-08-20 09:25:10 +00:00
Alexander Potapenko
4a156c1b80
Fix a leftover #if defined(DYNAMIC_MAC_WRAPPERS).
...
llvm-svn: 162197
2012-08-20 08:49:49 +00:00
Alexander Potapenko
dffbb3b330
Intercept siglongjmp and _longjmp under "#if ASAN_INTERCEPT_*"
...
llvm-svn: 162103
2012-08-17 16:27:38 +00:00
Alexander Potapenko
5f487de8a3
Fix lint warnings.
...
llvm-svn: 162092
2012-08-17 10:08:51 +00:00
Alexander Potapenko
c62210e3ff
Commit the source and CMake changes that will allow to build ASan runtime
...
as a shared library on Mac OS. This will provide an alternative to
mach_override.
llvm-svn: 162091
2012-08-17 09:00:08 +00:00
Alexander Potapenko
cfb2a6b074
Remove the extra semicolon reported by the buildbot.
...
llvm-svn: 161954
2012-08-15 15:59:18 +00:00
Alexander Potapenko
f6344ffe39
Introduce asan_intercepted_functions.h which contains the declarations wrapped functions and their wrappers.
...
Those declarations are going to be shared between asan_interceptors.cc and the dynamic runtime library on Mac OS.
llvm-svn: 161952
2012-08-15 15:24:48 +00:00
Alexey Samsonov
5b2c6ea38f
[ASan] lit tests: use nm instead of llvm-nm, until llvm-nm becomes usable on Mac. Port output test change in r161948 to lit
...
llvm-svn: 161951
2012-08-15 14:33:30 +00:00
Alexander Potapenko
6c1de8faa7
Check for filenames and numbers to detect possible problems with asan_symbolize.py on -fPIE binaries.
...
llvm-svn: 161948
2012-08-15 14:00:09 +00:00
Alexander Potapenko
1800362758
Pass offset of the frame address within the binary to addr2line instead of the absolute address.
...
Fixes the problem with -PIE binaries.
llvm-svn: 161947
2012-08-15 13:58:24 +00:00
Alexander Potapenko
07ea07c3ca
Patch the frame address regardless of the frame number.
...
llvm-svn: 161946
2012-08-15 13:23:03 +00:00
Alexander Potapenko
20f9fcc285
Move the prototype of __CFInitialize to asan_mac.h so that asan_malloc_mac.cc may use it in the dynamic library mode.
...
llvm-svn: 161945
2012-08-15 12:23:36 +00:00
Alexander Potapenko
9a168a7405
Use SANITIZER_INTERFACE_ATTRIBUTE instead of __attribute__((visibility("default")))
...
Export CheckFailed, asan_malloc, asan_free, asan_memalign, AsanStackTrace::CompressStack, AsanStackTrace::UncompressStack from the dynamic runtime library.
llvm-svn: 161943
2012-08-15 11:57:52 +00:00
Alexander Potapenko
55df945db2
Make __asan::asan_{malloc,free,memalign} globally visible, so that the dynamic version of the runtime will export them.
...
llvm-svn: 161942
2012-08-15 11:32:15 +00:00
Alexey Samsonov
9fe914b099
[ASan] Port (the last one) tricky interface_test to lit, and a *huge* chunks of boilerplate to run tests for 32/64 bits and all optimization levels. Alas, lit doesn't support for loops in RUN-lines...
...
llvm-svn: 161941
2012-08-15 11:26:57 +00:00
Alexander Potapenko
81a1ec8ea6
Do not attempt to intercept mlock and friends on Windows.
...
llvm-svn: 161939
2012-08-15 09:46:45 +00:00
Alexander Potapenko
785f8bc4ec
Use the common interception machinery for mlock/munlock/mlockall/munlockall.
...
llvm-svn: 161938
2012-08-15 09:22:57 +00:00
Alexey Samsonov
0e056762ef
[ASan] use clangxx_asan instead of clang_asan for C++ lit tests
...
llvm-svn: 161936
2012-08-15 08:54:14 +00:00
Alexey Samsonov
6016486a16
[ASan] port remaining output and feature tests to lit. TODO: we should in fact run most of the tests for 32/64 bits and for all optimization levels
...
llvm-svn: 161935
2012-08-15 08:29:17 +00:00
Alexey Samsonov
5717f4c1eb
[ASan] port interception and shared library tests to lit
...
llvm-svn: 161933
2012-08-15 07:13:51 +00:00
Alexey Samsonov
682a07cbe1
[ASan] move declaration of __asan_default_options to interface header
...
llvm-svn: 161932
2012-08-15 07:11:14 +00:00
Kostya Serebryany
ad855e9438
[asan] better diagnostics for mmap failure
...
llvm-svn: 161874
2012-08-14 15:18:40 +00:00
Alexey Samsonov
517842b2fc
[ASan] make sure __asan_default_options symbol is exported
...
llvm-svn: 161873
2012-08-14 15:03:24 +00:00
Alexey Samsonov
eb39adc9fa
[ASan] make sure __asan_default_options gets default visibility, port corresponding test to lit
...
llvm-svn: 161869
2012-08-14 13:54:28 +00:00
Alexey Samsonov
bf2bfa5aa4
[ASan] support for running OS-specific tests using lit, port clone_test as an example
...
llvm-svn: 161864
2012-08-14 13:22:58 +00:00
Alexey Samsonov
b39b0fa9a0
[ASan] add __asan_set_on_error_callback into force_interface_symbols (thanks to cool test by glider@)
...
llvm-svn: 161756
2012-08-13 14:05:00 +00:00
Alexey Samsonov
f87ff74075
[ASan] Add __asan_set_on_error_callback() interface function that allows user to set a callback to be called right when ASan detects an error
...
llvm-svn: 161754
2012-08-13 11:23:40 +00:00
Alexey Samsonov
a72c7cf227
[ASan] If ASan finds second error report, wait for some time and die (instead of running in a busy loop) to make sure ASan won't hang if it finds error while reporting an error in the same thread
...
llvm-svn: 161749
2012-08-13 09:57:19 +00:00
Alexey Samsonov
b93df94238
[ASan] share code executed at the beginning/end of printing error reports
...
llvm-svn: 161666
2012-08-10 15:13:05 +00:00
Alexey Samsonov
fb844c7eff
[ASan] CMake support for building ASan runtime as a universal binary on Mac
...
llvm-svn: 161665
2012-08-10 14:45:52 +00:00
Alexander Potapenko
33c028fa05
Remove the setjmp.h dependency, fix the comment.
...
llvm-svn: 161662
2012-08-10 12:46:39 +00:00
Alexander Potapenko
2cdd4f165e
Temporary fix for http://code.google.com/p/address-sanitizer/issues/detail?id=99 :
...
when trying to free memory that actually belongs to the system purgeable zone, use malloc_zone_free(malloc_default_purgeable_zone(), ptr) instead of asan_free().
llvm-svn: 161661
2012-08-10 11:33:01 +00:00
Alexander Potapenko
8aba007fe1
Add a test checking that all the "__asan_" interface functions are present in a binary built with -dead_strip.
...
Fix force_interface_symbols() so that none of the interface symbols is stripped.
llvm-svn: 161582
2012-08-09 16:05:17 +00:00
Alexey Samsonov
f343eb7df4
[ASan] Move mac-specific error reports to asan_report.cc as well
...
llvm-svn: 161576
2012-08-09 12:15:40 +00:00
Alexey Samsonov
b53a670817
[ASan] Small fix to please tests on Windows, where stack unwinding using provided pc/bp works too bad
...
llvm-svn: 161575
2012-08-09 11:29:13 +00:00
Alexey Samsonov
f688412b8c
[ASan] Move __asan_report_error implementation to asan_report.cc
...
llvm-svn: 161574
2012-08-09 10:56:57 +00:00
Alexander Potapenko
ba6174889c
Use a switch instead of a simple condition in force_interface_symbols().
...
Otherwise Clang eliminates everything after the first interface symbol that is marked noreturn.
llvm-svn: 161573
2012-08-09 09:46:12 +00:00
Alexey Samsonov
65b9acf0af
[ASan] move code that describes globals to asan_report.cc
...
llvm-svn: 161572
2012-08-09 09:27:24 +00:00
Alexey Samsonov
4ce12349d6
[ASan] move some functions that describe addresses to asan_report.cc
...
llvm-svn: 161571
2012-08-09 09:06:52 +00:00
Alexey Samsonov
c0ff933d8b
[ASan] Move error reporting code away from file with interceptors
...
llvm-svn: 161570
2012-08-09 08:32:33 +00:00
Alexey Samsonov
b4b316fc5b
[ASan] Move error reports away from ASan allocator. Add new source file to CMakeLists as well
...
llvm-svn: 161569
2012-08-09 08:15:46 +00:00
Alexey Samsonov
aa05110a17
[ASan] Create new files asan_report.{h,cc} as a preparation for refactoring of ASan error reporting code.
...
Currently ASan reports many kinds of errors, and the code that actually prints error messages can
be found inside allocator, OS-specific files, interceptors code etc.
An example of maintenance troubles this situation causes:
There is currently an ASan interface function that registers
callback which should take the char buffer with error report printed by ASan.
This function is now broken, as one has to insert callback calls to all the places in
ASan code where the error reports are printed, surprisingly it is not only
"__asan_report_error" function...
llvm-svn: 161568
2012-08-09 07:40:58 +00:00
Alexey Samsonov
0317b8bbc0
[ASan] simplify cmake rules for adding lit testsuites
...
llvm-svn: 161412
2012-08-07 11:09:41 +00:00
Alexey Samsonov
1e6c947a4c
[ASan] add llvm_tools_dir to lit.site.cfg for ASan and add it to PATH
...
llvm-svn: 161411
2012-08-07 11:00:19 +00:00
Alexey Samsonov
59c33c0c9a
[ASan] Add support for running unit tests by lit (as a part of 'make check-asan' command)
...
llvm-svn: 161406
2012-08-07 08:59:15 +00:00
Alexey Samsonov
941a6ec9bb
[ASan] fix names of malloc/free replacements on Android
...
llvm-svn: 161322
2012-08-06 15:13:22 +00:00
Alexey Samsonov
0295edbfd5
[ASan] add new ASan option 'strip_path_prefix' to remove useless prefices from filenames in stack traces
...
llvm-svn: 161321
2012-08-06 13:00:21 +00:00
Alexander Potapenko
8f6dd3537c
AllocationSize(ptr) should check that |ptr| actually points to the beginning of the chunk it belongs to.
...
Fixes http://code.google.com/p/address-sanitizer/issues/detail?id=86
llvm-svn: 161320
2012-08-06 12:24:39 +00:00
Alexander Potapenko
879b1ffca7
Implement LinuxSymbolizer instead of symbolize_addr2line.
...
llvm-svn: 161181
2012-08-02 14:58:04 +00:00
Alexander Potapenko
be84ac8ff3
Some refactoring for asan_symbolize.py: introduced the Symbolizer class and implemented DarwinSymbolizer for atos-based symbolization, BreakpadSymbolizer for breakpad-based symbolization (files produced by the dump_syms tool, http://code.google.com/p/google-breakpad/source/browse/#svn%2Ftrunk%2Fsrc%2Ftools%2Fmac%2Fdump_syms ) and ChainSymbolizer to allow falling back if a symbolizer hadn't succeeded.
...
Fixed pylint warnings.
llvm-svn: 161176
2012-08-02 13:59:23 +00:00
Alexander Potapenko
33824c54f6
Make strcat() and strncat() more standard-compliant (check for invalid parameters even if zero bytes is copied, more accurate overlap check)
...
Fix the tests that were relying on the incorrect behavior.
llvm-svn: 161167
2012-08-02 10:25:46 +00:00
Alexey Samsonov
139a7c0575
[Sanitizer] Make ASan/TSan sources depend on headers from interception library
...
llvm-svn: 161113
2012-08-01 14:55:49 +00:00
Alexey Samsonov
cc7ea4269a
[ASan] cleanup interceptors code - prefer ASAN_INTERCEPT_FUNCTION_NAME macro to _WIN32, __APPLE__ etc.
...
llvm-svn: 161109
2012-08-01 11:17:00 +00:00
Alexey Samsonov
7b2f36e96a
First tiny move towards integrating AddressSanitizer regressions test into LLVM lit-based testing infrastructure.
...
The goal is to be able to run ASan tests by simply running "make check-asan" command from CMake build tree:
* tests should use fresh clang binary from current build tree.
* tests should use the same RUN-lines syntax as llvm/clang reg tests.
Next steps:
- restricting tests to machines where target is equal to host, i.e. where we can produce working binaries.
- moving AddressSanitizer unit tests to lit as well.
llvm-svn: 161050
2012-07-31 15:43:11 +00:00
Alexander Potapenko
8aae9557d6
Factor out the main() function.
...
llvm-svn: 161046
2012-07-31 13:51:26 +00:00
Alexey Samsonov
36d2dff143
[ASan] fix cmake build warning
...
llvm-svn: 160957
2012-07-30 10:18:31 +00:00
Kostya Serebryany
4c38790f70
[asan] ensure that asan_init is called in str[n]cmp. Bug found by Nick Kralevich (thanks)
...
llvm-svn: 160853
2012-07-27 07:09:49 +00:00
Alexey Samsonov
5062359502
cmake for compiler-rt: add a function to set output dirs for compiler runtimes equal to directory used by Clang driver. Use it for ASan runtime. Also, make sure that ASan unit tests depend on the ASan runtime.
...
llvm-svn: 160721
2012-07-25 11:15:00 +00:00
Kostya Serebryany
bb0ade6daa
[asan] don't return from a never-return function. fix a test that had a chain of bugs instead of just one
...
llvm-svn: 160719
2012-07-25 10:56:09 +00:00
Alexey Samsonov
c145b02607
[ASan] fixup for r160712: provide a default definition for weak __asan_default_options()
...
llvm-svn: 160718
2012-07-25 10:40:57 +00:00
Alexander Potapenko
9bac1cedbc
Make __asan_default_options a weak function that returns a const char*.
...
Users may define it to override the default ASan options.
This function has to be marked with __attribute__((no_address_safety_analysis)), because it is called before ASan is fully initialized.
Add an output test checking the __asan_default_options functionality.
llvm-svn: 160712
2012-07-25 09:18:43 +00:00
Alexey Samsonov
65d842ae51
Revert r160669 (except for compile flag updates)
...
llvm-svn: 160671
2012-07-24 12:11:38 +00:00
Alexey Samsonov
3397013606
[ASan] hacking cmake build: after generating asan runtime, copy it to the Clang lib directory where Clang driver expects to find it.
...
llvm-svn: 160669
2012-07-24 11:49:55 +00:00
Alexey Samsonov
96b9393f2d
[ASan] Support for cmake build of ASan unittests in 32-bit LLVM build. Currently, to run ASan unit tests both for 32- and 64 bits one has to maintain two distinct LLVM builds. In a bright future, we'd like to use a single build for this
...
llvm-svn: 160666
2012-07-24 08:26:19 +00:00
Alexander Potapenko
51e6488b31
Intercept CFAllocator for each thread in the program.
...
Test that child threads use the ASan allocator, that allocated memory can be passed to another thread and deallocated on it.
This should fix http://code.google.com/p/address-sanitizer/issues/detail?id=81
llvm-svn: 160630
2012-07-23 14:07:58 +00:00
Alexey Samsonov
37d5134f38
[ASan] minor fixes to silence cmake build warnings
...
llvm-svn: 160624
2012-07-23 09:11:58 +00:00
Alexander Potapenko
7f3e84c9fd
For wild addresses in the shadow or shadow gap areas print an error message instead of crashing on a check.
...
Add AddressSanitizer.MemsetWildAddressTest that makes sure a proper error message is printed.
llvm-svn: 160620
2012-07-23 08:22:27 +00:00
Alexey Samsonov
3735faa108
[ASan] subtract one from PCs in ASan error reports (as they originally contain return addresses). Make output tests stricter.
...
llvm-svn: 160508
2012-07-19 15:07:26 +00:00
Alexander Potapenko
628b349b17
Suppress the stderr output from atos.
...
llvm-svn: 160502
2012-07-19 12:01:07 +00:00
Kostya Serebryany
78713bc574
[asan] get rid of the last operator new call in asan rtl
...
llvm-svn: 160347
2012-07-17 07:20:13 +00:00
Alexey Samsonov
2d4bd13eb6
[Sanitizer] fix CMake build
...
llvm-svn: 159988
2012-07-10 09:17:06 +00:00
Alexey Samsonov
9f666ea6ca
[ASan] move flags description to separate header, add comments about them.
...
llvm-svn: 159985
2012-07-10 07:41:27 +00:00
Alexey Samsonov
2467ca5010
[ASan] cleanup: remove dead flag
...
llvm-svn: 159934
2012-07-09 15:11:28 +00:00
Alexey Samsonov
34efb8e9b9
[ASan] Use common flags parsing machinery.
...
llvm-svn: 159933
2012-07-09 14:36:04 +00:00
Alexander Potapenko
740d166c3e
Small fix: do not replace the default CFAllocator if it has been replaced already.
...
llvm-svn: 159824
2012-07-06 13:52:28 +00:00
Alexander Potapenko
dc211a8db4
Because CFAllocatorCreate() should also be called after __CFInitialize() on Lion,
...
do so by factoring the CFAllocator logic into ReplaceCFAllocator(), which is called from
either the __CFInitialize wrapper or __asan_init(), depending on which of them is called later.
llvm-svn: 159822
2012-07-06 13:24:28 +00:00
Alexander Potapenko
89f9270366
A portable way to check whether __CFInitialize has been called: compare kCFAllocatorSystemDefault._base._cfisa to 0.
...
This should fix http://code.google.com/p/address-sanitizer/issues/detail?id=87 on both Lion and Snow Leopard.
llvm-svn: 159821
2012-07-06 13:04:12 +00:00
Alexander Potapenko
d2ff0b087a
Do not check for __CFRuntimeClassTableSize on non-10.6 systems, where this symbol is private.
...
This change may cause http://code.google.com/p/address-sanitizer/issues/detail?id=87 to re-appear on Lion.
llvm-svn: 159819
2012-07-06 11:58:54 +00:00
Alexander Potapenko
25b567dd0d
Fix http://code.google.com/p/address-sanitizer/issues/detail?id=87 by making sure we replace the default CFAllocator only after __CFInitialize has been called.
...
llvm-svn: 159749
2012-07-05 14:46:56 +00:00
Alexander Potapenko
77769caaef
Do not call malloc_zone_from_ptr() for the pointers passed to mz_size() and mz_free().
...
These callbacks assume that the memory belongs to asan_zone, so it's incorrect to pass it to another one.
If a need for this appears (e.g. system libraries free the memory using wrong zone), it should be documented.
llvm-svn: 159713
2012-07-04 13:58:07 +00:00
Alexey Samsonov
3ac4548c92
[ASan] Minor fix in symbolizer output.
...
llvm-svn: 159709
2012-07-04 10:58:35 +00:00
Alexey Samsonov
961276af26
[Sanitizer] Extend a symbolizer code. Implemented for Linux only. Use dl_iterate_phdr to get virtual addresses of mapped module sections. To symbolize an address from a module, map this module to memory and obtain pointers to debug info sections. Later these pointers can be passed to constructor of DWARF context-in-memory from LLVM DebugInfo lib.
...
llvm-svn: 159652
2012-07-03 08:24:14 +00:00
Alexey Samsonov
4618508ea4
[ASan] cmake cleanup: make tab/space padding in CMakeLists consistent, silence/fix some pedantic warnings
...
llvm-svn: 159514
2012-07-02 06:48:10 +00:00
Dmitry Vyukov
7a9fa7dbc5
tsan/asan: unify ScopedLock
...
llvm-svn: 159438
2012-06-29 17:10:08 +00:00
Dmitry Vyukov
6fa46f7003
tsan/asan: unify atomics (move atomics from tsan to sanitizer_common)
...
llvm-svn: 159437
2012-06-29 16:58:33 +00:00
Alexey Samsonov
c37ac17629
[ASan] cmake unit tests: explicitly add necessary linker flags when linking unit tests with asan runtime
...
llvm-svn: 159420
2012-06-29 11:29:39 +00:00
Alexey Samsonov
548b7b5b0e
[ASan] cmake-based unit tests: merge instrumented and non-instrumented files into one test binary
...
llvm-svn: 159419
2012-06-29 10:23:31 +00:00
Alexey Samsonov
6b03aa1bf7
[ASan] fix the build - erase second main as we link all test sources together
...
llvm-svn: 159348
2012-06-28 13:44:27 +00:00
Alexey Samsonov
3fe0d4d9aa
[ASan] silence various warnings in cmake build of asan unit tests
...
llvm-svn: 159347
2012-06-28 13:12:07 +00:00
Alexey Samsonov
b4edab5a6b
[ASan] cmake support for running asan unit tests on Mac
...
llvm-svn: 159345
2012-06-28 12:19:52 +00:00
Alexey Samsonov
ecf5436e9c
[ASan] update cmake rules so that ASan unit tests can include googletest (and, hence, llvm) headers when they are built by fresh Clang
...
llvm-svn: 159343
2012-06-28 09:32:19 +00:00
Alexey Samsonov
70386aaffa
[ASan] cleanup: trailing semicolons, trailing colons in enums
...
llvm-svn: 159338
2012-06-28 08:27:24 +00:00
Chandler Carruth
9aaf156f30
Add support for building the ASan instrumentation unit tests with the
...
just-built Clang binary, and linking them against the just-built ASan
runtime.
This is *very* brittle. I expect it will require tweaking, and I've
pro-actively disabled it on non-Unix builds and on cross-builds.
It is also currently missing dependency edges on GoogleTest header files
and a few other corner cases, but those can be fixed. This is the major
milestone of a mini-bootstrap-like build of the unittest.
llvm-svn: 159255
2012-06-27 09:01:24 +00:00
Kostya Serebryany
c639b3943a
[asan] update the cmake file for asan
...
llvm-svn: 159143
2012-06-25 15:38:37 +00:00
Kostya Serebryany
9ed4f506bb
[asan] move tests from asan_interface_test.cc to asan_noinst_test.cc. Now all these tests do not require instrumentation and work directly with asan rt
...
llvm-svn: 159135
2012-06-25 14:23:07 +00:00
Chandler Carruth
9359efa986
Cleanup the handling of CFLAGS even more in the cmake build for ASan.
...
Add the initial support for building ASan tests.
The first change here is to try to get the CFLAGS to more closely match
those used by the old Makefile. There are probably still goofs here,
ASan folks, your review would be appreciated.
The second big change is to add support for building both
instrumentation based an non-instrumentation based unittests for ASan.
They are built a bit differently from how the old makefiles managed
things. Specifically, there are two binaries, one for the
non-instrumented case, and one for the instrumented case.
Also, the instrumented unit tests rely on the host compiler supporting
AddressSanitizer's intrumentation pass. This is kind-of gross, but
I don't know of a better way yet. I've mailed llvmdev to discuss this
issue.
One big caveat is that the detection logic currently doesn't work. I've
commented it out temporarily as I'd like to get feedback from the ASan
developers, etc.
llvm-svn: 159134
2012-06-25 12:57:43 +00:00
Kostya Serebryany
0e0832bfdb
[asan] get rid of '#include <malloc.h>' in the implementation of malloc interceptors
...
llvm-svn: 159132
2012-06-25 09:58:29 +00:00
Chandler Carruth
c78ad00c07
Another big step toward a viable CMake build system for CompilerRT,
...
ASan, and friends.
This explicitly switches the CompilerRT CMake build to require CMake
version 2.8.8 or newer which provides first-class support for "object"
libraries which consist of a pile of '.o' files -- exactly what is
desired for composing runtime libraries. I've gone ahead and switched to
using this.
I've also added the interception library which I missed initially. And
I've added proper dependencies between the various libraries. With this,
I'm able to build archives for asan that appear to contain all of the
necessary .o files.
The final tweak here is to start setting up the compile flags and macro
defines expected by ASan and its helper libraries. These may not be
entirely correct currently, they're based loosely on my reading of the
old Makefiles. However, they can be tweaked more easily now that they're
wired up properly.
llvm-svn: 159129
2012-06-25 08:40:10 +00:00
Chandler Carruth
bbff278c9c
Lots of trivial changes to remove extraneous semicolons throughout ASan.
...
llvm-svn: 159128
2012-06-25 06:53:10 +00:00
Kostya Serebryany
875f99a6bf
[asan] fix -Wsign-compare
...
llvm-svn: 159083
2012-06-23 16:30:48 +00:00
Alexander Potapenko
245f4ae59a
Small lint fix.
...
llvm-svn: 158922
2012-06-21 16:40:59 +00:00
Alexander Potapenko
70feed27ea
Add a test for issue 81 -- AddressSanitizerMac.DISABLED_CFAllocatorDefaultDoubleFree_ChildPhread
...
llvm-svn: 158921
2012-06-21 16:08:11 +00:00
Alexey Samsonov
f8947a3360
[ASan] fix lint error
...
llvm-svn: 158905
2012-06-21 08:13:49 +00:00
Alexander Potapenko
15b4cafd2c
Enable AddressSanitizerMac.CFAllocatorDefaultDoubleFree and AddressSanitizerMac.CFAllocatorMallocDoubleFree, which now work fine.
...
llvm-svn: 158886
2012-06-21 01:04:30 +00:00
Alexander Potapenko
1bde28b464
Factor the common code out of cf_free and mz_free.
...
Introduce the mac_ignore_invalid_free flag (0 by default) which makes both cf_free and mz_free ignore invalid free invocations and leak memory.
llvm-svn: 158885
2012-06-21 01:01:20 +00:00
Alexander Potapenko
642371724e
Fix the output tests on Darwin
...
llvm-svn: 158870
2012-06-20 23:07:55 +00:00
Alexander Potapenko
f9f2fbacb3
Actually intercept free() to ensure that the deallocations caused by other functions directly calling it are routed to our allocator.
...
For the allocations that do not belong to any malloc zone check whether they're padded with a pointer to ASan's CFAllocator. If so, free the original (unpadded) pointer.
This should fix AddressSanitizerMac.NSURLDeallocation and issue 70.
llvm-svn: 158863
2012-06-20 22:29:09 +00:00
Alexander Potapenko
50e788b724
Add a test for NSURL deallocation (issue 70)
...
llvm-svn: 158843
2012-06-20 20:28:39 +00:00
Chandler Carruth
bf22bd21e9
Resuming work on the compiler-rt CMake build at long long last. In order
...
to get it working again, two changes were needed:
- I had to give up on glob-based file expansion. This just isn't well
supported by CMake, and until we convince upstream there of its value,
it's not worth dealing with the pain.
- Add the common library as otherwise even ASan won't build.
This now builds again, although the "correctness" of it is a touch
debatable. ;] Specifically, there is no merging of the common runtime
library with the asan runtime library into a single archive file. I'm
not really sure what the best technique is for that, and it may be
influenced by the ongoing discussion about how best to link runtime
libraries.
Note of course that this is still very much WIP. It doesn't entirely
work yet, and remains disabled by the LLVM projects/CMakeLists.txt until
it is in a working state.
llvm-svn: 158811
2012-06-20 10:18:43 +00:00
Alexey Samsonov
e1cb524226
[Sanitizer] Renaming: SNPrintf -> internal_snprintf (and move it to sanitizer libc)
...
llvm-svn: 158710
2012-06-19 09:21:57 +00:00
Alexey Samsonov
0d76e8983f
[Sanitizer] Use ProcessMaps in symbolizer to get module name and offset for instruction address
...
llvm-svn: 158522
2012-06-15 14:00:25 +00:00
Alexey Samsonov
156958dd0c
[Sanitizer] move all the rest re-implementations of libc functions from ASan runtime to common sanitizer runtime
...
llvm-svn: 158519
2012-06-15 13:09:52 +00:00
Alexey Samsonov
3efd6fc26c
[Sanitizer] Use DEFINE_REAL macro in TSan runtime to call libc implementations of functions. Move strchr to sanitizer_libc.
...
llvm-svn: 158517
2012-06-15 12:24:07 +00:00
Alexey Samsonov
40e5128412
[Sanitizer] move ShadowRangeIsAvailable and several defines to common runtime
...
llvm-svn: 158499
2012-06-15 07:29:14 +00:00
Alexey Samsonov
e4a889866d
[Sanitizer] move atomic ops, min/max and sort to commnon runtime
...
llvm-svn: 158496
2012-06-15 07:00:31 +00:00
Alexey Samsonov
70afb91636
[Sanitizer] move more portability wrappers to common runtime: sleep, _exit, abort, atexit, pthread_self
...
llvm-svn: 158493
2012-06-15 06:37:34 +00:00
Alexey Samsonov
ae1e171b72
[Sanitizer] move DumpProcessMap and DisableCoreDumper to common runtime
...
llvm-svn: 158490
2012-06-15 06:08:19 +00:00
Alexey Samsonov
c70d1086f6
[Sanitizer] move rest of mmap routines to common sanitizer runtime
...
llvm-svn: 158452
2012-06-14 14:42:58 +00:00
Alexey Samsonov
0c53a38abb
[Sanitizer] move portable GetEnv to common sanitizer runtime
...
llvm-svn: 158451
2012-06-14 14:07:21 +00:00
Alexey Samsonov
96ef49a71e
[Sanitizer] Move internal_memcmp to common sanitizer libc
...
llvm-svn: 158450
2012-06-14 14:04:54 +00:00
Alexey Samsonov
52f946611f
[ASan] don't include deleted header
...
llvm-svn: 158448
2012-06-14 13:15:45 +00:00
Alexey Samsonov
53daa28e77
[ASan] remove obsolete header asan_procmaps.h
...
llvm-svn: 158447
2012-06-14 12:51:20 +00:00
Alexey Samsonov
59036d2c06
[Sanitizer] add internal_memset and internal_strrchr to sanitizer_common/
...
llvm-svn: 158202
2012-06-08 14:11:12 +00:00
Alexey Samsonov
99d58521c5
[ASan] allow calls to memmove during rtl initialization
...
llvm-svn: 158201
2012-06-08 14:04:04 +00:00
Alexey Samsonov
f26b842ca8
[ASan] add interceptor for strncat
...
llvm-svn: 158198
2012-06-08 13:27:46 +00:00
Kostya Serebryany
0b14fd855b
[asan] slow 16-byte redzones (still experimental)
...
llvm-svn: 158143
2012-06-07 09:15:48 +00:00
Alexey Samsonov
cf4d3a027d
[Sanitizer] Fix mac build.
...
llvm-svn: 158141
2012-06-07 07:32:00 +00:00
Alexey Samsonov
4b1f1031e6
[Sanitizer] factor out GetThreadStackTopAndBottom from ASan runtime to common.
...
llvm-svn: 158140
2012-06-07 07:13:46 +00:00
Alexey Samsonov
28a9895ee0
[Sanitizer] __asan::AsanProcMaps -> __sanitizer::ProcessMaps.
...
llvm-svn: 158139
2012-06-07 06:15:12 +00:00
Alexey Samsonov
fe44fbd750
[Sanitizer] Move ReadFileToBuffer to sanitizer_common.
...
llvm-svn: 158138
2012-06-07 05:38:26 +00:00
Kostya Serebryany
112ac68d52
[asan] more compaction: don't use the next field while the chunk is in allocated state
...
llvm-svn: 158083
2012-06-06 16:58:21 +00:00
Kostya Serebryany
c0bbfbfba2
[asan] more allocator compaction
...
llvm-svn: 158082
2012-06-06 16:33:46 +00:00
Alexey Samsonov
40d5b772e5
[Sanitizer] Switch to common mmap/munmap routines in ASan run-time.
...
llvm-svn: 158078
2012-06-06 16:15:07 +00:00
Alexey Samsonov
e95e29c2ac
[Sanitizer] Make UNIMPLEMENTED macro common.
...
llvm-svn: 158077
2012-06-06 15:47:40 +00:00
Kostya Serebryany
00e22d2b2c
[asan] more compaction for allocator
...
llvm-svn: 158076
2012-06-06 15:30:55 +00:00
Alexey Samsonov
e428779dbf
[Sanitizer] Use common CHECK machinery. Currently each tool has to define its own CheckFailed function.
...
llvm-svn: 158075
2012-06-06 15:22:20 +00:00
Kostya Serebryany
79437fe376
[asan] make tid u32 instead of int
...
llvm-svn: 158074
2012-06-06 15:06:58 +00:00
Kostya Serebryany
53b74ac256
[asan] start compacting the allocator header, the goal is to make it 16 bytes w/o losing any information
...
llvm-svn: 158072
2012-06-06 14:46:38 +00:00