summaryrefslogtreecommitdiff
path: root/lib/lsan/lsan_common_linux.cc
AgeCommit message (Collapse)Author
2017-11-06[LSan] Detect dynamic loader by its base address.Alex Shlyapnikov
Summary: Relanding D38600, which was reverted due to various PPC bot failures. If it breaks something again, please provide some pointers to broken bots, not just revert it, otherwise it's very hard to reason what's wrong with this commit. Whenever possible (Linux + glibc 2.16+), detect dynamic loader module by its base address, not by the module name matching. The current name matching approach fails on some configurations. Reviewers: eugenis Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D39275 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@317512 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-05Revert "[LSan] Detect dynamic loader by its base address."Alex Shlyapnikov
This reverts commit r315024. Breaks sysconf_interceptor_bypass_test.cc git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@315031 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-05[LSan] Detect dynamic loader by its base address.Alex Shlyapnikov
Summary: Relanding D33859, which was reverted because it has "broken LOTS of ARM/AArch64 bots for two days". If it breaks something again, please provide some pointers to broken bots, not just revert it, otherwise it's very hard to reason what's wrong with this commit. Whenever possible (Linux + glibc 2.16+), detect dynamic loader module by its base address, not by the module name matching. The current name matching approach fails on some configurations. Reviewers: eugenis Subscribers: aemerson, kubamracek, kristof.beyls, llvm-commits Differential Revision: https://reviews.llvm.org/D38600 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@315024 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-18Don't call exit() from atexit handlers on DarwinFrancis Ricci
Summary: Calling exit() from an atexit handler is undefined behavior. On Linux, it's unavoidable, since we cannot intercept exit (_exit isn't called if a user program uses return instead of exit()), and I haven't seen it cause issues regardless. However, on Darwin, I have a fairly complex internal test that hangs roughly once in every 300 runs after leak reporting finishes, which is resolved with this patch, and is presumably due to the undefined behavior (since the Die() is the only thing that happens after the end of leak reporting). In addition, this is the way TSan works as well, where an atexit handler+Die() is used on Linux, and an _exit() interceptor is used on Darwin. I'm not sure if it's intentionally structured that way in TSan, since TSan sets up the atexit handler and the _exit() interceptor on both platforms, but I have observed that on Darwin, only the _exit() interceptor is used, and on Linux the atexit handler is used. There is some additional related discussion here: https://reviews.llvm.org/D35085 Reviewers: alekseyshl, kubamracek Subscribers: eugenis, vsk, llvm-commits Differential Revision: https://reviews.llvm.org/D35513 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308353 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-05Revert "[sanitizer-coverage] test for -fsanitize-coverage=inline-8bit-counters"Renato Golin
Revert "Mark sancov test as unsupported on Darwin" Revert "[LSan] Detect dynamic loader by its base address." This reverts commit r304633. This reverts commit r304673. This reverts commit r304632. Those commit have broken LOTS of ARM/AArch64 bots for two days. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@304699 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-03[LSan] Detect dynamic loader by its base address.Alex Shlyapnikov
Summary: Whenever possible (Linux + glibc 2.16+), detect dynamic loader module by its base address, not by the module name matching. The current name matching approach fails on some configurations. Reviewers: eugenis Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D33859 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@304633 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-15[lsan] Report the missing linker only when the linker is actually missing.Alex Shlyapnikov
Reviewers: eugenis Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D33218 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@303129 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-19Move valid caller-pc checks out of platform-specific checksFrancis Ricci
Summary: ProcessPlatformSpecificAllocations for linux leak sanitizer iterated over memory chunks and ran two checks concurrently: 1) Ensured the pc was valid 2) Checked whether it was a linker allocation All platforms will need the valid pc check, so it is moved out of the platform- specific file. To prevent code and logic duplication, the linker allocation check is moved as well, with the name of the linker supplied by the platform-specific module. In cases where we don't need to check for linker allocations (ie Darwin), this name will be a nullptr, and we'll only run the caller pc checks. Reviewers: kubamracek, alekseyshl, kcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32130 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@300690 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-13Implement global pointer scanning for darwin leak sanitizerFrancis Ricci
Reviewers: kubamracek, kcc, alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32012 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@300234 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-29Move current thread data out of lsan_common on linuxFrancis Ricci
Summary: Now that we have a platform-specific non-common lsan file, use it to store non-common lsan data. Reviewers: kubamracek Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31472 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@299032 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-27Move lsan allocator cache from lsan_common_linux to lsan_linuxFrancis Ricci
Having this function in common seems to trigger a lot of unrelated test failures. Given that this isn't really common code anyway, move this to a new linux-specific lsan file. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298878 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-27Use pthreads for thread-local lsan allocator cache on darwinFrancis Ricci
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298848 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-21Revert r298274: "Use pthreads for thread-local lsan allocator cache on darwin"Chandler Carruth
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298382 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-20Use pthreads for thread-local lsan allocator cache on darwinFrancis Ricci
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298274 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-20Revert "Use pthreads for thread-local lsan allocator cache on darwin"Francis Ricci
This is still failing stack-use-after-return on linux-aarch64. This reverts commit 5b350130fc4bf6f70c078a5d97096df98a17a057. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298246 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-19Use pthreads for thread-local lsan allocator cache on darwinFrancis Ricci
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298214 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-02Revert "Use pthreads for thread-local lsan allocator cache on darwin"Francis Ricci
Reverting due to revert of prerequisite patch r296706 This reverts commit 6e1f23078c1acc44295065d28167043c4d31ddd1. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@296720 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-01Use pthreads for thread-local lsan allocator cache on darwinFrancis Ricci
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@296707 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-17Revert "Use pthreads for thread-local lsan allocator cache on darwin"Francis Ricci
This caused a failure in Linux-x86_64 stack-use-after-return This reverts commit 1f9563141e999016d13ac3fc6a50fde690381e82. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@295449 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-17Use pthreads for thread-local lsan allocator cache on darwinFrancis Ricci
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@295413 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-17Use pthreads to store current thread id on darwinFrancis Ricci
Summary: __thread is not supported by all darwin versions and architectures, use pthreads instead to allow for building darwin lsan on iossim. Reviewers: kubamracek, kcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29993 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@295405 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-13Use pthreads to manage thread-local storage on darwin for leak sanitizerFrancis Ricci
Summary: __thread is supported on Darwin, but is implemented dynamically via function calls to __tls_get_addr. This causes two issues when combined with leak sanitizer, due to malloc() interception. - The dynamic loader calls malloc during the process of loading the sanitizer dylib, while swapping a placeholder tlv_boostrap function for __tls_get_addr. This will cause tlv_bootstrap to be called in DisabledInThisThread() via the asan allocator. - The first time __tls_get_addr is called, it allocates memory for the thread-local object, during which it calls malloc(). This call will be intercepted, leading to an infinite loop in the asan allocator, in which the allocator calls DisabledInThisThread, which calls tls_get_addr, which calls into the allocator again. Reviewers: kcc, glider, kubamracek Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29786 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@294994 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-26[lsan] Relax check for allocator_end in ProcessGlobalRegionsCallback.Maxim Ostapenko
Differential Revision: https://reviews.llvm.org/D25945 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@285177 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-22[Sanitizer] Introduce ListOfModules object and use it to replace ↵Alexey Samsonov
GetListOfModules(). Summary: This removes the hard limit on the number of loaded modules (used to be 16K), and makes it easier to use LoadedModules w/o causing a memory leak: ListOfModules owns the modules, and makes sure to properly clean them in destructor. Remove filtering functionality that is only needed in one place (LSan). Reviewers: aizatsky Subscribers: llvm-commits, kcc Differential Revision: http://reviews.llvm.org/D17470 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@261554 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-14[LSan] Add "use_ld_allocations" flag to disable old way of DTLS handling.Alexey Samsonov
This flag allows to disable old way of determining dynamic TLS by filtering out allocations from dynamic linker. This will be eventually superseded by __tls_get_addr interceptor (see r257785), after we: 1) Test it in several supported environments 2) Deal with existing problems (currently we can't find a pointer to DTV which is calloc()-ed in pthread_create). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@257789 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-01[compiler-rt] Apply modernize-use-nullptr fixes in sanitizersVedant Kumar
- 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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@248966 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-24[lsan] Add an interface function for on-demand leak checking.Sergey Matveev
Summary: Add an interface function which can be used to periodically trigger leak detection in a long-running process. NB: The meaning of the kIgnored tag has been changed to allow easy clean-up between subsequent leak checks. Previously, this tag was applied to explicitly ignored (i.e. with __lsan_disable() or __lsan_ignore_object()) chunks *and* any chunks only reachable from those. With this change, it's only applied to explicitly ignored chunks. Reviewers: samsonov Reviewed By: samsonov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D9159 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@235728 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-26[lsan] Fix indent.Sergey Matveev
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@230633 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-26LSan: fix a deadlock caused by dl_iterate_phdr().Sergey Matveev
Wrap the StopTheWorld call in a dl_iterate_phdr() callback. This ensures that no other threads are holding the libdl lock, and we can safely reenter it in the tracer thread. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@230631 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-26Change StackDepot interface to use StackTrace more extensivelyAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@220637 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-14LSan: Print warning about dynamic linker only in verbose modeAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@201421 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-23[lsan] Expand a comment to document our dynamic TLS hack.Sergey Matveev
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@199900 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-25[lsan] Minor code health stuff.Sergey Matveev
- introduce logging macros - fix incorrect vector construction git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@198021 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-30[LSan] Rework r191522 - treat allocations with short stack traces as liveAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@191662 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-12[asan] Fix deadlock in stack unwinder on android/x86.Evgeniy Stepanov
Fixes PR17116. Patch by 林作健 (manjian2006 at gmail.com). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@190590 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-26[sanitizer] Add a fast version of StackDepotGet() for use in LSan.Sergey Matveev
Add a class that holds a snapshot of the StackDepot optimized for querying by ID. This allows us to speed up LSan dramatically. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@189217 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-24Revert to C-style callbacks for iteration over allocator chunks.Sergey Matveev
Also clean up LSan code, fix some comments and replace void* with uptr to bring down the number of reinterpret_casts. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@184700 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-14[LSan] Use a typedef for frontier vectorAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@183973 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-14[Sanitizer] Rename InternalVector to InternalMmapVectorAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@183972 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-06[sanitizer] Do not fall back to SlowUnwindStack() in GetStackTrace()Sergey Matveev
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@183414 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-27[lsan] Begin converting LSan tests to output tests.Sergey Matveev
In this CL all old tests are removed and one LIT test is added. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@182730 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-24[lsan] Minor adjustments to LSan messages.Sergey Matveev
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@182648 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-21[lsan] Change CMakeLists to build the common LSan module for ASan.Sergey Matveev
Also, define CAN_SANITIZE_LEAKS. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@182383 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-20[lsan] Fix r182256.Sergey Matveev
Add missing call to GetUserBegin(). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@182267 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-20[lsan] Common leak checking module.Sergey Matveev
Leak checking functionality which will be shared between LSan/ASan/MSan. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@182249 91177308-0d34-0410-b5e6-96231b3b80d8