[lld] r314860 - Merging r313741:

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 3 16:42:47 PDT 2017


Author: ruiu
Date: Tue Oct  3 16:42:47 2017
New Revision: 314860

URL: http://llvm.org/viewvc/llvm-project?rev=314860&view=rev
Log:
Merging r313741:
------------------------------------------------------------------------
r313741 | grimar | 2017-09-20 02:27:41 -0700 (Wed, 20 Sep 2017) | 9 lines

[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/branches/release_50/   (props changed)
    lld/branches/release_50/ELF/SyntheticSections.cpp
    lld/branches/release_50/ELF/SyntheticSections.h

Propchange: lld/branches/release_50/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Oct  3 16:42:47 2017
@@ -1 +1 @@
-/lld/trunk:308492,308728,308935,308998,309002,310526,310989,310992
+/lld/trunk:308492,308728,308935,308998,309002,310526,310989,310992,313741

Modified: lld/branches/release_50/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_50/ELF/SyntheticSections.cpp?rev=314860&r1=314859&r2=314860&view=diff
==============================================================================
--- lld/branches/release_50/ELF/SyntheticSections.cpp (original)
+++ lld/branches/release_50/ELF/SyntheticSections.cpp Tue Oct  3 16:42:47 2017
@@ -427,10 +427,11 @@ CieRecord *EhFrameSection<ELFT>::addCie(
         &Sec->template getFile<ELFT>()->getRelocTargetSym(Rels[FirstRelI]);
 
   // Search for an existing CIE by CIE contents/relocation target pair.
-  CieRecord *Cie = &CieMap[{Piece.data(), Personality}];
+  CieRecord *&Cie = CieMap[{Piece.data(), Personality}];
 
   // If not found, create a new one.
-  if (Cie->Piece == nullptr) {
+  if (!Cie) {
+    Cie = make<CieRecord>();
     Cie->Piece = &Piece;
     Cies.push_back(Cie);
   }

Modified: lld/branches/release_50/ELF/SyntheticSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_50/ELF/SyntheticSections.h?rev=314860&r1=314859&r2=314860&view=diff
==============================================================================
--- lld/branches/release_50/ELF/SyntheticSections.h (original)
+++ lld/branches/release_50/ELF/SyntheticSections.h Tue Oct  3 16:42:47 2017
@@ -103,7 +103,8 @@ private:
   std::vector<CieRecord *> Cies;
 
   // 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