diff options
author | Ryan Savitski <rsavitski@google.com> | 2021-06-16 14:34:36 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2021-06-16 14:34:36 +0000 |
commit | d03d88dc970cf5414ebeeeb7e2d1266d9dd81a87 (patch) | |
tree | 26144977e01ba500e236f244ca05cf368084a2c7 | |
parent | a0335bcea598e28856a03fcf3cc27d36c49df79b (diff) | |
parent | c868a4f1162a305b0804cee9169f6d9376d12c95 (diff) | |
download | unwinding-d03d88dc970cf5414ebeeeb7e2d1266d9dd81a87.tar.gz |
Merge "Avoid pathologically high memory use for DEX files." into sc-dev
-rw-r--r-- | libunwindstack/DexFile.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/libunwindstack/DexFile.cpp b/libunwindstack/DexFile.cpp index c3e53c7..e576354 100644 --- a/libunwindstack/DexFile.cpp +++ b/libunwindstack/DexFile.cpp @@ -89,6 +89,21 @@ std::shared_ptr<DexFile> DexFile::Create(uint64_t base_addr, uint64_t file_size, if (!has_dex_support || file_size == 0) { return nullptr; } + + // Do not try to open the DEX file if the file name ends with "(deleted)". It does not exist. + // This happens when an app is background-optimized by ART and all of its files are replaced. + // Furthermore, do NOT try to fallback to in-memory copy. It would work, but all apps tend to + // be background-optimized at the same time, so it would lead to excessive memory use during + // system-wide profiling (essentially copying all dex files for all apps: hundreds of MBs). + // This will cause missing symbols in the backtrace, however, that outcome is inevitable + // anyway, since we can not obtain mini-debug-info for the deleted .oat files. + const std::string_view filename(info != nullptr ? info->name() : ""); + const std::string_view kDeleted("(deleted)"); + if (filename.size() >= kDeleted.size() && + filename.substr(filename.size() - kDeleted.size()) == kDeleted) { + return nullptr; + } + std::shared_ptr<DexFile> dex_file = CreateFromDisk(base_addr, file_size, info); if (dex_file != nullptr) { return dex_file; |