diff options
author | Francis Ricci <francisjricci@gmail.com> | 2017-09-28 19:37:17 +0000 |
---|---|---|
committer | Francis Ricci <francisjricci@gmail.com> | 2017-09-28 19:37:17 +0000 |
commit | c76c49014f5b65f316833358d89d6c8c8325a900 (patch) | |
tree | af3ee202e9fb95c0aeaa24192881a0f97afe0e35 /lib | |
parent | 35bf445122908c454897722b57a81ba320ed915e (diff) | |
download | compiler-rt-c76c49014f5b65f316833358d89d6c8c8325a900.tar.gz |
Revert "Add support for custom loaders to the sanitizer symbolizer"
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sanitizer_common/sanitizer_common.h | 10 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_linux_libcdep.cc | 39 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_mac.cc | 4 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_procmaps.h | 2 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_procmaps_common.cc | 2 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_procmaps_mac.cc | 2 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_symbolizer.h | 2 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc | 46 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_win.cc | 6 |
9 files changed, 33 insertions, 80 deletions
diff --git a/lib/sanitizer_common/sanitizer_common.h b/lib/sanitizer_common/sanitizer_common.h index ee5eca516..47b02b149 100644 --- a/lib/sanitizer_common/sanitizer_common.h +++ b/lib/sanitizer_common/sanitizer_common.h @@ -727,10 +727,9 @@ class LoadedModule { // filling this information. class ListOfModules { public: - ListOfModules() : initialized(false) {} + ListOfModules() : modules_(kInitialCapacity) {} ~ListOfModules() { clear(); } void init(); - void fallbackInit(); // Uses fallback init if available, otherwise clears const LoadedModule *begin() const { return modules_.begin(); } LoadedModule *begin() { return modules_.begin(); } const LoadedModule *end() const { return modules_.end(); } @@ -746,15 +745,10 @@ class ListOfModules { for (auto &module : modules_) module.clear(); modules_.clear(); } - void clearOrInit() { - initialized ? clear() : modules_.Initialize(kInitialCapacity); - initialized = true; - } - InternalMmapVectorNoCtor<LoadedModule> modules_; + InternalMmapVector<LoadedModule> modules_; // We rarely have more than 16K loaded modules. static const uptr kInitialCapacity = 1 << 14; - bool initialized; }; // Callback type for iterating over a set of memory ranges. diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc index f28d3e86b..11d8b3ac0 100644 --- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc +++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc @@ -26,7 +26,6 @@ #include "sanitizer_placement_new.h" #include "sanitizer_procmaps.h" #include "sanitizer_stacktrace.h" -#include "sanitizer_symbolizer.h" #include <dlfcn.h> // for dlsym() #include <link.h> @@ -425,7 +424,7 @@ typedef ElfW(Phdr) Elf_Phdr; # endif struct DlIteratePhdrData { - InternalMmapVectorNoCtor<LoadedModule> *modules; + InternalMmapVector<LoadedModule> *modules; bool first; }; @@ -463,37 +462,21 @@ extern "C" __attribute__((weak)) int dl_iterate_phdr( int (*)(struct dl_phdr_info *, size_t, void *), void *); #endif -static bool requiresProcmaps() { +void ListOfModules::init() { + clear(); #if SANITIZER_ANDROID && __ANDROID_API__ <= 22 + u32 api_level = AndroidGetApiLevel(); // Fall back to /proc/maps if dl_iterate_phdr is unavailable or broken. // The runtime check allows the same library to work with // both K and L (and future) Android releases. - return AndroidGetApiLevel() <= ANDROID_LOLLIPOP_MR1; -#else - return false; -#endif -} - -static void procmapsInit(InternalMmapVectorNoCtor<LoadedModule> *modules) { - MemoryMappingLayout memory_mapping(false); - memory_mapping.DumpListOfModules(modules); -} - -void ListOfModules::init() { - clearOrInit(); - if (requiresProcmaps()) { - procmapsInit(&modules_); - } else { - DlIteratePhdrData data = {&modules_, true}; - dl_iterate_phdr(dl_iterate_phdr_cb, &data); + if (api_level <= ANDROID_LOLLIPOP_MR1) { // L or earlier + MemoryMappingLayout memory_mapping(false); + memory_mapping.DumpListOfModules(&modules_); + return; } -} - -// When a custom loader is used, dl_iterate_phdr may not contain the full -// list of modules. Allow callers to fall back to using procmaps. -void ListOfModules::fallbackInit() { - clearOrInit(); - if (!requiresProcmaps()) procmapsInit(&modules_); +#endif + DlIteratePhdrData data = {&modules_, true}; + dl_iterate_phdr(dl_iterate_phdr_cb, &data); } // getrusage does not give us the current RSS, only the max RSS. diff --git a/lib/sanitizer_common/sanitizer_mac.cc b/lib/sanitizer_common/sanitizer_mac.cc index 9fead91b9..1570ae277 100644 --- a/lib/sanitizer_common/sanitizer_mac.cc +++ b/lib/sanitizer_common/sanitizer_mac.cc @@ -411,13 +411,11 @@ void GetThreadStackAndTls(bool main, uptr *stk_addr, uptr *stk_size, } void ListOfModules::init() { - clearOrInit(); + clear(); MemoryMappingLayout memory_mapping(false); memory_mapping.DumpListOfModules(&modules_); } -void ListOfModules::fallbackInit() { clear(); } - static HandleSignalMode GetHandleSignalModeImpl(int signum) { switch (signum) { case SIGABRT: diff --git a/lib/sanitizer_common/sanitizer_procmaps.h b/lib/sanitizer_common/sanitizer_procmaps.h index d462ad841..96d0b2f9d 100644 --- a/lib/sanitizer_common/sanitizer_procmaps.h +++ b/lib/sanitizer_common/sanitizer_procmaps.h @@ -76,7 +76,7 @@ class MemoryMappingLayout { static void CacheMemoryMappings(); // Adds all mapped objects into a vector. - void DumpListOfModules(InternalMmapVectorNoCtor<LoadedModule> *modules); + void DumpListOfModules(InternalMmapVector<LoadedModule> *modules); private: void LoadFromCache(); diff --git a/lib/sanitizer_common/sanitizer_procmaps_common.cc b/lib/sanitizer_common/sanitizer_procmaps_common.cc index b9298d4cc..30663e8c6 100644 --- a/lib/sanitizer_common/sanitizer_procmaps_common.cc +++ b/lib/sanitizer_common/sanitizer_procmaps_common.cc @@ -120,7 +120,7 @@ void MemoryMappingLayout::LoadFromCache() { } void MemoryMappingLayout::DumpListOfModules( - InternalMmapVectorNoCtor<LoadedModule> *modules) { + InternalMmapVector<LoadedModule> *modules) { Reset(); InternalScopedString module_name(kMaxPathLength); MemoryMappedSegment segment(module_name.data(), module_name.size()); diff --git a/lib/sanitizer_common/sanitizer_procmaps_mac.cc b/lib/sanitizer_common/sanitizer_procmaps_mac.cc index 3b98ff095..786876f04 100644 --- a/lib/sanitizer_common/sanitizer_procmaps_mac.cc +++ b/lib/sanitizer_common/sanitizer_procmaps_mac.cc @@ -353,7 +353,7 @@ bool MemoryMappingLayout::Next(MemoryMappedSegment *segment) { } void MemoryMappingLayout::DumpListOfModules( - InternalMmapVectorNoCtor<LoadedModule> *modules) { + InternalMmapVector<LoadedModule> *modules) { Reset(); InternalScopedString module_name(kMaxPathLength); MemoryMappedSegment segment(module_name.data(), kMaxPathLength); diff --git a/lib/sanitizer_common/sanitizer_symbolizer.h b/lib/sanitizer_common/sanitizer_symbolizer.h index 208362d2f..543e27e39 100644 --- a/lib/sanitizer_common/sanitizer_symbolizer.h +++ b/lib/sanitizer_common/sanitizer_symbolizer.h @@ -119,7 +119,6 @@ class Symbolizer final { void AddHooks(StartSymbolizationHook start_hook, EndSymbolizationHook end_hook); - void RefreshModules(); const LoadedModule *FindModuleForAddress(uptr address); void InvalidateModuleList(); @@ -152,7 +151,6 @@ class Symbolizer final { uptr *module_offset, ModuleArch *module_arch); ListOfModules modules_; - ListOfModules fallback_modules_; // If stale, need to reload the modules before looking up addresses. bool modules_fresh_; diff --git a/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc b/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc index 8f968e78a..caab4ca35 100644 --- a/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc +++ b/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc @@ -163,47 +163,29 @@ bool Symbolizer::FindModuleNameAndOffsetForAddress(uptr address, return true; } -void Symbolizer::RefreshModules() { - modules_.init(); - fallback_modules_.fallbackInit(); - RAW_CHECK(modules_.size() > 0); - modules_fresh_ = true; -} - -static const LoadedModule *SearchForModule(const ListOfModules &modules, - uptr address) { - for (uptr i = 0; i < modules.size(); i++) { - if (modules[i].containsAddress(address)) { - return &modules[i]; - } - } - return nullptr; -} - const LoadedModule *Symbolizer::FindModuleForAddress(uptr address) { bool modules_were_reloaded = false; if (!modules_fresh_) { - RefreshModules(); + modules_.init(); + RAW_CHECK(modules_.size() > 0); + modules_fresh_ = true; modules_were_reloaded = true; } - const LoadedModule *module = SearchForModule(modules_, address); - if (module) return module; - - // dlopen/dlclose interceptors invalidate the module list, but when - // interception is disabled, we need to retry if the lookup fails in - // case the module list changed. + for (uptr i = 0; i < modules_.size(); i++) { + if (modules_[i].containsAddress(address)) { + return &modules_[i]; + } + } + // dlopen/dlclose interceptors invalidate the module list, but when + // interception is disabled, we need to retry if the lookup fails in + // case the module list changed. #if !SANITIZER_INTERCEPT_DLOPEN_DLCLOSE if (!modules_were_reloaded) { - RefreshModules(); - module = SearchForModule(modules_, address); - if (module) return module; + modules_fresh_ = false; + return FindModuleForAddress(address); } #endif - - if (fallback_modules_.size()) { - module = SearchForModule(fallback_modules_, address); - } - return module; + return 0; } // For now we assume the following protocol: diff --git a/lib/sanitizer_common/sanitizer_win.cc b/lib/sanitizer_common/sanitizer_win.cc index f1a74d3f2..a144db28c 100644 --- a/lib/sanitizer_common/sanitizer_win.cc +++ b/lib/sanitizer_common/sanitizer_win.cc @@ -524,7 +524,7 @@ static uptr GetPreferredBase(const char *modname) { } void ListOfModules::init() { - clearOrInit(); + clear(); HANDLE cur_process = GetCurrentProcess(); // Query the list of modules. Start by assuming there are no more than 256 @@ -583,9 +583,7 @@ void ListOfModules::init() { modules_.push_back(cur_module); } UnmapOrDie(hmodules, modules_buffer_size); -} - -void ListOfModules::fallbackInit() { clear(); } +}; // We can't use atexit() directly at __asan_init time as the CRT is not fully // initialized at this point. Place the functions into a vector and use |