nemanjai created this revision. nemanjai added a reviewer: rsmith. Herald added a subscriber: jdoerfert. Herald added a project: clang.
When the `Preprocessor (PP)` in compiler instance is going away, we should clear the cache of any pointers that it owns as they will be destroyed. This is one possible fix for the issue I outlined in http://lists.llvm.org/pipermail/cfe-dev/2019-February/061293.html that received no responses. We have now encountered the issue in multiple internal buildbots and I have even seen it in external bots as well. This really should be fixed. As outlined in my cfe-dev post, it is exceedingly difficult to produce a reliable test case for this (at least for me) so I have not provided one. If others should be on the list of reviewers, please add them. Repository: rC Clang https://reviews.llvm.org/D58497 Files: lib/Frontend/CompilerInstance.cpp Index: lib/Frontend/CompilerInstance.cpp =================================================================== --- lib/Frontend/CompilerInstance.cpp +++ lib/Frontend/CompilerInstance.cpp @@ -374,7 +374,14 @@ // The module manager holds a reference to the old preprocessor (if any). ModuleManager.reset(); - // Create the Preprocessor. + // Create the Preprocessor. If this instance is replacing the existing + // preprocessor and that existing one is going away, we have to remove + // the Module* pointers it owns from KnownModules since they will be + // dangling. FIXME: Should this only remove pointers owned by the + // preprocessor that is going away or clear the entire map (or can + // the map even own any other Module* pointers)? + if (PP.unique()) + KnownModules.clear(); HeaderSearch *HeaderInfo = new HeaderSearch(getHeaderSearchOptsPtr(), getSourceManager(), getDiagnostics(), getLangOpts(), &getTarget());
Index: lib/Frontend/CompilerInstance.cpp =================================================================== --- lib/Frontend/CompilerInstance.cpp +++ lib/Frontend/CompilerInstance.cpp @@ -374,7 +374,14 @@ // The module manager holds a reference to the old preprocessor (if any). ModuleManager.reset(); - // Create the Preprocessor. + // Create the Preprocessor. If this instance is replacing the existing + // preprocessor and that existing one is going away, we have to remove + // the Module* pointers it owns from KnownModules since they will be + // dangling. FIXME: Should this only remove pointers owned by the + // preprocessor that is going away or clear the entire map (or can + // the map even own any other Module* pointers)? + if (PP.unique()) + KnownModules.clear(); HeaderSearch *HeaderInfo = new HeaderSearch(getHeaderSearchOptsPtr(), getSourceManager(), getDiagnostics(), getLangOpts(), &getTarget());
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits