kuhnel marked an inline comment as done.
kuhnel added inline comments.

================
Comment at: clang-tools-extra/clangd/unittests/StdLibIndexTests.cpp:51
+  Req.AnyScope = true;
+  EXPECT_THAT(match(*Index, Req),
+              UnorderedElementsAre(llvm::StringRef("myfunc"),
----------------
nridge wrote:
> kuhnel wrote:
> > @sammccall I seem to be running into a use-after-free problem here. 
> > Debugging the whole thing shows that `Index` is pointing to an invalid 
> > address. So the problem is somewhere between returning the `unique_ptr` 
> > from `indexUmbrellaHeaders(...)` and assigning it to the `Index` variable.
> > 
> > Can you please take a look and give me a hint how to fix this?
> I think your issue may be that `Dex` doesn't actually take ownership of the 
> slabs that get passed to it; the slabs [need to outlive 
> it](https://searchfox.org/llvm/rev/cab7c52acdf508f73186dfe49b8cb012bb9129b2/clang-tools-extra/clangd/index/dex/Dex.h#39).
> 
> `Dex` has another constructor which allows it to also take ownership, and a 
> [Dex::build()](https://searchfox.org/llvm/rev/cab7c52acdf508f73186dfe49b8cb012bb9129b2/clang-tools-extra/clangd/index/dex/Dex.cpp#26)
>  helper function to call it -- you probably want to be using that.
Awesome, thx @nridge ! That fixed the use-after-free!
I was searching in the wrong place the whole time...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105177

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to