From eab8552ac0494ca232fd0ba9747b88f30e9a1e48 Mon Sep 17 00:00:00 2001 From: Vedant Kumar Date: Tue, 5 Sep 2017 22:04:00 +0000 Subject: [PATCH] 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 --- include/llvm/Object/Decompressor.h | 8 +------- lib/Object/Decompressor.cpp | 14 +++----------- ...arfdump-decompression-invalid-size.elf-x86-64 | Bin 6853 -> 0 bytes .../dwarfdump-decompression-invalid-size.test | 15 --------------- 4 files changed, 4 insertions(+), 33 deletions(-) delete mode 100644 test/DebugInfo/Inputs/dwarfdump-decompression-invalid-size.elf-x86-64 delete mode 100644 test/DebugInfo/dwarfdump-decompression-invalid-size.test 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 7e6efcf1f5b0b22b9f0159590e772435d6b387ce..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6853 zcmcIpZEREL6+X5TCxu{K5=x+v@LHmUmRu4-X#3m zmw1|{?MU~Y_nh}U=RNQDx%ML)!>vw-1B9G#7m(yD(Ur=20}OkV$hu}I2OUI&aKY_B97EXRKVz$tiOzLvS0`ij$wX>kuzs+4UH!VXS~jh%QSs9-P!~6C z>rf75JbX$j{vynxIjU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/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.