From 23e3fe93ac88f1b55229385df369aa04678ae342 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Thu, 8 Dec 2016 16:57:04 +0000 Subject: [PATCH] Fix ASAN buildbots by fixing a double free crash. The dwarfgen::Generator::StringPool was in a unique_ptr but it was owned by the Allocator member variable so it was being free twice. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289070 91177308-0d34-0410-b5e6-96231b3b80d8 --- unittests/DebugInfo/DWARF/DwarfGenerator.cpp | 6 ++++-- unittests/DebugInfo/DWARF/DwarfGenerator.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/unittests/DebugInfo/DWARF/DwarfGenerator.cpp b/unittests/DebugInfo/DWARF/DwarfGenerator.cpp index 06fa121e7a2..05039875729 100644 --- a/unittests/DebugInfo/DWARF/DwarfGenerator.cpp +++ b/unittests/DebugInfo/DWARF/DwarfGenerator.cpp @@ -110,7 +110,9 @@ dwarfgen::DIE dwarfgen::CompileUnit::getUnitDIE() { /// dwarfgen::Generator implementation. //===----------------------------------------------------------------------===// -dwarfgen::Generator::Generator() : Abbreviations(Allocator) {} +dwarfgen::Generator::Generator() + : MAB(nullptr), MCE(nullptr), MS(nullptr), StringPool(nullptr), + Abbreviations(Allocator) {} dwarfgen::Generator::~Generator() = default; llvm::Expected> @@ -201,7 +203,7 @@ llvm::Error dwarfgen::Generator::init(Triple TheTriple, uint16_t V) { MC->setDwarfVersion(Version); Asm->setDwarfVersion(Version); - StringPool.reset(new DwarfStringPool(Allocator, *Asm, StringRef())); + StringPool = new DwarfStringPool(Allocator, *Asm, StringRef()); return Error::success(); } diff --git a/unittests/DebugInfo/DWARF/DwarfGenerator.h b/unittests/DebugInfo/DWARF/DwarfGenerator.h index 185bbecb91d..f3d2413be04 100644 --- a/unittests/DebugInfo/DWARF/DwarfGenerator.h +++ b/unittests/DebugInfo/DWARF/DwarfGenerator.h @@ -170,7 +170,7 @@ class Generator { MCStreamer *MS; // Owned by AsmPrinter std::unique_ptr TM; std::unique_ptr Asm; - std::unique_ptr StringPool; + DwarfStringPool *StringPool; // Owned by Allocator std::vector> CompileUnits; BumpPtrAllocator Allocator; DIEAbbrevSet Abbreviations; -- 2.50.1