summaryrefslogtreecommitdiff
path: root/lib/asan/asan_allocator.h
Commit message (Collapse)AuthorAgeFilesLines
* Revert r369472 and r369441Vitaly Buka2019-08-211-59/+22
| | | | | | check-sanitizer does not work on Linux git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@369495 91177308-0d34-0410-b5e6-96231b3b80d8
* [AArch64] Speed-up leak and address sanitizers on AArch64 for 48-bit VMASebastian Pop2019-08-201-22/+59
| | | | | | | | | | | | | | | | | | This patch fixes https://github.com/google/sanitizers/issues/703 On a Graviton-A1 aarch64 machine with 48-bit VMA, the time spent in LSan and ASan reduced from 2.5s to 0.01s when running clang -fsanitize=leak compiler-rt/test/lsan/TestCases/sanity_check_pure_c.c && time ./a.out clang -fsanitize=address compiler-rt/test/lsan/TestCases/sanity_check_pure_c.c && time ./a.out With this patch, LSan and ASan create both the 32 and 64 allocators and select at run time between the two allocators following a global variable that is initialized at init time to whether the allocator64 can be used in the virtual address space. Differential Revision: https://reviews.llvm.org/D60243 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@369441 91177308-0d34-0410-b5e6-96231b3b80d8
* compiler-rt: Rename .cc file in lib/asan to .cppNico Weber2019-08-011-1/+1
| | | | | | | Like r367463, but for asan. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@367558 91177308-0d34-0410-b5e6-96231b3b80d8
* [sanitizer][NFC] Set LargeMmapAllocator type from PrimaryAllocatorVitaly Buka2019-05-011-7/+1
| | | | | | | | | | | | | | They need to have same AddressSpaceView and MapUnmapCallback. Reviewers: eugenis Subscribers: kubamracek, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D61168 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@359719 91177308-0d34-0410-b5e6-96231b3b80d8
* [sanitizer][NFC] Get type of AllocatorCache from CombinedAllocatorVitaly Buka2019-05-011-5/+1
| | | | | | | | | | | | | | Reviewers: eugenis, cryptoad, kcc Reviewed By: kcc Subscribers: kcc, kubamracek, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D61155 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@359715 91177308-0d34-0410-b5e6-96231b3b80d8
* [sanitizer] Implement reallocarray.Evgeniy Stepanov2019-05-011-0/+2
| | | | | | | | | | | | | | | | Summary: It's a cross of calloc and realloc. Sanitizers implement calloc-like check for size overflow. Reviewers: vitalybuka, kcc Subscribers: kubamracek, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D61108 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@359708 91177308-0d34-0410-b5e6-96231b3b80d8
* [sanitizer] Calculate SizeClassAllocator32::ByteMap type from ↵Vitaly Buka2019-04-271-12/+1
| | | | | | | | | | | | | | Params::kSpaceSize and Params::kRegionSizeLog Reviewers: eugenis Subscribers: kubamracek, cryptoad, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D61206 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@359374 91177308-0d34-0410-b5e6-96231b3b80d8
* AddressSanitizer: 64-bit SPARC/Linux portVitaly Buka2019-03-121-1/+5
| | | | | | | | | | | | | | | | | | | Summary: This patch contains the bits required to make the AddressSanitizer work on SPARC64/Linux (SPARC-T4 and later). Patch by Eric Botcazou. Reviewers: #sanitizers, vitalybuka, krytarowski Reviewed By: #sanitizers, vitalybuka Subscribers: brad, vitalybuka, ro, jyknight, kubamracek, fedor.sergeev, jdoerfert, llvm-commits, #sanitizers Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D58434 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355980 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix bug in `AsanAllocatorASVT` (ASan) and `AllocatorASVT` (LSan) templated ↵Dan Liew2019-01-201-1/+2
| | | | | | | | | | | | | | alias. We forgot to pass `AddressSpaceView` to the `CombinedAllocator` which meant we would always use `LocalAddressSpaceView` for the `CombinedAllocator` leading to a static_assert failing when we tried to do `AsanAllocatorASVT<RemoteAddressSpaceView>` or `AllocatorASVT<RemoteAddressSpaceView>`. rdar://problem/45284065 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@351689 91177308-0d34-0410-b5e6-96231b3b80d8
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@351636 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce `AddressSpaceView` template parameter to `CombinedAllocator`.Dan Liew2018-12-211-4/+14
| | | | | | | | | | | | | | | | | | | | | | Summary: This is a follow up to https://reviews.llvm.org/D55764 . For the ASan and LSan allocatorsthe type declarations have been modified so that it's possible to create a combined allocator type that consistently uses a different type of `AddressSpaceView`. We intend to use this in future patches. For the other sanitizers they just use `LocalAddressSpaceView` by default because we have no plans to use these allocators in an out-of-process manner. rdar://problem/45284065 Reviewers: kcc, dvyukov, vitalybuka, cryptoad, eugenis, kubamracek, george.karpenkov, yln Subscribers: #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D55766 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@349957 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce `AddressSpaceView` template parameter to `SizeClassAllocator64`.Dan Liew2018-12-211-1/+5
| | | | | | | | | | | | | | | | | | | | | | Summary: This is a follow up patch to r349138. This patch makes a `AddressSpaceView` a type declaration in the allocator parameters used by `SizeClassAllocator64`. For ASan, LSan, and the unit tests the AP64 declarations have been made templated so that `AddressSpaceView` can be changed at compile time. For the other sanitizers we just hard-code `LocalAddressSpaceView` because we have no plans to use these allocators in an out-of-process manner. rdar://problem/45284065 Reviewers: kcc, dvyukov, vitalybuka, cryptoad, eugenis, kubamracek, george.karpenkov Subscribers: #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D55764 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@349954 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce `AddressSpaceView` template parameter to `SizeClassAllocator32`, ↵Dan Liew2018-12-141-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `FlatByteMap`, and `TwoLevelByteMap`. Summary: This is a follow up patch to r346956 for the `SizeClassAllocator32` allocator. This patch makes `AddressSpaceView` a template parameter both to the `ByteMap` implementations (but makes `LocalAddressSpaceView` the default), some `AP32` implementations and is used in `SizeClassAllocator32`. The actual changes to `ByteMap` implementations and `SizeClassAllocator32` are very simple. However the patch is large because it requires changing all the `AP32` definitions, and users of those definitions. For ASan and LSan we make `AP32` and `ByteMap` templateds type that take a single `AddressSpaceView` argument. This has been done because we will instantiate the allocator with a type that isn't `LocalAddressSpaceView` in the future patches. For the allocators used in the other sanitizers (i.e. HWAsan, MSan, Scudo, and TSan) use of `LocalAddressSpaceView` is hard coded because we do not intend to instantiate the allocators with any other type. In the cases where untemplated types have become templated on a single `AddressSpaceView` parameter (e.g. `PrimaryAllocator`) their name has been changed to have a `ASVT` suffix (Address Space View Type) to indicate they are templated. The only exception to this are the `AP32` types due to the desire to keep the type name as short as possible. In order to check that template is instantiated in the correct a way a `static_assert(...)` has been added that checks that the `AddressSpaceView` type used by `Params::ByteMap::AddressSpaceView` matches the `Params::AddressSpaceView`. This uses the new `sanitizer_type_traits.h` header. rdar://problem/45284065 Reviewers: kcc, dvyukov, vitalybuka, cryptoad, eugenis, kubamracek, george.karpenkov Subscribers: mgorny, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D54904 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@349138 91177308-0d34-0410-b5e6-96231b3b80d8
* [Sanitizers] Check alignment != 0 for aligned_alloc and posix_memalignAlex Shlyapnikov2018-06-081-0/+1
| | | | | | | | | | | | | | | Summary: Move the corresponding tests to the common folder (as all of the sanitizer allocators will support this feature soon) and add the checks specific to aligned_alloc to ASan and LSan allocators. Reviewers: vitalybuka Subscribers: srhines, kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D47924 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@334316 91177308-0d34-0410-b5e6-96231b3b80d8
* [asan] Use dynamic allocator space address on Android/AArch64.Evgeniy Stepanov2018-05-221-1/+2
| | | | | | | | | | | | | | Summary: We need one library to support all of 39, 42 and 48 bit VMAs, and there is no common address that works for all of them. Reviewers: kcc, alekseyshl, javed.absar Subscribers: rengolin, srhines, kubamracek, kristof.beyls, llvm-commits, cryptoad Differential Revision: https://reviews.llvm.org/D47160 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@333025 91177308-0d34-0410-b5e6-96231b3b80d8
* Change kAllocatorSpace for powerpc64.Martin Liska2018-04-231-1/+1
| | | | | | | | | Fixes issue: https://github.com/google/sanitizers/issues/933 Differential Revision: https://reviews.llvm.org/D45950 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@330650 91177308-0d34-0410-b5e6-96231b3b80d8
* [Sanitizers] ASan: detect new/delete calls with mismatched alignment.Alex Shlyapnikov2017-10-251-2/+3
| | | | | | | | | | | | | | | | | | | | ASan allocator stores the requested alignment for new and new[] calls and on delete and delete[] verifies that alignments do match. The representable alignments are: default alignment, 8, 16, 32, 64, 128, 256 and 512 bytes. Alignments > 512 are stored as 512, hence two different alignments > 512 will pass the check (possibly masking the bug), but limited memory requirements deemed to be a resonable tradeoff for relaxed conditions. The feature is controlled by new_delete_type_mismatch flag, the same one protecting new/delete matching size check. Differential revision: https://reviews.llvm.org/D38574 Issue: https://github.com/google/sanitizers/issues/799 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@316595 91177308-0d34-0410-b5e6-96231b3b80d8
* [asan] Allocator support for FuchsiaVitaly Buka2017-08-031-1/+5
| | | | | | | | | | | | | | | | Submitted on behalf of Roland McGrath. Reviewers: vitalybuka, alekseyshl, kcc Reviewed By: alekseyshl Subscribers: srhines, cryptoad, kubamracek, phosek, filcab, llvm-commits Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D36190 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@309914 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r304285, r304297.Evgeniy Stepanov2017-06-051-2/+0
| | | | | | | | | | | r304285 - [sanitizer] Avoid possible deadlock in child process after fork r304297 - [sanitizer] Trying to fix MAC buildbots after r304285 These changes create deadlock when Tcl calls pthread_create from a pthread_atfork child handler. More info in the original review at https://reviews.llvm.org/D33325 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@304735 91177308-0d34-0410-b5e6-96231b3b80d8
* [sanitizer] Avoid possible deadlock in child process after forkMaxim Ostapenko2017-05-311-0/+2
| | | | | | | | | | | | | | | This patch addresses https://github.com/google/sanitizers/issues/774. When we fork a multi-threaded process it's possible to deadlock if some thread acquired StackDepot or allocator internal lock just before fork. In this case the lock will never be released in child process causing deadlock on following memory alloc/dealloc routine. While calling alloc/dealloc routines after multi-threaded fork is not allowed, most of modern allocators (Glibc, tcmalloc, jemalloc) are actually fork safe. Let's do the same for sanitizers except TSan that has complex locking rules. Differential Revision: https://reviews.llvm.org/D33325 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@304285 91177308-0d34-0410-b5e6-96231b3b80d8
* [sanitizer] Change SizeClassAllocator32 to accept just one templateKostya Kortchinsky2017-05-151-4/+11
| | | | | | | | | | | | | | | | | | | | | Summary: With rL279771, SizeClassAllocator64 was changed to accept only one template instead of 5, for the following reasons: "First, this will make the mangled names shorter. Second, this will make adding more parameters simpler". This patch mirrors that work for SizeClassAllocator32. This is in preparation for introducing the randomization of chunks in the 32-bit SizeClassAllocator in a later patch. Reviewers: kcc, alekseyshl, dvyukov Reviewed By: alekseyshl Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D33141 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@303071 91177308-0d34-0410-b5e6-96231b3b80d8
* Improved ASAN allocator and quarantine stats.Evgeniy Stepanov2017-01-051-16/+17
| | | | | | | | | | | | | | Summary: Improved ASAN allocator and quarantine stats. Reviewers: eugenis Patch by Alex Shlyapnikov. Subscribers: llvm-commits, kubabrecka Differential Revision: https://reviews.llvm.org/D28333 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@291183 91177308-0d34-0410-b5e6-96231b3b80d8
* Expose thread local quarantine size as ASAN option.Evgeniy Stepanov2016-12-221-0/+1
| | | | | | | | | | | | | | Summary: Make thread local quarantine size an option so it can be turned off to save memory. Reviewers: eugenis Patch by Alex Shlyapnikov. Subscribers: kubabrecka, llvm-commits Differential Revision: https://reviews.llvm.org/D28027 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@290373 91177308-0d34-0410-b5e6-96231b3b80d8
* Return memory to OS right after free (not in the async thread).Evgeniy Stepanov2016-11-291-0/+1
| | | | | | | | | | | | | | | | | | Summary: In order to avoid starting a separate thread to return unused memory to the system (the thread interferes with process startup on Android, Zygota waits for all threads to exit before fork, but this thread never exits), try to return it right after free. Reviewers: eugenis Subscribers: cryptoad, filcab, danalbert, kubabrecka, llvm-commits Patch by Aleksey Shlyapnikov. Differential Revision: https://reviews.llvm.org/D27003 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@288091 91177308-0d34-0410-b5e6-96231b3b80d8
* [compiler-rt] Set asan win 64-bits to use dynamic address for memory allocatorEtienne Bergeron2016-09-141-0/+4
| | | | | | | | | | | | | | | Summary: ASAN on Windows 64-bits should use a dynamic address instead of a fixed one. The asan-allocator code to support dynamic address is already landed. This patch is turning on the feature. Reviewers: rnk Subscribers: kubabrecka, dberris, llvm-commits, chrisha Differential Revision: https://reviews.llvm.org/D24575 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281522 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch to 64-bit allocator on android/aarch64.Evgeniy Stepanov2016-09-131-2/+8
| | | | | | | This uses the "very compact" size class mapping that fits in the 39-bit address space. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281371 91177308-0d34-0410-b5e6-96231b3b80d8
* [sanitizer] enable random shuffling the memory chunks inside the allocator, ↵Kostya Serebryany2016-08-261-0/+1
| | | | | | under a flag. Set this flag for the scudo allocator, add a test. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@279793 91177308-0d34-0410-b5e6-96231b3b80d8
* [sanitizer] change SizeClassAllocator64 to accept just one template ↵Kostya Serebryany2016-08-251-2/+9
| | | | | | parameter instead of 5. First, this will make the mangled names shorter. Second, this will make adding more parameters simpler. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@279771 91177308-0d34-0410-b5e6-96231b3b80d8
* [asan] minor fix in the asan memory profileKostya Serebryany2016-08-231-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@279547 91177308-0d34-0410-b5e6-96231b3b80d8
* Deal with buildbot fallout from r278917: s/AllocType()/GetAllocType()/ (had ↵Filipe Cabecinhas2016-08-171-1/+1
| | | | | | the same name as the enum) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@278919 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename DescribeHeapAddress to DescribeAddressIfHeap and split it into a ↵Filipe Cabecinhas2016-08-171-0/+1
| | | | | | | | | | | | | | | | | function to get all the information about the address, and one to print it. Summary: Replacement for part of D23518 This deals with heap addresses, and renames DescribeHeapAddress. Requires D23520, which moves code around to make it accessible in asan_describers.cc (and still accessible in asan_report.cc if needed). Reviewers: kcc, samsonov Subscribers: kubabrecka, llvm-commits Differential Revision: https://reviews.llvm.org/D23569 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@278917 91177308-0d34-0410-b5e6-96231b3b80d8
* [asan] add an interface function __sanitizer_print_memory_profile (a basic ↵Kostya Serebryany2016-06-021-0/+2
| | | | | | memory profiler; asan/Linux-only for now) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@271463 91177308-0d34-0410-b5e6-96231b3b80d8
* [asan] Assert in __sanitizer_ptr_{sub,cmp} if one of the pointers was freed.Filipe Cabecinhas2016-04-291-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This (partially) implements the check mentioned at http://kristerw.blogspot.co.uk/2016/04/dangling-pointers-and-undefined-behavior.html (via John Regehr) Quoting: "That the behavior is undefined follows from C11 6.2.4 "Storage durations of objects" The lifetime of an object is the portion of program execution during which storage is guaranteed to be reserved for it. An object exists, has a constant address, and retains its last-stored value throughout its lifetime. If an object is referred to outside of its lifetime, the behavior is undefined. The value of a pointer becomes indeterminate when the object it points to (or just past) reaches the end of its lifetime. and 7.22.3 "Memory management functions" that says that free ends the lifetime of objects The lifetime of an allocated object extends from the allocation until the deallocation. " We can probably implement this for stack variables too, but I think this is a good start to see if there's interest in this check. We can also hide this behind a flag, too. Reviewers: samsonov, kcc, rsmith, regehr Subscribers: kubabrecka, llvm-commits Differential Revision: http://reviews.llvm.org/D19691 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@268097 91177308-0d34-0410-b5e6-96231b3b80d8
* [asan] Intercept all Heap* related imports from ucrtbase.dllReid Kleckner2016-03-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | ucrtbase.dll appears to be built with some kind of cross-module inlining, because there are calls to imported Heap* routines sprinkled throughout the code. This inlining defeats our attempts to hotpatch malloc, _malloc_base, and related functions. Failing to intercept an allocation or deallocation results in a crash when the program attempts to deallocate or reallocate memory with the wrong allocator. This change patches the IAT of ucrtbase.dll to replace the addresses of the imported Heap* functions with implementations provided by ASan. We don't globally intercept the win32 Heap* functions because they are typically used by system DLLs that run before ASan initializes. Eventually, we may want to intercept them, but for now I think this is the minimal change that will keep ASan stable. Reviewers: samsonov Differential Revision: http://reviews.llvm.org/D18413 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@264327 91177308-0d34-0410-b5e6-96231b3b80d8
* [asan] Enable ASan for AArch64/42-bit VMAAdhemerval Zanella2015-08-201-0/+5
| | | | | | | | | | | | This patch adds support for asan on aarch64-linux with 42-bit VMA (current default config for 64K pagesize kernels). The support is enabled by defining the SANITIZER_AARCH64_VMA to 42 at build time for both clang/llvm and compiler-rt. The default VMA is 39 bits. For 42-bit VMA aarch64 uses SANITIZIER_CAN_USER_ALLOCATOR64. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@245596 91177308-0d34-0410-b5e6-96231b3b80d8
* [ASan] Clean up obsolete stats.Alexey Samsonov2015-06-261-1/+1
| | | | | | | | Remove stats that we no longer collect after the allocator change. Use proper constant SizeClassMap::kNumClasses to fix potential buffer overflow (https://code.google.com/p/address-sanitizer/issues/detail?id=397). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@240816 91177308-0d34-0410-b5e6-96231b3b80d8
* [asan] add a flag soft_rss_limit_mbKostya Serebryany2015-01-061-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@225323 91177308-0d34-0410-b5e6-96231b3b80d8
* [ASan] Change activation strategy.Alexey Samsonov2014-12-191-0/+2
| | | | | | | | | | | Now ASan deactivation doesn't modify common or ASan-specific runtime flags. Flags stay constant after initialization, and "deactivation" instead stashes initialized runtime state, and deactivates the runtime. Activation then just restores the original state (possibly, overriden by some activation flags provided in system property on Android). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224614 91177308-0d34-0410-b5e6-96231b3b80d8
* [ASan] Introduce AllocatorOptions to configure allocator behavior.Alexey Samsonov2014-12-191-2/+13
| | | | | | | | | | | | | | | | | | | Summary: Reduce the dependency of allocator code on runtime flags. Instead, pass a bunch of options that configure allocator behavior at initialization or re-initialization. That would allow us to cleaner modify allocator behavior during a program execution when ASan is activated or de-activated. Test Plan: regression test suite Reviewers: kcc Subscribers: llvm-commits, eugenis Differential Revision: http://reviews.llvm.org/D6711 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224605 91177308-0d34-0410-b5e6-96231b3b80d8
* [ASan] Re-structure the allocator code. NFC.Alexey Samsonov2014-12-171-2/+2
| | | | | | | | | | | | | Introduce "Allocator" object, which contains all the bits and pieces ASan allocation machinery actually use: allocator from sanitizer_common, quarantine, fallback allocator and quarantine caches, fallback mutex. This step is a preparation to adding more state to this object. We want to reduce dependency of Allocator on commandline flags and be able to "safely" modify its behavior (such as the size of the redzone) at runtime. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224406 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename asan_allocator2.cc to asan_allocator.ccAlexey Samsonov2014-12-171-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224396 91177308-0d34-0410-b5e6-96231b3b80d8
* [Sanitizer] Introduce Allocator::may_return_null bool flag.Alexey Samsonov2014-12-121-2/+2
| | | | | | | | | | | | | | | | | | | | Summary: Turn "allocator_may_return_null" common flag into an Allocator::may_return_null bool flag. We want to make sure that common flags are immutable after initialization. There are cases when we want to change this flag in the allocator at runtime: e.g. in unit tests and during ASan activation on Android. Test Plan: regression test suite, real-life applications Reviewers: kcc, eugenis Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D6623 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224148 91177308-0d34-0410-b5e6-96231b3b80d8
* [Sanitizer] Make StackTrace a lightweight reference to array of PCs, andAlexey Samsonov2014-10-261-11/+11
| | | | | | | | | | | | | | | | | | | | | | introduce a BufferedStackTrace class, which owns this array. Summary: This change splits __sanitizer::StackTrace class into a lightweight __sanitizer::StackTrace, which doesn't own array of PCs, and BufferedStackTrace, which owns it. This would allow us to simplify the interface of StackDepot, and eventually merge __sanitizer::StackTrace with __tsan::StackTrace. Test Plan: regression test suite. Reviewers: kcc, dvyukov Reviewed By: dvyukov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D5985 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@220635 91177308-0d34-0410-b5e6-96231b3b80d8
* [asan] add a feature to detect new-delete-size-mismatch (when used with ↵Kostya Serebryany2014-07-301-0/+2
| | | | | | -Xclang -fsized-deallocation). Not yet on Mac. Also, remove some unused code. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@214296 91177308-0d34-0410-b5e6-96231b3b80d8
* [asan] fix the alloctor code to not use opaque data structure, which was ↵Kostya Serebryany2014-04-151-2/+39
| | | | | | larger than needed. This was a leftover of the allocator1=>allocator2 migration; thanks Yuri Gribov for reminding git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@206280 91177308-0d34-0410-b5e6-96231b3b80d8
* [asan] *experimental* implementation of invalid-pointer-pair detector (finds ↵Kostya Serebryany2014-02-271-0/+1
| | | | | | when two unrelated pointers are compared or subtracted). This implementation has both false positives and false negatives and is not tuned for performance. A bug report for a proper implementation will follow. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@202389 91177308-0d34-0410-b5e6-96231b3b80d8
* [asan] Reinitialize allocator quarantine on activation.Evgeniy Stepanov2014-02-031-0/+1
| | | | | | | | This is covered by AddressSanitizer.UAF_* tests in asan_test with start_deactivated=1. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@200696 91177308-0d34-0410-b5e6-96231b3b80d8
* asan: fix atomic operations on ARMDmitry Vyukov2014-01-221-1/+2
| | | | | | | | | | | implement correct atomic load/store for ARM add test for atomic load/store http://llvm-reviews.chandlerc.com/D2582 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@199802 91177308-0d34-0410-b5e6-96231b3b80d8
* [ASan] Clarify that AsanThread objects are allocated only via mmap(). No ↵Alexey Samsonov2013-11-271-7/+3
| | | | | | functionality change. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@195840 91177308-0d34-0410-b5e6-96231b3b80d8
* [ASan] Do not rely on malloc context in allocator reports.Alexey Samsonov2013-11-131-1/+1
| | | | | | | | | | | | Invoke a fatal stack trace unwinder when ASan prints allocator-relevant error reports (double-free, alloc-dealloc-mismatch, invalid-free). Thus we'll be able to print complete stack trace even if allocation/free stacks are not stored (malloc_context_size=0). Based on the patch by Yuri Gribov! git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@194579 91177308-0d34-0410-b5e6-96231b3b80d8