[PATCH] D15638: [symbolizer] Fix a dangling pointer in LLVMSymbolizer::getOrCreateObjects

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 18 05:01:02 PST 2015


kubabrecka created this revision.
kubabrecka added a reviewer: samsonov.
kubabrecka added subscribers: llvm-commits, zaks.anna.

LLVMSymbolizer in getOrCreateObjects() takes ownership of the Binary object it creates, so it's not deallocated early (we're storing pointers to Binary objects in ObjectFileForArch).  However, when `getObjectFileFromBinary` fails (e.g. when the specified architecture is not found), we currently fail to take ownership of Binary.  Instead we end up deallocating the object too early and storing a dangling pointer in ObjectFileForArch.  This fix calls `addOwningBinary` even when an error is returned from getObjectFileFromBinary.

http://reviews.llvm.org/D15638

Files:
  lib/DebugInfo/Symbolize/Symbolize.cpp

Index: lib/DebugInfo/Symbolize/Symbolize.cpp
===================================================================
--- lib/DebugInfo/Symbolize/Symbolize.cpp
+++ lib/DebugInfo/Symbolize/Symbolize.cpp
@@ -285,6 +285,7 @@
   if (auto EC = ObjOrErr.getError()) {
     ObjectPairForPathArch.insert(
         std::make_pair(std::make_pair(Path, ArchName), EC));
+    addOwningBinary(std::move(B));
     return EC;
   }
   addOwningBinary(std::move(B));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15638.43219.patch
Type: text/x-patch
Size: 445 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151218/fd6efee6/attachment.bin>


More information about the llvm-commits mailing list