This revision was automatically updated to reflect the committed changes. Closed by commit rGd03a7f15f019: [clangd] SIGSEGV at clangd: DiagnosticConsumer Is Used After Free (authored by ivanmurashko).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D159363/new/ https://reviews.llvm.org/D159363 Files: clang-tools-extra/clangd/Preamble.cpp Index: clang-tools-extra/clangd/Preamble.cpp =================================================================== --- clang-tools-extra/clangd/Preamble.cpp +++ clang-tools-extra/clangd/Preamble.cpp @@ -665,6 +665,10 @@ Stats ? TimedFS : StatCacheFS, std::make_shared<PCHContainerOperations>(), StoreInMemory, /*StoragePath=*/"", CapturedInfo); PreambleTimer.stopTimer(); + + // We have to setup DiagnosticConsumer that will be alife + // while preamble callback is executed + PreambleDiagsEngine->setClient(new IgnoringDiagConsumer, true); // Reset references to ref-counted-ptrs before executing the callbacks, to // prevent resetting them concurrently. PreambleDiagsEngine.reset(); @@ -706,6 +710,7 @@ // While extending the life of FileMgr and VFS, StatCache should also be // extended. Ctx->setStatCache(Result->StatCache); + PreambleCallback(std::move(*Ctx), Result->Pragmas); } return Result;
Index: clang-tools-extra/clangd/Preamble.cpp =================================================================== --- clang-tools-extra/clangd/Preamble.cpp +++ clang-tools-extra/clangd/Preamble.cpp @@ -665,6 +665,10 @@ Stats ? TimedFS : StatCacheFS, std::make_shared<PCHContainerOperations>(), StoreInMemory, /*StoragePath=*/"", CapturedInfo); PreambleTimer.stopTimer(); + + // We have to setup DiagnosticConsumer that will be alife + // while preamble callback is executed + PreambleDiagsEngine->setClient(new IgnoringDiagConsumer, true); // Reset references to ref-counted-ptrs before executing the callbacks, to // prevent resetting them concurrently. PreambleDiagsEngine.reset(); @@ -706,6 +710,7 @@ // While extending the life of FileMgr and VFS, StatCache should also be // extended. Ctx->setStatCache(Result->StatCache); + PreambleCallback(std::move(*Ctx), Result->Pragmas); } return Result;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits