[PATCH] D155110: [memprof] Fix use-after-free in peekBuildIds.

Snehasish Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 12 14:21:41 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG787a5efb020f: [memprof] Fix use-after-free in peekBuildIds. (authored by snehasish).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155110/new/

https://reviews.llvm.org/D155110

Files:
  llvm/lib/ProfileData/RawMemProfReader.cpp


Index: llvm/lib/ProfileData/RawMemProfReader.cpp
===================================================================
--- llvm/lib/ProfileData/RawMemProfReader.cpp
+++ llvm/lib/ProfileData/RawMemProfReader.cpp
@@ -552,7 +552,7 @@
   // callback is the main program."
   // https://man7.org/linux/man-pages/man3/dl_iterate_phdr.3.html
   std::vector<std::string> BuildIds;
-  llvm::SmallSet<StringRef, 4> BuildIdsSet;
+  llvm::SmallSet<std::string, 10> BuildIdsSet;
   while (Next < DataBuffer->getBufferEnd()) {
     auto *Header = reinterpret_cast<const memprof::Header *>(Next);
 
@@ -564,7 +564,7 @@
       if (BuildIdsSet.contains(Id))
         continue;
       BuildIds.push_back(Id);
-      BuildIdsSet.insert(BuildIds.back());
+      BuildIdsSet.insert(Id);
     }
 
     Next += Header->TotalSize;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155110.539732.patch
Type: text/x-patch
Size: 805 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230712/19ef4711/attachment.bin>


More information about the llvm-commits mailing list