summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/lsan/lsan_allocator.cc
Commit message (Collapse)AuthorAgeFilesLines
* compiler-rt: Rename .cc file in lib/lsan to .cppNico Weber2019-08-011-353/+0
| | | | | | Like r367463, but for lsan. llvm-svn: 367561
* [sanitizer] Implement reallocarray.Evgeniy Stepanov2019-05-011-0/+11
| | | | | | | | | | | | | | | | 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 llvm-svn: 359708
* 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. llvm-svn: 351636
* Introduce `AddressSpaceView` template parameter to `CombinedAllocator`.Dan Liew2018-12-211-3/+0
| | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 349957
* [Sanitizers] Move pvalloc overflow tests to common.Alex Shlyapnikov2018-06-111-0/+13
| | | | | | | | | | | | | | | | | | | Summary: Now all sanitizers with improved allocator error reporting are covered by these common tests. Also, add pvalloc-specific checks to LSan. HWASan is not covered by sanitizer_common, hence its own pvalloc and other allocator tests. Reviewers: vitalybuka Subscribers: srhines, kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D47970 llvm-svn: 334424
* [Sanitizers] Check alignment != 0 for aligned_alloc and posix_memalignAlex Shlyapnikov2018-06-081-0/+10
| | | | | | | | | | | | | | | 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 llvm-svn: 334316
* [LSan] Report proper error on allocator failures instead of CHECK(0)-ingAlex Shlyapnikov2018-06-051-13/+29
| | | | | | | | | | | | | | | | | | Summary: Following up on and complementing D44404. Currently many allocator specific errors (OOM, for example) are reported as a text message and CHECK(0) termination, not stack, no details, not too helpful nor informative. To improve the situation, detailed and structured errors were defined and reported under the appropriate conditions. Reviewers: eugenis Subscribers: srhines, mgorny, delcypher, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D47645 llvm-svn: 334034
* [Sanitizers] Add more standard compliant posix_memalign implementation for LSan.Alex Shlyapnikov2018-03-121-0/+15
| | | | | | | | | | | | | | | Summary: Add more standard compliant posix_memalign implementation for LSan and use corresponding sanitizer's posix_memalign implenetations in allocation wrappers on Mac. Reviewers: eugenis, fjricci Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D44335 llvm-svn: 327338
* [Sanitizers] Make common allocator agnostic to failure handling modes.Alex Shlyapnikov2018-01-171-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Make common allocator agnostic to failure handling modes and move the decision up to the particular sanitizer's allocator, where the context is available (call stack, parameters, return nullptr/crash mode etc.) It simplifies the common allocator and allows the particular sanitizer's allocator to generate more specific and detailed error reports (which will be implemented later). The behavior is largely the same, except one case, the violation of the common allocator's check for "size + alignment" overflow is now reportied as OOM instead of "bad request". It feels like a worthy tradeoff and "size + alignment" is huge in this case anyway (thus, can be interpreted as not enough memory to satisfy the request). There's also a Report() statement added there. Reviewers: eugenis Subscribers: kubamracek, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D42198 llvm-svn: 322784
* [Sanitizers] ASan/MSan/LSan allocators set errno on failure.Alex Shlyapnikov2017-07-181-11/+6
| | | | | | | | | | | | | | | | | | | | | Summary: ASan/MSan/LSan allocators set errno on allocation failures according to malloc/calloc/etc. expected behavior. MSan allocator was refactored a bit to make its structure more similar with other allocators. Also switch Scudo allocator to the internal errno definitions. TSan allocator changes will follow. Reviewers: eugenis Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D35275 llvm-svn: 308344
* [Sanitizers] LSan allocator set errno on failure.Alex Shlyapnikov2017-07-141-10/+24
| | | | | | | Set proper errno code on alloction failures and change valloc and memalign implementations to satisfy their man-specified requirements. llvm-svn: 308063
* [LSan] Make LSan allocator allocator_may_return_null compliantAlex Shlyapnikov2017-06-301-2/+4
| | | | | | | | | | | | | | | | | | Summary: An attempt to reland D34786 (which caused bot failres on Mac), now with properly intercepted operators new() and delete(). LSan allocator used to always return nullptr on too big allocation requests (the definition of "too big" depends on platform and bitness), now it follows policy configured by allocator_may_return_null flag Reviewers: eugenis Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D34845 llvm-svn: 306845
* MergeAlex Shlyapnikov2017-06-291-1/+1
| | | | llvm-svn: 306748
* [Sanitizers] Rename CallocShouldReturnNullDueToOverflow to ↵Alex Shlyapnikov2017-06-291-1/+1
| | | | | | | | | | | | | | | | CheckForCallocOverflow Summary: Due to changes in semantics, CheckForCallocOverflow makes much more sense now. Reviewers: eugenis Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D34799 llvm-svn: 306747
* Revert "[LSan] Make LSan allocator allocator_may_return_null compliant"Michael Zolotukhin2017-06-291-4/+2
| | | | | | | | This reverts commit r306624. The committed test failed on various bots (e.g. on green dragon). llvm-svn: 306644
* [LSan] Make LSan allocator allocator_may_return_null compliantAlex Shlyapnikov2017-06-291-2/+4
| | | | | | | | | | | | | | | Summary: LSan allocator used to always return nullptr on too big allocation requests (the definition of "too big" depends on platform and bitness), now it follows policy configured by allocator_may_return_null flag. Reviewers: eugenis Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D34786 llvm-svn: 306624
* [Sanitizers] Move cached allocator_may_return_null flag to sanitizer_allocatorAlex Shlyapnikov2017-06-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Move cached allocator_may_return_null flag to sanitizer_allocator.cc and provide API to consolidate and unify the behavior of all specific allocators. Make all sanitizers using CombinedAllocator to follow AllocatorReturnNullOrDieOnOOM() rules to behave the same way when OOM happens. When OOM happens, turn allocator_out_of_memory flag on regardless of allocator_may_return_null flag value (it used to not to be set when allocator_may_return_null == true). release_to_os_interval_ms and rss_limit_exceeded will likely be moved to sanitizer_allocator.cc too (later). Reviewers: eugenis Subscribers: srhines, kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D34310 llvm-svn: 305858
* [Sanitizer] Remove CombinedAllocator::Allocate's 'cleared' parameterAlex Shlyapnikov2017-06-161-1/+1
| | | | | | | | | | | | | | Summary: CombinedAllocator::Allocate cleared parameter is not used anywhere and seem to be obsolete. Reviewers: eugenis Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D34289 llvm-svn: 305590
* Implement standalone lsan interceptors for OS XFrancis Ricci2017-04-111-0/+31
| | | | | | | | | | | | | | Summary: Mimicks the existing tsan and asan implementations of Darwin interception. Reviewers: kubamracek, kcc, glider Subscribers: llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D31889 llvm-svn: 299979
* Reapply "Enable LSan for arm Linux"Maxim Ostapenko2017-04-111-1/+1
| | | | | | This patch reapplies r299923 with typo fixed in BLX macros. llvm-svn: 299948
* Revert r299923, it doesn't build in bootstrap builds.Nico Weber2017-04-111-1/+1
| | | | | | | | | | | | | | | FAILED: lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.arm.dir/sanitizer_linux.cc.o lib/sanitizer_common/sanitizer_linux.cc:1340:24: error: invalid instruction BLX(ip) ^ lib/sanitizer_common/sanitizer_linux.cc:1313:19: note: expanded from macro 'BLX' # define BLX(R) "mov lr, pc; bx" #R "\n" ^ <inline asm>:6:13: note: instantiated into assembly here mov lr, pc; bxip ^~~~ llvm-svn: 299943
* [lsan] Enable LSan for arm LinuxMaxim Ostapenko2017-04-111-1/+1
| | | | | | | | This patch enables LSan for arm Linux. Differential Revision: https://reviews.llvm.org/D29586 llvm-svn: 299923
* Use pthreads for thread-local lsan allocator cache on darwinFrancis Ricci2017-03-271-37/+1
| | | | | | | | | | | | | | | Summary: This patch allows us to move away from using __thread on darwin, which is requiring for building lsan for darwin on ios version 7 and on iossim i386. Reviewers: kubamracek, kcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31291 llvm-svn: 298848
* Factor lsan allocator cache accesses into a functionFrancis Ricci2017-03-221-8/+9
| | | | | | | | | | | | | | | | | | Summary: This patch is the first step towards allows us to move away from using __thread for the allocator cache on darwin, which is requiring for building lsan for darwin on ios version 7 and on iossim i386. This will be followed by patches to move the function into OS-specific files. Reviewers: kubamracek, kcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29994 llvm-svn: 298537
* Revert r298274: "Use pthreads for thread-local lsan allocator cache on darwin"Chandler Carruth2017-03-211-8/+43
| | | | | | | | This fixes a failure currently present on the upstream linux boxes (and reproduces for me as well): http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/1130/steps/64-bit%20check-asan-dynamic/logs/stdio llvm-svn: 298382
* Use pthreads for thread-local lsan allocator cache on darwinFrancis Ricci2017-03-201-43/+8
| | | | | | | | | | | | | | | Summary: This patch allows us to move away from using __thread on darwin, which is requiring for building lsan for darwin on ios version 7 and on iossim i386. Reviewers: kubamracek, kcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29994 llvm-svn: 298274
* Revert "Use pthreads for thread-local lsan allocator cache on darwin"Francis Ricci2017-03-201-8/+43
| | | | | | | | This is still failing stack-use-after-return on linux-aarch64. This reverts commit 5b350130fc4bf6f70c078a5d97096df98a17a057. llvm-svn: 298246
* Use pthreads for thread-local lsan allocator cache on darwinFrancis Ricci2017-03-191-43/+8
| | | | | | | | | | | | | | | Summary: This patch allows us to move away from using __thread on darwin, which is requiring for building lsan for darwin on ios version 7 and on iossim i386. Reviewers: kubamracek, kcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29994 llvm-svn: 298214
* Revert "Use pthreads for thread-local lsan allocator cache on darwin"Francis Ricci2017-03-021-8/+43
| | | | | | | | Reverting due to revert of prerequisite patch r296706 This reverts commit 6e1f23078c1acc44295065d28167043c4d31ddd1. llvm-svn: 296720
* Use pthreads for thread-local lsan allocator cache on darwinFrancis Ricci2017-03-011-43/+8
| | | | | | | | | | | | | | | Summary: This patch allows us to move away from using __thread on darwin, which is requiring for building lsan for darwin on ios version 7 and on iossim i386. Reviewers: kubamracek, kcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29994 llvm-svn: 296707
* Revert "Use pthreads for thread-local lsan allocator cache on darwin"Francis Ricci2017-02-171-8/+43
| | | | | | | | This caused a failure in Linux-x86_64 stack-use-after-return This reverts commit 1f9563141e999016d13ac3fc6a50fde690381e82. llvm-svn: 295449
* Use pthreads for thread-local lsan allocator cache on darwinFrancis Ricci2017-02-171-43/+8
| | | | | | | | | | | | | | | Summary: This patch allows us to move away from using __thread on darwin, which is requiring for building lsan for darwin on ios version 7 and on iossim i386. Reviewers: kubamracek, kcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29994 llvm-svn: 295413
* [lsan] Renable LSan for x86 LinuxMaxim Ostapenko2017-01-311-1/+10
| | | | | | | | | The missed clang part was committed at https://reviews.llvm.org/rL293609 thus we can reenable LSan for x86 Linux. Differential Revision: https://reviews.llvm.org/D28609 llvm-svn: 293610
* Revert "[lsan] Enable LSan for x86 Linux."Evgeniy Stepanov2017-01-231-10/+1
| | | | | | | Breaks tests on i686/Linux due to missing clang driver support: error: unsupported option '-fsanitize=leak' for target 'i386-unknown-linux-gnu' llvm-svn: 292844
* [lsan] Enable LSan for x86 Linux.Maxim Ostapenko2017-01-231-1/+10
| | | | | | | | | | | | | People keep asking LSan to be available on 32 bit targets (e.g. https://github.com/google/sanitizers/issues/403) despite the fact that false negative ratio might be huge (up to 85%). This happens for big real world applications that may contain random binary data (e.g. browser), but for smaller apps situation is not so terrible and LSan still might be useful. This patch adds initial support for x86 Linux (disabled by default), ARM32 is in TODO list. We used this patch (well, ported to GCC) on our 32 bit mobile emulators and it worked pretty fine thus I'm posting it here to initiate further discussion. Differential Revision: https://reviews.llvm.org/D28609 llvm-svn: 292775
* Provide default implementations for sanitizer interface functionsFrancis Ricci2017-01-071-0/+13
| | | | | | | | | | | | | | Summary: Adds a few default implementations for weak interface functions on platforms where weak hooks are not supported. Reviewers: eugenis, samsonov, timurrrr Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D28201 llvm-svn: 291313
* Return memory to OS right after free (not in the async thread).Evgeniy Stepanov2016-11-291-1/+3
| | | | | | | | | | | | | | | | | | 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 llvm-svn: 288091
* [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. llvm-svn: 279793
* [sanitizer] change SizeClassAllocator64 to accept just one template ↵Kostya Serebryany2016-08-251-4/+10
| | | | | | parameter instead of 5. First, this will make the mangled names shorter. Second, this will make adding more parameters simpler. llvm-svn: 279771
* [sanitizers] introduce yet another API function: ↵Kostya Serebryany2016-06-161-0/+2
| | | | | | __sanitizer_install_malloc_and_free_hooks llvm-svn: 272943
* [lsan] [aarch64] Add support for AArch64Adhemerval Zanella2015-10-211-1/+1
| | | | | | | | | | This patch add support for leak sanitizer for aarch64. Similar to MIPS it uses a SizeClassAllocator32 due VMA constraints (aarch64 currently supports 39 and 42-bit VMA). It also fixes the android build issue. llvm-svn: 250898
* Revert "[lsan] [aarch64] Add support for AArch64"Evgeniy Stepanov2015-10-081-1/+1
| | | | | | | | | This reverts commit ea02fa45225c35613bfecab383fb526e24b74497 (r249337). Reason: broken "ninja AsanUnitTests" on Android/AArch64. http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/20675/steps/build%20compiler-rt%20android%2Faarch64/logs/stdio llvm-svn: 249730
* [lsan] [aarch64] Add support for AArch64Adhemerval Zanella2015-10-051-1/+1
| | | | | | | | This patch add support for leak sanitizer for aarch64. Similar to MIPS it uses a SizeClassAllocator32 due VMA constraints (aarch64 currently supports 39 and 42-bit VMA). llvm-svn: 249337
* [compiler-rt] Apply modernize-use-nullptr fixes in sanitizersVedant Kumar2015-10-011-5/+5
| | | | | | | | | | | | | | | | | | - Trim spaces. - Use nullptr in place of 0 for pointer variables. - Use '!p' in place of 'p == 0' for null pointer checks. - Add blank lines to separate function definitions. - Add 'extern "C"' or 'namespace foo' comments after the appropriate closing brackets This is a continuation of work from 409b7b82. The focus here is on the various sanitizers (not sanitizer_common, as before). Patch by Eugene Zelenko! Differential Revision: http://reviews.llvm.org/D13225 llvm-svn: 248966
* Fix compilation warning in compiler-rt.Evgeniy Stepanov2015-09-161-1/+1
| | | | | | | error: width of bit-field 'allocated' (8 bits) exceeds the width of its type; value will be truncated to 1 bit [-Werror,-Wbitfield-width] llvm-svn: 247840
* [LSan] [MIPS] adding support of LSan for mips64/mips64el archMohit K. Bhakkad2015-02-191-4/+14
| | | | | | | | | | | | Patch by Sagar Thakur Reviewers: petarj, earthdok, kcc. Subscribers: samsonov, dsanders, mohit.bhakkad, Anand.Takale, llvm-commits. Differential Revision: http://reviews.llvm.org/D7013 llvm-svn: 229830
* [sanitizer] Rename InitIfLinkerInitialized to InitLinkerInitialized.Sergey Matveev2014-12-191-1/+1
| | | | llvm-svn: 224577
* [sanitizer] add CombinedAllocator::InitIfLinkerInitialized and use it in ↵Kostya Serebryany2014-12-171-1/+1
| | | | | | lsan: speeds up lsan start-up time by ~25% llvm-svn: 224469
* [Sanitizer] Introduce Allocator::may_return_null bool flag.Alexey Samsonov2014-12-121-1/+1
| | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 224148
* Change StackDepot interface to use StackTrace more extensivelyAlexey Samsonov2014-10-261-1/+1
| | | | llvm-svn: 220637
OpenPOWER on IntegriCloud