From f500b96fb913882fc74166dceb8da6dadb6ed1d1 Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Tue, 17 Oct 2017 11:44:34 +0000 Subject: [PATCH] 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315990 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/FaultMaps.h | 3 +++ lib/Target/X86/X86AsmPrinter.h | 1 + 2 files changed, 4 insertions(+) diff --git a/include/llvm/CodeGen/FaultMaps.h b/include/llvm/CodeGen/FaultMaps.h index 98ff526dfe9..55e25c9823b 100644 --- a/include/llvm/CodeGen/FaultMaps.h +++ b/include/llvm/CodeGen/FaultMaps.h @@ -39,6 +39,9 @@ public: void recordFaultingOp(FaultKind FaultTy, const MCSymbol *HandlerLabel); void serializeToFaultMapSection(); + void reset() { + FunctionInfos.clear(); + } private: static const char *WFMP; diff --git a/lib/Target/X86/X86AsmPrinter.h b/lib/Target/X86/X86AsmPrinter.h index 7a40552ee38..c5c29b611cc 100644 --- a/lib/Target/X86/X86AsmPrinter.h +++ b/lib/Target/X86/X86AsmPrinter.h @@ -135,6 +135,7 @@ public: bool doInitialization(Module &M) override { SMShadowTracker.reset(0); SM.reset(); + FM.reset(); return AsmPrinter::doInitialization(M); } -- 2.50.1