-
Notifications
You must be signed in to change notification settings - Fork 10.5k
ClangImporter: Use a separate CompilerInstance for canReadPCH #28125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ClangImporter: Use a separate CompilerInstance for canReadPCH #28125
Conversation
@swift-ci please test |
@swift-ci please smoke-test |
@swift-ci smoke test |
Build failed |
6121bea
to
d06b335
Compare
@swift-ci smoke test |
@swift-ci please smoke test |
Build failed |
d06b335
to
930ee29
Compare
@swift-ci smoke-test |
@swift-ci smoke test |
@swift-ci please smoke test |
@swift-ci smoke test osx |
1 similar comment
@swift-ci smoke test osx |
@swift-ci please smoke-test osx |
@swift-ci smoke test osx |
@swift-ci smoke test |
@swift-ci smoke test osx |
@swift-ci test |
@swift-ci please test |
@swift-ci smoke test osx |
@swift-ci test osx |
Build failed |
930ee29
to
b45a599
Compare
@swift-ci test |
@swift-ci smoke test |
@swift-ci please smoke test |
@swift-ci please test |
@swift-ci smoke test osx |
Build failed |
Build failed |
@swift-ci test osx |
@swift-ci test |
Build failed |
Build failed |
@swift-ci test macOS |
b45a599
to
4fc9e97
Compare
@swift-ci smoke test |
@swift-ci please test |
@swift-ci please smoke test |
@brentdax @adrian-prantl, This is ready for review now. Let me know if you have any questions or concerns! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can tell, this looks safe to me.
ClangImporter::canReadPCH has been trying to reset the main CompilerInstance back to as if it hadn't run, but there's a long tail of potential memory corruption here. One example is that it's reusing HeaderSearch, but HeaderSearch contains a ModuleMap whose SourceLocations will point into the soon-to-be-released ASTContext on the stack. Instead, just use a separate CompilerInstnace, like the rest of the ClangImporter does when it needs a different ASTContext. This fixes a few potential memory corruption bugs, and it *may* be related to the persistent "missing submodule X" problems hitting Linux bots.
4fc9e97
to
178d209
Compare
@swift-ci smoke test |
@swift-ci smoke test linux |
I think this change makes sense. I'm a little concerned that it could end up performing more work and thus regressing performance, so I've created a revert PR so I can test its performance, but I don't plan to merge the revert. |
Thanks Brent! |
ClangImporter::canReadPCH has been trying to reset the main
CompilerInstance back to as if it hadn't run, but there's a long tail of
potential memory corruption here. One example is that it's reusing
HeaderSearch, but HeaderSearch contains a ModuleMap whose
SourceLocations will point into the soon-to-be-released ASTContext on
the stack. Instead, just use a separate CompilerInstnace, like the rest
of the ClangImporter does when it needs a different ASTContext.
This fixes a few potential memory corruption bugs, and it may be
related to the persistent "missing submodule X" problems hitting Linux
bots.
Note: assigning to myself while I run tests. I'll add reviewers when ready.