summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_symbolizer.h
AgeCommit message (Collapse)Author
2017-10-02Add 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@314713 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-02Revert "Add support for custom loaders to the sanitizer symbolizer"Francis Ricci
This reverts commit r314671, which hangs on the gcc sanitizer buildbot. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@314684 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-02Add 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@314671 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-29Add missing header definitionFrancis Ricci
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@314521 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-26Invalidate symbolizer module list from dlopen/dlclose interceptorsFrancis Ricci
Summary: The module list should only be invalidated by dlopen and dlclose, so the symbolizer should only re-generate it when we've hit one of those functions. Reviewers: kubamracek, rnk, vitalybuka Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D37268 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@314219 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-06[sanitizer] Use architecture/slice information when symbolizing fat Mach-O ↵Kuba Mracek
files on Darwin This patch starts passing architecture information about a module to llvm-symbolizer and into text reports. This fixes the longstanding x86_64/x86_64h mismatch issue on Darwin. Differential Revision: https://reviews.llvm.org/D27390 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@291287 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15TestCase null_deref was failing in Win64:Etienne Bergeron
c:\lipo\work\asan\b_llvm>c:\lipo\work\asan\b_llvm\projects\compiler-rt\test\asan\X86_64WindowsConfig\TestCases\Output\null_deref.cc.tmp ================================================================= ==5488==ERROR: AddressSanitizer: access-violation on unknown address 0x000000000028 (pc 0x7ff701f91067 bp 0x000c8cf8fbf0 sp 0x000c8cf8fbb0 T0) ==5488==The signal is caused by a READ memory access. ==5488==Hint: address points to the zero page. #0 0x7ff701f91066 in NullDeref(int *) C:\lipo\work\asan\llvm\projects\compiler-rt\test\asan\TestCases\null_deref.cc:15:10 #1 0x8a0388830a67 (<unknown module>) The reason was symbols was not initilized. In fact, it was first inited with a call to stack.Print(), which calls WinSymbolizerTool::SymbolizePC, then InitializeDbgHelpIfNeeded(). Since the StackWalk was performed before the stack.Print(), stack frames where not gathered correctly. There should be a better place to initialize symbols. For now, this patch makes the test happy. Patch by Wei Wang Differential Revision: https://reviews.llvm.org/D22410 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275580 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-12[sanitizer] Fix a crash when demangling Swift symbols, take 2Kuba Brecka
To invoke the Swift demangler, we use dlsym to locate swift_demangle. However, dlsym malloc's storage and stores it in thread-local storage. Since allocations from the symbolizer are done with the system allocator (at least in TSan, interceptors are skipped when inside the symbolizer), we will crash when we try to deallocate later using the sanitizer allocator again. To fix this, let's just not call dlsym from the demangler, and call it during initialization. The dlsym function calls malloc, so it needs to be only used after our allocator is initialized. Adding a Symbolizer::LateInitialize call that is only invoked after all other initializations. Differential Revision: http://reviews.llvm.org/D20015 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@269291 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-01tsan: describe heap/data locations in GoDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@262343 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-16Introduce stats and stats_client libraries.Peter Collingbourne
This is part of a new statistics gathering feature for the sanitizers. See clang/docs/SanitizerStats.rst for further info and docs. Differential Revision: http://reviews.llvm.org/D16176 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@257972 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-15sanitizer_common: C++ify the IntrusiveList iterator interface.Peter Collingbourne
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@257858 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-11[Sanitizer] Merge POSIXSymbolizer and WinSymbolizerKuba Brecka
The two subclasses of Symbolizer now only define two virtual functions, PlatformDemangle and PlatformPrepareForSandboxing. Let's make these non-virtual and directly defined by individual platforms. Reviewed at http://reviews.llvm.org/D8912 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234690 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-09[Sanitizer] Get rid of PlatformGetListOfModulesKuba Brecka
Moving the implementation of several functions from sanitizer_symbolizer.cc into sanitizer_symbolizer_libcdep.cc. Reviewed at http://reviews.llvm.org/D8858 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234472 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
2015-03-31[Sanitizer RT] Put the Symbolizer module name string ownership in orderTimur Iskhodzhanov
Reviewed at http://reviews.llvm.org/D8666 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@233687 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-17Improve SUMMARY reporting in sanitizers.Alexey Samsonov
Make sure SUMMARY is always reported unless print_summary flag is set to false, even if symbolizer is unavailable or report stack trace is empty. If file/line info for PC can't be evaluated, print module name/offset like we do in stack trace. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@232567 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-09Symbolizer refactoring: Merge common parts of POSIXSymbolizer and WinSymbolizerKuba Brecka
Reviewed at http://reviews.llvm.org/D8105 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@231680 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-04[sanitizer] when dumping coverage bitset, dump seperate file for every ↵Kostya Serebryany
module, instead of dumping a single combined bitset git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@231319 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-03Symbolizer refactoring: Turn FillAddressAndModuleInfo into FillModuleInfoKuba Brecka
Reviewed at http://reviews.llvm.org/D8020 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@231061 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-02Symbolizer refactoring: Move internals to separate filesKuba Brecka
Reviewed at http://reviews.llvm.org/D7972 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@231014 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-28Symbolizer refactoring: SymbolizerTool and better interfaceKuba Brecka
Reviewed at: http://reviews.llvm.org/D7936 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@230842 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-27[compiler-rt] Symbolizer refactoring: Abstract SymbolizerProcess betterKuba Brecka
Reviewed at http://reviews.llvm.org/D7889 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@230749 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-25[compiler-rt] Symbolizer refactoring: Move SymbolizerProcess interface to headerKuba Brecka
Reviewed at http://reviews.llvm.org/D7868 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@230530 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-02Simplify Symbolizer::SymbolizePC() interface.Alexey Samsonov
Return a linked list of AddressInfo objects, instead of using an array of these objects as an output parameter. This simplifies the code in callers of this function (especially TSan). Fix a few memory leaks from internal allocator, when the returned AddressInfo objects were not properly cleared. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@223145 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-04Correct the usage of DataInfo structure in TSanAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@221297 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-10[Sanitizer] Get rid of Symbolizer::Get() and Symbolizer::GetOrNull().Alexey Samsonov
We may as well just use Symbolizer::GetOrInit() in all the cases. Don't call Symbolizer::Get() early in tools initialization: these days it doesn't do any important setup work, and we may as well create the symbolizer the first time it's actually needed. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@217558 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-26[Sanitizer] Simplify Symbolizer creation interface.Alexey Samsonov
Get rid of Symbolizer::Init(path_to_external) in favor of thread-safe Symbolizer::GetOrInit(), and use the latter version everywhere. Implicitly depend on the value of external_symbolizer_path runtime flag instead of passing it around manually. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@214005 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-25[Sanitizer] Add Symbolizer::GetModuleNameAndOffsetForPC() and use it in LSan ↵Alexey Samsonov
suppression matching. This allows us to avoid retrieving file/line info for suppressed modules. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@198025 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-25[Sanitizer] Replace Symbolizer::IsAvailable and ↵Alexey Samsonov
Symbolizer::IsExternalAvailable with Symbolizer::CanReturnFileLineInfo. Remove now redundant checks in symbolizer initialization in TSan and MSan. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@198000 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-18[Sanitizer] Implement Symbolizer class on WindowsTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@197571 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-18[Sanitizers] Rename Symbolizer::SymbolizeCode to Symbolizer::SymbolizePCTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@197569 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-17[Sanitizer] Always initialize a Symbolizer (even if 'symbolize' is false).Alexey Samsonov
If 'symbolize' flag is not set, we still want to transform virtual address to module+offset pair in the call to Symbolizer::SymbolizeCode(). See https://code.google.com/p/address-sanitizer/issues/detail?id=251 for more details. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@197491 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-31[Sanitizer] Add Symbolizer::AddHooks() and use it in TSan and MSan.Alexey Samsonov
Summary: TSan and MSan need to know if interceptor was called by the user code or by the symbolizer and use pre- and post-symbolization hooks for that. Make Symbolizer class responsible for calling these hooks instead. This would ensure the hooks are only called when necessary (during in-process symbolization, they are not needed for out-of-process) and save specific sanitizers from tracing all places in the code where symbolization will be performed. Reviewers: eugenis, dvyukov Reviewed By: eugenis CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2067 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@193807 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-30[Sanitizer] Update comment in sanitizer_symbolizer.hAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@193700 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-30[Sanitizer] Use SpinMutex for Symbolizer initialization (per dvyukov's ↵Alexey Samsonov
suggestion) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@193697 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-25Overhaul the symbolizer interface.Peter Collingbourne
This moves away from creating the symbolizer object and initializing the external symbolizer as separate steps. Those steps now always take place together. Sanitizers with a legacy requirement to specify their own symbolizer path should use InitSymbolizer to initialize the symbolizer with the desired path, and GetSymbolizer to access the symbolizer. Sanitizers with no such requirement (e.g. UBSan) can use GetOrInitSymbolizer with no need for initialization. The symbolizer interface has been made thread-safe (as far as I can tell) by protecting its member functions with mutexes. Finally, the symbolizer interface no longer relies on weak externals, the introduction of which was probably a mistake on my part. Differential Revision: http://llvm-reviews.chandlerc.com/D1985 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@193448 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-11Revert r190520 as it wasn't the right fix.Daniel Jasper
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@190524 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-11Add empty virtual destructor...Daniel Jasper
... as this otherwise triggers -Wnon-virtual-dtor. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@190520 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-10[Sanitizer] Refactor symbolization interface: use class instead of several ↵Alexey Samsonov
functions. Move some code around to get rid of extra source files git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@190410 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-03ASan, LSan, MSan: try to find llvm-symbolizer binary in PATH if it is not ↵Alexey Samsonov
provided. Now we don't need to explicitly set the location of llvm-symbolizer in lit test configs. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@189801 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-13Define SANITIZER_INTERFACE_ATTRIBUTE on Windows and fix all the places where ↵Timur Iskhodzhanov
SANITIZER_INTERFACE_ATTRIBUTE or SANITIZER_ATTRIBUTE_WEAK are used git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@188261 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-28Demangle names using pluggable internal symbolizer if possibleAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@185146 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-11[Sanitizer] support running external llvm-symbolizer on MacAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@183730 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-29[nolibc] Unweak SymbolizerPrepareForSandboxing and move it to ↵Peter Collingbourne
libc-independent part. Fixes the Go build. Differential Revision: http://llvm-reviews.chandlerc.com/D877 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@182851 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-28[nolibc] Make SymbolizerPrepareForSandboxing weak and optional.Peter Collingbourne
Differential Revision: http://llvm-reviews.chandlerc.com/D872 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@182765 91177308-0d34-0410-b5e6-96231b3b80d8