diff options
author | Ben Langmuir <blangmuir@apple.com> | 2022-07-07 10:06:49 -0700 |
---|---|---|
committer | Ben Langmuir <blangmuir@apple.com> | 2022-07-07 10:23:57 -0700 |
commit | 67a84ec8105e590159b6303a1f0e3cb77c02b5fe (patch) | |
tree | d1aab33b375f607a8fcbba84c9f81dd7d26c6c4a /clang/lib/Frontend/FrontendAction.cpp | |
parent | ec48a0df9151a5192381e44bee6a48a08ed8932b (diff) | |
download | llvm-67a84ec8105e590159b6303a1f0e3cb77c02b5fe.zip llvm-67a84ec8105e590159b6303a1f0e3cb77c02b5fe.tar.gz llvm-67a84ec8105e590159b6303a1f0e3cb77c02b5fe.tar.bz2 |
[clang] Cleanup ASTContext before output files in crash recovery for modules
When we recover from a crash in a module compilation thread, we need to
ensure any output streams owned by the ASTConsumer (e.g. in
RawPCHContainerGenerator) are deleted before we call clearOutputFiles().
This has the same theoretical issues with proxy streams that Duncan
discusses in the commit 2d133867833fe8eb. In practice, this was observed
as a use-after-free crash on a downstream branch that uses such a proxy
stream in this code path. Add an assertion so it won't regress.
Differential Revision: https://reviews.llvm.org/D129220
rdar://96525032
Diffstat (limited to 'clang/lib/Frontend/FrontendAction.cpp')
-rw-r--r-- | clang/lib/Frontend/FrontendAction.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index 81915e63..ed3e314c 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -581,6 +581,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, auto FailureCleanup = llvm::make_scope_exit([&]() { if (HasBegunSourceFile) CI.getDiagnosticClient().EndSourceFile(); + CI.setASTConsumer(nullptr); CI.clearOutputFiles(/*EraseFiles=*/true); CI.getLangOpts().setCompilingModule(LangOptions::CMK_None); setCurrentInput(FrontendInputFile()); |