summaryrefslogtreecommitdiff
path: root/lib/asan/asan_malloc_mac.cc
AgeCommit message (Collapse)Author
2015-12-04[ASan] Retire mac_ignore_invalid_free, remove some dead code.Alexander Potapenko
mac_ignore_invalid_free was helpful when ASan runtime used to intercept CFAllocator and sometimes corrupted its memory. This behavior had been long gone, and the flag was unused. This patch also deletes ReportMacCfReallocUnknown(), which was used by the CFAllocator realloc() wrapper. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@254722 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-04[tsan] Use malloc zone interceptors on OS X, part 1 (refactoring)Kuba Brecka
TSan needs to use a custom malloc zone on OS X, which is already implemented in ASan. This patch is a refactoring patch (NFC) that extracts this from ASan into sanitizer_common, where we can reuse it in TSan. Reviewed at http://reviews.llvm.org/D14330 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@252052 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-04Revert "[ASan] Add the new __asan_mz_* symbols to asan_interface_internal.h"Juergen Ributzka
Reverting r228137 to unbreak the build bots. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@228172 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-04[ASan] Add the new __asan_mz_* symbols to asan_interface_internal.hAlexander Potapenko
to fix the interface_symbols_darwin.c test. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@228137 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-03[ASan] Remove ifdefs for MAC_OS_X_VERSION_10_6, as ASan assumes OSX >= 10.6Alexander Potapenko
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@227968 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-03[ASan] Add __asan_ prefix for "mz_*" allocation/deallocation functionsAlexander Potapenko
and make them global so that they're not removed by `strip -x`. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@227967 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-02Replace InternalScopedBuffer<char> with InternalScopedString where applicable.Alexey Samsonov
Summary: No functionality change. Test Plan: make check-all Reviewers: kcc Reviewed By: kcc Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D6472 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@223164 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-14[asan] use some LIKELY/UNLIKELYKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@208776 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-04[ASan] Get rid of asan_mac.h, which contents have been moved to sanitizer_mac.hAlexander Potapenko
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@200757 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-03[ASan] Move GetMacosVersion() to sanitizer_common.Alexander Potapenko
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@200700 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-16[asan] Fix a bunch of style issues.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@199380 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-16[asan] Implement delayed activation of AddressSanitizerEvgeniy Stepanov
This change adds ASAN_OPTIONS=start_deactivated=1 flag. When present, ASan will start in "deactivated" mode, with no heap poisoning, no quarantine, no stack trace gathering, and minimal redzones. All this features come back when __asan_init is called for the constructor of an instrumented library. The primary use case for this feature is Android. Code itself is not Android-specific, and this patch includes a Linux test for it. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@199377 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-04[ASan] Do not protect the malloc zone created by malloc_zone_create() on ↵Alexander Potapenko
Snow Leopard and earlier systems. Fixes https://code.google.com/p/address-sanitizer/issues/detail?id=208 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@185621 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-28[ASan][OSX] Make sure the zones created by malloc_create_zone() are ↵Alexander Potapenko
write-protected. Add a test. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@185140 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-28[ASan][OSX] Fix the incorrect malloc_create_zone() implementation that led ↵Alexander Potapenko
to out-of-bounds mprotect()s (https://code.google.com/p/address-sanitizer/issues/detail?id=203) Add a test. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@185138 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-03[ASan] Kill the remainders of platform defines in favor of SANITIZER_ definesAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@178629 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-21[ASan] Switch ASan to generic ThreadRegistry from sanitizer_common. Delete ↵Alexey Samsonov
ASan-specific AsanThreadRegistry. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177634 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-20[ASan] Move malloc stats collection away from AsanThreadRegistry class.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177508 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-19[sanitizer] More renamed macros.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177401 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-19[sanitizer] Replace more platform checks with SANITIZER_ constants.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177400 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-22[ASan] Use dylib interposition to hook memory allocation in the dynamic runtime.Alexander Potapenko
This CL drastically simplifies the way we're hooking the memory allocation routines in ASan on Mac by using dylib interposition to replace the main malloc_zone_* functions. This allows us to avoid replacing the default CFAllocator and drop the CF dependency at all. Committing this patch will result in the static runtime being broken. A follow-up CL will switch ASan to use the dynamic runtime library. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@173134 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-21[asan] add a flag alloc_dealloc_mismatch (off by default for now) which ↵Kostya Serebryany
finds malloc/delete, new/free, new/delete[], etc mismatches git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@170869 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-13[asan] fix mac buildKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@170118 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-13[asan] add two asan flags: fast_unwind_on_fatal and fast_unwind_on_malloc to ↵Kostya Serebryany
allow using the slow CFI-based unwinder git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@170117 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-23[asan] get rid of some of the uses of kPageSize. The intent is to get rid of ↵Kostya Serebryany
it completely to support platforms with multiple possible page sizes. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@168517 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-24[ASan] Rename ReplaceCFAllocator to MaybeReplaceCFAllocator.Alexander Potapenko
Replace the allocator only if the replace_cfallocator flag is set (in some cases it wasn't checked) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@166550 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-09[Sanitizer] Remove unneeded returns after UNIMPLEMENTED macroAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@165493 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-12Give more accurate malloc statistics to malloc_zone_statistics().Alexander Potapenko
Fix a warning in macros instantiation. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@163716 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-12[ASan] more macro/casting magic to suppress warningsAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@163706 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-12Initial support for malloc_zone_statistics. All counters are set to zero now.Alexander Potapenko
This is required to overcome a crash in mstats() (http://code.google.com/p/address-sanitizer/issues/detail?id=109) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@163690 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-29For invalid pointers passed to free_common check whether they are actually ↵Alexander Potapenko
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@162839 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-28[asan] get rid of AsanPrintf in favor of Printf from sanitizer_commonKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@162746 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-17Commit the source and CMake changes that will allow to build ASan runtimeAlexander Potapenko
as a shared library on Mac OS. This will provide an alternative to mach_override. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@162091 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-10Remove the setjmp.h dependency, fix the comment.Alexander Potapenko
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@161662 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-10Temporary fix for ↵Alexander Potapenko
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(). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@161661 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-09[ASan] Move mac-specific error reports to asan_report.cc as wellAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@161576 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-23Intercept CFAllocator for each thread in the program.Alexander Potapenko
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@160630 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-09[ASan] Use common flags parsing machinery.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@159933 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-06Small fix: do not replace the default CFAllocator if it has been replaced ↵Alexander Potapenko
already. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@159824 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-06Because CFAllocatorCreate() should also be called after __CFInitialize() on ↵Alexander Potapenko
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@159822 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-06A portable way to check whether __CFInitialize has been called: compare ↵Alexander Potapenko
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@159821 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-06Do not check for __CFRuntimeClassTableSize on non-10.6 systems, where this ↵Alexander Potapenko
symbol is private. This change may cause http://code.google.com/p/address-sanitizer/issues/detail?id=87 to re-appear on Lion. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@159819 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-05Fix http://code.google.com/p/address-sanitizer/issues/detail?id=87 by making ↵Alexander Potapenko
sure we replace the default CFAllocator only after __CFInitialize has been called. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@159749 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-04Do not call malloc_zone_from_ptr() for the pointers passed to mz_size() and ↵Alexander Potapenko
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@159713 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-21Factor the common code out of cf_free and mz_free.Alexander Potapenko
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158885 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-20Actually intercept free() to ensure that the deallocations caused by other ↵Alexander Potapenko
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158863 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-06[Sanitizer]: Introduce a common internal printf function. For now, also use ↵Alexey Samsonov
tool-specific wrappers TsanPrintf (its output is controlled by TSan flags) and AsanPrintf (which copies its results to the ASan-private buffer). Supported formats: %[z]{d,u,x}, %s, %p. Re-write all format strings in TSan according to this format (this should have no effect on 64-bit platforms). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158065 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-04Remove file-type tags for .cc files in ASan run-time libraryAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@157927 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-31[asan] more renamingKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@157746 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-29Add internal_memset and replace the uses of REAL(memset) with it where the ↵Alexander Potapenko
performance allows. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@153641 91177308-0d34-0410-b5e6-96231b3b80d8