[Lldb-commits] [PATCH] D88266: Check that the "StructuredData Plugin weak pointer" is good before trying to turn it into a shared pointer

Jim Ingham via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Sep 29 10:49:19 PDT 2020


jingham added inline comments.


================
Comment at: lldb/include/lldb/Core/StructuredDataImpl.h:72-74
+    lldb::StructuredDataPluginSP plugin_sp;
+    if (!m_plugin_wp.expired())
+      plugin_sp = lldb::StructuredDataPluginSP(m_plugin_wp);
----------------
labath wrote:
> This is racy. The right way to do that is to call `m_plugin_wp.lock()` and then check the validity of the returned shared_ptr.
I tried that, but at least on the version of the STL on the latest macOS if the weak pointer has just been default initialized if you call lock on it it crashes.  expired was the only call I could make that didn't crash.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88266



More information about the lldb-commits mailing list