[lld] r313741 - [ELF] - Fix segfault when processing .eh_frame.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 20 02:27:41 PDT 2017


Author: grimar
Date: Wed Sep 20 02:27:41 2017
New Revision: 313741

URL: http://llvm.org/viewvc/llvm-project?rev=313741&view=rev
Log:
[ELF] - Fix segfault when processing .eh_frame.

Its a PR34648 which was a segfault that happened because
we stored pointers to elements in DenseMap. 
When DenseMap grows such pointers are invalidated.
Solution implemented is to keep elements by pointer
and not by value.

Differential revision: https://reviews.llvm.org/D38034

Modified:
    lld/trunk/ELF/SyntheticSections.cpp
    lld/trunk/ELF/SyntheticSections.h

Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=313741&r1=313740&r2=313741&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Wed Sep 20 02:27:41 2017
@@ -417,10 +417,11 @@ CieRecord *EhFrameSection<ELFT>::addCie(
         &Sec->template getFile<ELFT>()->getRelocTargetSym(Rels[FirstRelI]);
 
   // Search for an existing CIE by CIE contents/relocation target pair.
-  CieRecord *Rec = &CieMap[{Cie.data(), Personality}];
+  CieRecord *&Rec = CieMap[{Cie.data(), Personality}];
 
   // If not found, create a new one.
-  if (Rec->Cie == nullptr) {
+  if (!Rec) {
+    Rec = make<CieRecord>();
     Rec->Cie = &Cie;
     CieRecords.push_back(Rec);
   }

Modified: lld/trunk/ELF/SyntheticSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.h?rev=313741&r1=313740&r2=313741&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.h (original)
+++ lld/trunk/ELF/SyntheticSections.h Wed Sep 20 02:27:41 2017
@@ -103,7 +103,8 @@ private:
   std::vector<CieRecord *> CieRecords;
 
   // CIE records are uniquified by their contents and personality functions.
-  llvm::DenseMap<std::pair<ArrayRef<uint8_t>, SymbolBody *>, CieRecord> CieMap;
+  llvm::DenseMap<std::pair<ArrayRef<uint8_t>, SymbolBody *>, CieRecord *>
+      CieMap;
 };
 
 class GotSection : public SyntheticSection {




More information about the llvm-commits mailing list