[llvm] r289070 - Fix ASAN buildbots by fixing a double free crash.

Greg Clayton via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 8 08:57:05 PST 2016


Author: gclayton
Date: Thu Dec  8 10:57:04 2016
New Revision: 289070

URL: http://llvm.org/viewvc/llvm-project?rev=289070&view=rev
Log:
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.


Modified:
    llvm/trunk/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
    llvm/trunk/unittests/DebugInfo/DWARF/DwarfGenerator.h

Modified: llvm/trunk/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/DWARF/DwarfGenerator.cpp?rev=289070&r1=289069&r2=289070&view=diff
==============================================================================
--- llvm/trunk/unittests/DebugInfo/DWARF/DwarfGenerator.cpp (original)
+++ llvm/trunk/unittests/DebugInfo/DWARF/DwarfGenerator.cpp Thu Dec  8 10:57:04 2016
@@ -110,7 +110,9 @@ dwarfgen::DIE dwarfgen::CompileUnit::get
 /// 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(Tr
   MC->setDwarfVersion(Version);
   Asm->setDwarfVersion(Version);
 
-  StringPool.reset(new DwarfStringPool(Allocator, *Asm, StringRef()));
+  StringPool = new DwarfStringPool(Allocator, *Asm, StringRef());
 
   return Error::success();
 }

Modified: llvm/trunk/unittests/DebugInfo/DWARF/DwarfGenerator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/DWARF/DwarfGenerator.h?rev=289070&r1=289069&r2=289070&view=diff
==============================================================================
--- llvm/trunk/unittests/DebugInfo/DWARF/DwarfGenerator.h (original)
+++ llvm/trunk/unittests/DebugInfo/DWARF/DwarfGenerator.h Thu Dec  8 10:57:04 2016
@@ -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;




More information about the llvm-commits mailing list