[PATCH] D38924: Fix `FaultMaps` crash when the out streamer is reused

Yichao Yu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 14 14:41:32 PDT 2017


yuyichao created this revision.
Herald added subscribers: kristof.beyls, aemerson.

Make sure the map is cleared before processing a new module. Similar to what is done on `StackMaps`.

This issue is similar to https://reviews.llvm.org/D38588, though this time for FaultMaps (on x86) rather than ARM/AArch64. Other than possible mixing of information between modules, the crash is caused by the pointers values in the map that was allocated by the bump pointer allocator that is unwinded when emitting the next file. This issue has been around since 3.8 though only the recent experience with https://reviews.llvm.org/D38588 helped me finding the fix....

This issue is likely much harder to write a test for since AFAICT it requires emitting something much more compilcated (and possibly real code) instead of just some random bytes....


https://reviews.llvm.org/D38924

Files:
  include/llvm/CodeGen/FaultMaps.h
  lib/Target/X86/X86AsmPrinter.h


Index: lib/Target/X86/X86AsmPrinter.h
===================================================================
--- lib/Target/X86/X86AsmPrinter.h
+++ lib/Target/X86/X86AsmPrinter.h
@@ -135,6 +135,7 @@
   bool doInitialization(Module &M) override {
     SMShadowTracker.reset(0);
     SM.reset();
+    FM.reset();
     return AsmPrinter::doInitialization(M);
   }
 
Index: include/llvm/CodeGen/FaultMaps.h
===================================================================
--- include/llvm/CodeGen/FaultMaps.h
+++ include/llvm/CodeGen/FaultMaps.h
@@ -39,6 +39,9 @@
 
   void recordFaultingOp(FaultKind FaultTy, const MCSymbol *HandlerLabel);
   void serializeToFaultMapSection();
+  void reset() {
+    FunctionInfos.clear();
+  }
 
 private:
   static const char *WFMP;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38924.119043.patch
Type: text/x-patch
Size: 766 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171014/28fb2b29/attachment.bin>


More information about the llvm-commits mailing list