Fix ASAN buildbots by fixing a double free crash.
authorGreg Clayton <gclayton@apple.com>
Thu, 8 Dec 2016 16:57:04 +0000 (16:57 +0000)
committerGreg Clayton <gclayton@apple.com>
Thu, 8 Dec 2016 16:57:04 +0000 (16:57 +0000)
The dwarfgen::Generator::StringPool was in a unique_ptr but it was owned by the Allocator member variable so it was being free twice.

llvm-svn: 289070

llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
llvm/unittests/DebugInfo/DWARF/DwarfGenerator.h

index 06fa121..0503987 100644 (file)
@@ -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<std::unique_ptr<dwarfgen::Generator>>
@@ -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();
 }
index 185bbec..f3d2413 100644 (file)
@@ -170,7 +170,7 @@ class Generator {
   MCStreamer *MS;     // Owned by AsmPrinter
   std::unique_ptr<TargetMachine> TM;
   std::unique_ptr<AsmPrinter> Asm;
-  std::unique_ptr<DwarfStringPool> StringPool;
+  DwarfStringPool *StringPool; // Owned by Allocator
   std::vector<std::unique_ptr<CompileUnit>> CompileUnits;
   BumpPtrAllocator Allocator;
   DIEAbbrevSet Abbreviations;