From: Vedant Kumar Date: Tue, 5 Sep 2017 22:04:00 +0000 (+0000) Subject: Revert "[Decompression] Fail gracefully when out of memory" X-Git-Tag: android-x86-7.1-r4~11409 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=eab8552ac0494ca232fd0ba9747b88f30e9a1e48;p=android-x86%2Fexternal-llvm.git Revert "[Decompression] Fail gracefully when out of memory" This reverts commit r312526. Revert "Fix test/DebugInfo/dwarfdump-decompression-invalid-size.test" This reverts commit r312527. It causes an ASan failure: http://lab.llvm.org:8080/green/job/clang-stage2-cmake-RgSan_check/4150 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312582 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Object/Decompressor.h b/include/llvm/Object/Decompressor.h index 8fc5dc3e9bf..c8e888d285e 100644 --- a/include/llvm/Object/Decompressor.h +++ b/include/llvm/Object/Decompressor.h @@ -13,7 +13,6 @@ #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringRef.h" #include "llvm/Object/ObjectFile.h" -#include "llvm/Support/ErrorHandling.h" namespace llvm { namespace object { @@ -32,9 +31,7 @@ public: /// @brief Resize the buffer and uncompress section data into it. /// @param Out Destination buffer. template Error resizeAndDecompress(T &Out) { - install_bad_alloc_error_handler(outOfMemoryHandler, this); Out.resize(DecompressedSize); - remove_bad_alloc_error_handler(); return decompress({Out.data(), (size_t)DecompressedSize}); } @@ -55,14 +52,11 @@ public: static bool isGnuStyle(StringRef Name); private: - static void outOfMemoryHandler(void *Data, const std::string &Message, bool); - - Decompressor(StringRef Name, StringRef Data); + Decompressor(StringRef Data); Error consumeCompressedGnuHeader(); Error consumeCompressedZLibHeader(bool Is64Bit, bool IsLittleEndian); - StringRef SectionName; StringRef SectionData; uint64_t DecompressedSize; }; diff --git a/lib/Object/Decompressor.cpp b/lib/Object/Decompressor.cpp index 89821822484..53f084d7620 100644 --- a/lib/Object/Decompressor.cpp +++ b/lib/Object/Decompressor.cpp @@ -23,7 +23,7 @@ Expected Decompressor::create(StringRef Name, StringRef Data, if (!zlib::isAvailable()) return createError("zlib is not available"); - Decompressor D(Name, Data); + Decompressor D(Data); Error Err = isGnuStyle(Name) ? D.consumeCompressedGnuHeader() : D.consumeCompressedZLibHeader(Is64Bit, IsLE); if (Err) @@ -31,8 +31,8 @@ Expected Decompressor::create(StringRef Name, StringRef Data, return D; } -Decompressor::Decompressor(StringRef Name, StringRef Data) - : SectionName(Name), SectionData(Data), DecompressedSize(0) {} +Decompressor::Decompressor(StringRef Data) + : SectionData(Data), DecompressedSize(0) {} Error Decompressor::consumeCompressedGnuHeader() { if (!SectionData.startswith("ZLIB")) @@ -92,11 +92,3 @@ Error Decompressor::decompress(MutableArrayRef Buffer) { size_t Size = Buffer.size(); return zlib::uncompress(SectionData, Buffer.data(), Size); } - -void Decompressor::outOfMemoryHandler(void *Data, const std::string &Message, - bool) { - const auto *D = static_cast(Data); - report_fatal_error("decompression of '" + Twine(D->SectionName) + - "' failed: unable to allocate " + - Twine(D->DecompressedSize) + " bytes."); -} diff --git a/test/DebugInfo/Inputs/dwarfdump-decompression-invalid-size.elf-x86-64 b/test/DebugInfo/Inputs/dwarfdump-decompression-invalid-size.elf-x86-64 deleted file mode 100644 index 7e6efcf1f5b..00000000000 Binary files a/test/DebugInfo/Inputs/dwarfdump-decompression-invalid-size.elf-x86-64 and /dev/null differ diff --git a/test/DebugInfo/dwarfdump-decompression-invalid-size.test b/test/DebugInfo/dwarfdump-decompression-invalid-size.test deleted file mode 100644 index 32e9d2e63b3..00000000000 --- a/test/DebugInfo/dwarfdump-decompression-invalid-size.test +++ /dev/null @@ -1,15 +0,0 @@ -REQUIRES: zlib - -// dwarfdump-decompression-invalid-size.elf-x86-64 is prepared using following -// source code and invocation: -// test.cpp: -// int main() { return 0; } -// -// gcc test.cpp -o out -g -Wl,--compress-debug-sections,zlib -// -// After that result object was modified manually. Decompressed size of -// .debug_frame section was changed to 0xffffffffffffffff in compression -// header. -RUN: not llvm-dwarfdump %p/Inputs/dwarfdump-decompression-invalid-size.elf-x86-64 2>&1 | FileCheck %s - -CHECK: decompression of '.debug_frame' failed: unable to allocate 18446744073709551615 bytes.