[PATCH] D159363: [clangd] SIGSEGV at clangd: DiagnosticConsumer Is Used After Free

Ivan Murashko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 1 10:49:23 PDT 2023


ivanmurashko added inline comments.


================
Comment at: clang-tools-extra/clangd/Preamble.cpp:709
       Ctx->setStatCache(Result->StatCache);
+      // We have to setup DiagnosticConsumer that will be alife
+      // while preamble callback is executed
----------------
sammccall wrote:
> I think this should go up next to PreambleDiagsEngine.reset() etc, as it's basically the same thing: we're trying to avoid any race between the async work done by the callback and the cleanup at the end of the function.
> 
> Also I think it's slightly clearer for us to consistently be taking the diagnostics from PreambleDiagnostics *after* it's detached from the compiler.
I applied the change


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159363/new/

https://reviews.llvm.org/D159363



More information about the cfe-commits mailing list