From efdbaa50be7ec7ccb3359203acef30f4d15c5c19 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 28 May 2021 19:52:07 +0300 Subject: SL-15093 Crash nanov2_free_to_block Superficially crash happens in disconnect() inside signal's deconstructor. Manual cleanup should help figuring out if crash happens due to named or anonymous listeners --- indra/llcommon/llevents.cpp | 19 ++++++++++++++----- indra/llcommon/llevents.h | 13 +------------ 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/indra/llcommon/llevents.cpp b/indra/llcommon/llevents.cpp index 64fb985951..0a213bddef 100644 --- a/indra/llcommon/llevents.cpp +++ b/indra/llcommon/llevents.cpp @@ -45,7 +45,6 @@ #include // external library headers #include -#include #if LL_WINDOWS #pragma warning (push) #pragma warning (disable : 4701) // compiler thinks might use uninitialized var, but no @@ -285,7 +284,7 @@ LLEventPump::LLEventPump(const std::string& name, bool tweak): // Register every new instance with LLEventPumps mRegistry(LLEventPumps::instance().getHandle()), mName(mRegistry.get()->registerNew(*this, name, tweak)), - mSignal(boost::make_shared()), + mSignal(std::make_shared()), mEnabled(true) {} @@ -317,14 +316,24 @@ void LLEventPump::clear() { // Destroy the original LLStandardSignal instance, replacing it with a // whole new one. - mSignal = boost::make_shared(); + mSignal = std::make_shared(); mConnections.clear(); } void LLEventPump::reset() { - mSignal.reset(); + // Resetting mSignal is supposed to disconnect everything on its own + // But due to crash on 'reset' added explicit cleanup to get more data + ConnectionMap::const_iterator iter = mConnections.begin(); + ConnectionMap::const_iterator end = mConnections.end(); + while (iter!=end) + { + iter->second.disconnect(); + iter++; + } mConnections.clear(); + + mSignal.reset(); //mDeps.clear(); } @@ -543,7 +552,7 @@ bool LLEventStream::post(const LLSD& event) // *stack* instance of the shared_ptr, ensuring that our heap // LLStandardSignal object will live at least until post() returns, even // if 'this' gets destroyed during the call. - boost::shared_ptr signal(mSignal); + std::shared_ptr signal(mSignal); // Let caller know if any one listener handled the event. This is mostly // useful when using LLEventStream as a listener for an upstream // LLEventPump. diff --git a/indra/llcommon/llevents.h b/indra/llcommon/llevents.h index e380c108f4..6ac90cb3a3 100644 --- a/indra/llcommon/llevents.h +++ b/indra/llcommon/llevents.h @@ -49,7 +49,6 @@ #endif #include -#include #include #include // noncopyable #include @@ -571,7 +570,7 @@ protected: const NameList& before); /// implement the dispatching - boost::shared_ptr mSignal; + std::shared_ptr mSignal; /// valve open? bool mEnabled; @@ -745,14 +744,4 @@ private: LL_COMMON_API bool sendReply(const LLSD& reply, const LLSD& request, const std::string& replyKey="reply"); -// Somewhat to my surprise, passing boost::bind(...boost::weak_ptr...) to -// listen() fails in Boost code trying to instantiate LLEventListener (i.e. -// LLStandardSignal::slot_type) because the boost::get_pointer() utility function isn't -// specialized for boost::weak_ptr. This remedies that omission. -namespace boost -{ - template - T* get_pointer(const weak_ptr& ptr) { return shared_ptr(ptr).get(); } -} - #endif /* ! defined(LL_LLEVENTS_H) */ -- cgit v1.2.3