swift
fd992cc8 - [Dependency Scanner] Speculatively fix diagnostic consumer use-after-destroy in compiler sub-instances

Commit
248 days ago
[Dependency Scanner] Speculatively fix diagnostic consumer use-after-destroy in compiler sub-instances In `runInSubCompilerInstance`, the `CompilerInstance` was declared before its diagnostic consumers (`ForwardingDiagnosticConsumer` and `NullDiagnosticConsumer`). C++ destroys local variables in reverse declaration order, so the consumers were destroyed before `~CompilerInstance` ran. During `ASTContext` cleanup, any code emitting diagnostics would access the already-destroyed consumers via dangling pointers in the `DiagnosticEngine`, possibly causing undefined behavior that may manifest as heap corruption and a crash. Fix by declaring the diagnostic consumers before the CompilerInstance so they outlive it. Resolves rdar://172440435.
Author
Committer
Parents
Loading