[llvm] r315990 - Fix `FaultMaps` crash when the out streamer is reused

Yichao Yu via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 17 04:44:34 PDT 2017


Author: yuyichao
Date: Tue Oct 17 04:44:34 2017
New Revision: 315990

URL: http://llvm.org/viewvc/llvm-project?rev=315990&view=rev
Log:
Fix `FaultMaps` crash when the out streamer is reused

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

This issue is similar to 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.

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.

Reviewers: skatkov, sanjoy

Reviewed By: skatkov, sanjoy

Subscribers: sanjoy, aemerson, llvm-commits, kristof.beyls

Differential Revision: https://reviews.llvm.org/D38924

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

Modified: llvm/trunk/include/llvm/CodeGen/FaultMaps.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/FaultMaps.h?rev=315990&r1=315989&r2=315990&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/FaultMaps.h (original)
+++ llvm/trunk/include/llvm/CodeGen/FaultMaps.h Tue Oct 17 04:44:34 2017
@@ -39,6 +39,9 @@ public:
 
   void recordFaultingOp(FaultKind FaultTy, const MCSymbol *HandlerLabel);
   void serializeToFaultMapSection();
+  void reset() {
+    FunctionInfos.clear();
+  }
 
 private:
   static const char *WFMP;

Modified: llvm/trunk/lib/Target/X86/X86AsmPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86AsmPrinter.h?rev=315990&r1=315989&r2=315990&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86AsmPrinter.h (original)
+++ llvm/trunk/lib/Target/X86/X86AsmPrinter.h Tue Oct 17 04:44:34 2017
@@ -135,6 +135,7 @@ public:
   bool doInitialization(Module &M) override {
     SMShadowTracker.reset(0);
     SM.reset();
+    FM.reset();
     return AsmPrinter::doInitialization(M);
   }
 




More information about the llvm-commits mailing list