================ @@ -2564,9 +2564,12 @@ ModuleSP Target::GetOrCreateModule(const ModuleSpec &orig_module_spec, m_images.Append(module_sp, notify); for (ModuleSP &old_module_sp : replaced_modules) { + auto use_count = old_module_sp.use_count(); Module *old_module_ptr = old_module_sp.get(); old_module_sp.reset(); - ModuleList::RemoveSharedModuleIfOrphaned(old_module_ptr); + // If the use count was one, this was not in the shared module list. + if (use_count > 1) + ModuleList::RemoveSharedModuleIfOrphaned(old_module_ptr); ---------------- JDevlieghere wrote:
Why does `RemoveSharedModuleIfOrphaned` take a raw pointer and not the `ModuleSP`? If it did, then we could just check if the SP is valid (like `Remove` does) and avoid yet another place where we check the use count. https://github.com/llvm/llvm-project/pull/155331 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits