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

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 1 08:56:15 PDT 2023


sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Nice catch!



================
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
----------------
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.


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