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.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
Updated per out-of-band feedback from @steven_wu :
- Added an assert to clearOutputFiles that the ASTConsumer is removed. Normally this would be done in FrontendAction::EndSourceFile. This should help avoid regressions and also means it is covered by existing tests.
- Updated FailureCleanup in FrontendAction::BeginSourceFile to reset the ASTConsumer. This is needed due to the assertion, but I don't think it changes much in practice since there would also be no output files at this stage.