summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_procmaps_mac.cc
AgeCommit message (Collapse)Author
2017-11-10[compiler-rt] Fix const and volatile qualifier warningsKuba Mracek
Building with a new clang produces a bunch of warnings about dropped 'const' and 'volatile' qualifiers on pointers. Let's fix them. Differential Revision: https://reviews.llvm.org/D39861 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@317929 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-29Move LoadedModule list to a NoCtor vector and initialize on demand.Francis Ricci
Unreverting this patch because llvm-clang-lld-x86_64-debian-fast started passing again before the revert hit. Must've been just a flake. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@314556 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-29Revert "Move LoadedModule list to a NoCtor vector and initialize on demand."Francis Ricci
I think this may have introduced a failure on llvm-clang-lld-x86_64-debian-fast This reverts commit r314533 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@314552 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-29Move LoadedModule list to a NoCtor vector and initialize on demand.Francis Ricci
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@314533 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-28Revert "Add support for custom loaders to the sanitizer symbolizer"Francis Ricci
This causes the gcc sanitizer buildbot to timeout. This reverts commit 81f388fe570e5b6460dd5bc9b9a36b72714eeb68. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@314453 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-28Add support for custom loaders to the sanitizer symbolizerFrancis Ricci
Summary: Adds a fallback mode to procmaps when the symbolizer fails to locate a module for a given address by using dl_iterate_phdr. Reviewers: kubamracek, rnk, vitalybuka, eugenis Reviewed By: eugenis Subscribers: srhines, llvm-commits Differential Revision: https://reviews.llvm.org/D37269 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@314431 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-27Revert "Add support for custom loaders to symbolizer"Francis Ricci
This broke the windows buildbots, revert for now. This reverts commit 24050b5ddef42f6f3306aa94d4a1f42a7893a9a7. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@314347 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-27Add support for custom loaders to symbolizerFrancis Ricci
Change-Id: I5594bd6b216deca2c73cf0a7001f9aec1e803c60 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@314342 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-22Removed platform-specific ifdefs from sanitizer_procmaps.hFrancis Ricci
Summary: Removed platform-specific ifdefs for linux, mac, freebsd and netbsd from sanitizer_procmaps.h Patch by Yicheng Wang <yichengfb@fb.com> Reviewers: kcc, kubamracek, alekseyshl, fjricci, vitalybuka Reviewed By: fjricci, vitalybuka Subscribers: vitalybuka, emaste, krytarowski, llvm-commits Differential Revision: https://reviews.llvm.org/D38098 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@313999 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-25Only scan global sections containing data in LSan on darwinFrancis Ricci
Summary: __DATA segments on Darwin contain a large number of separate sections, many of which cannot actually contain pointers, and contain const values or objc metadata. Not scanning sections which cannot contain pointers significantly improves performance. On a medium-sized (~4000 files) internal project, I saw a speedup of about 30% in standalone LSan's execution time (30% improvement in the time spent running LSan, not the total program time). Reviewers: kcc, kubamracek, alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D35432 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308999 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-25Add address ranges for individual macho sections on darwinFrancis Ricci
Summary: This is a re-upload of the reverted commit r308644. It has changed quite a bit to reflect post-commit comments by kcc, so I'm re-uploading as a new review. Reviewers: kubamracek, alekseyshl, kcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D35799 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308977 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-20Revert "Add MemoryMappedSection struct for two-level memory map iteration"Francis Ricci
This probably broke lib0 tsan unit test on 10.11 buildbots This reverts commit 35ad307c385e384f47a7fb348c14b3602d3a33c4. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308676 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-20Add MemoryMappedSection struct for two-level memory map iterationFrancis Ricci
Summary: This will allow sanitizer_procmaps on mac to expose section information. Reviewers: kubamracek, alekseyshl, kcc Subscribers: llvm-commits, emaste Differential Revision: https://reviews.llvm.org/D35422 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308644 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-18Revert "Add MemoryMappedSection struct for two-level memory map iteration"Francis Ricci
This reverts commit c8095ce74118dee8544b0f1ffaba8f46aa10215c. Reverted due to some buildbot timeouts, perhaps due to 10.11 issues. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308395 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-18Revert "Only scan global sections containing data in LSan on darwin"Francis Ricci
This reverts commit 7e46d78d47832f03ce42adcf56417fbfd47cbaad. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308394 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-17Only scan global sections containing data in LSan on darwinFrancis Ricci
Summary: __DATA segments on Darwin contain a large number of separate sections, most of which cannot actually contain pointers, and contain const values or objc metadata. Only scanning sections which can contain pointers greatly improves performance. On a medium-sized (~4000 files) internal project, I saw a speedup of about 50% in standalone LSan's execution time (50% improvement in the time spent running LSan, not the total program time). Reviewers: kcc, kubamracek, alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D35432 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308231 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-17Add MemoryMappedSection struct for two-level memory map iterationFrancis Ricci
Summary: This will allow sanitizer_procmaps on mac to expose section information. Reviewers: kubamracek, alekseyshl, kcc Subscribers: llvm-commits, emaste Differential Revision: https://reviews.llvm.org/D35422 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308210 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-11Inline function to get mac segment address rangeFrancis Ricci
Summary: This function is only called once and is fairly simple. Inline to keep API simple. Reviewers: alekseyshl, kubamracek Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D35270 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@307695 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-11Refactor MemoryMappingLayout::Next to use a single struct instead of output ↵Francis Ricci
parameters. NFC. Summary: This is the first in a series of patches to refactor sanitizer_procmaps to allow MachO section information to be exposed on darwin. In addition, grouping all segment information in a single struct is cleaner than passing it through a large set of output parameters, and avoids the need for annotations of NULL parameters for unneeded information. The filename string is optional and must be managed and supplied by the calling function. This is to allow the MemoryMappedSegment struct to be stored on the stack without causing overly large stack sizes. Reviewers: alekseyshl, kubamracek, glider Subscribers: emaste, llvm-commits Differential Revision: https://reviews.llvm.org/D35135 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@307688 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-19Use write instead of read permissions to check for global sections on macFrancis Ricci
Summary: The LINKEDIT section is very large and is read-only. Scanning this section caused LSan on darwin to be very slow. When only writable sections are scanned for global pointers, performance improved by a factor of about 25x. Reviewers: alekseyshl, kubamracek Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D33322 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@303422 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-12Add dyld to sanitizer procmaps on darwinFrancis Ricci
Summary: Sanitizer procmaps uses dyld apis to iterate over the list of images in the process. This is much more performan than manually recursing over all of the memory regions in the process, however, dyld does not report itself in the list of images. In order to prevent reporting leaks from dyld globals and to symbolize dyld functions in stack traces, this patch special-cases dyld and ensures that it is added to the list of modules. This is accomplished by recursing through the memory map of the process until a dyld Mach header is found. While this recursion is expensive, it is run before the full set of images has been loaded in the process, so only a few calls are required. The result is cached so that it never needs to be searched for when the full process memory map exists, as this would be incredibly slow, on the order of minutes for leak sanitizer with only 25 or so libraries loaded. Reviewers: alekseyshl, kubamracek Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32968 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@302899 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-10Revert "Add dyld to sanitizer procmaps on darwin"Francis Ricci
This breaks several tests because we don't always have access to __cxa_guard functions This reverts commit 45eb470c3e9e8f6993a204e247c33d4092237efe. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@302693 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-10Revert "Disable static caching of dyld header on Go sanitizers"Francis Ricci
This is a problem on more than just the go sanitizers, so it's not a good enough fix for the issue. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@302692 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-10Disable static caching of dyld header on Go sanitizersFrancis Ricci
This causes buildbot failures due to undefined __cxa_guard_acquire git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@302681 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-10Add dyld to sanitizer procmaps on darwinFrancis Ricci
Summary: Sanitizer procmaps uses dyld apis to iterate over the list of images in the process. This is much more performan than manually recursing over all of the memory regions in the process, however, dyld does not report itself in the list of images. In order to prevent reporting leaks from dyld globals and to symbolize dyld functions in stack traces, this patch special-cases dyld and ensures that it is added to the list of modules. This is accomplished by recursing through the memory map of the process until a dyld Mach header is found. While this recursion is expensive, it is run before the full set of images has been loaded in the process, so only a few calls are required. The result is cached so that it never needs to be searched for when the full process memory map exists, as this would be incredibly slow, on the order of minutes for leak sanitizer with only 25 or so libraries loaded. Reviewers: alekseyshl, kubamracek Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32968 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@302673 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-17Don't read non-readable address ranges during lsan pointer scanningFrancis Ricci
Summary: This specifically addresses the Mach-O zero page, which we cannot read from. Reviewers: kubamracek, samsonov, alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32044 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@300456 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-06[sanitizer] Track which modules are instrumented in LoadedModule objectsKuba Mracek
This patch adds tracking which modules are instrumented and which are not. On macOS, instrumented modules link against the ASan/TSan/... dylib, so we can just check if such a load command exists or not. Differential Revision: https://reviews.llvm.org/D28263 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@291268 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-25[sanitizer] Define some CPU type symbols (like CPU_SUBTYPE_X86_64_H) when ↵Kuba Mracek
they're not available. This allows compiler-rt to be built on older macOS SDKs, where there symbols are not defined. Patch by Jeremy Huddleston Sequoia <jeremyhu@apple.com>. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@290521 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-02[sanitizer] Track architecture and UUID of modules in LoadedModuleKuba Mracek
When we enumerate loaded modules, we only track the module name and base address, which then has several problems on macOS. Dylibs and executables often have several architecture slices and not storing which architecture/UUID is actually loaded creates problems with symbolication: A file path + offset isn't enough to correctly symbolicate, since the offset can be valid in multiple slices. This is especially common for Haswell+ X86_64 machines, where x86_64h slices are preferred, but if one is not available, a regular x86_64 is loaded instead. But the same issue exists for i386 vs. x86_64 as well. This patch adds tracking of arch and UUID for each LoadedModule. At this point, this information isn't used in reports, but this is the first step. The goal is to correctly identify which slice is loaded in symbolication, and also to output this information in reports so that we can tell which exact slices were loaded in post-mortem analysis. Differential Revision: https://reviews.llvm.org/D26632 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@288537 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
2015-12-04[libsanitizer] Fix bugs and wiki links to point to GitHub.Alexander Potapenko
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@254738 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-06[ASan] Unify handling of loaded modules between POSIX and WindowsTimur Iskhodzhanov
Reviewed at http://reviews.llvm.org/D8805 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234150 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-06-25[ASan] When iterating over segments on OSX, treat the segments' initialAlexander Potapenko
protection level as their current protection level. This fixes the UNIMPLEMENTED check that started to fire on OSX after r210649. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@211713 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-11[asan] Exclude non-executable mappings from coverage.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@210649 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-25[Sanitizer] Remove now unused symbolization functionality from ↵Alexey Samsonov
MemoryMappingLayout git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@198014 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-25[Sanitizer] Use different MemoryMappingLayout::DumpListOfModules on Linux ↵Alexey Samsonov
and Mac. Make a unit test added in r198004 more robust. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@198012 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-25[Sanitizer] Move OS-specific code for MemoryMappingLayout into separate ↵Alexey Samsonov
source files. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@198003 91177308-0d34-0410-b5e6-96231b3b80d8