From 271bc05b91772e5aedd834db116734b34f0108a1 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 10 May 2024 09:55:19 -0400 Subject: Fix latent access violation in ~LLEventPump() if LLEventPumps gone. Instead of making LLEventPumps an LLHandleProvider, and storing an LLHandle in each LLEventPump instance, just make ~LLEventPump() query LLEventPumps::instanceExists() before calling instance(). --- indra/llcommon/llevents.cpp | 8 +++----- indra/llcommon/llevents.h | 16 +--------------- 2 files changed, 4 insertions(+), 20 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/llevents.cpp b/indra/llcommon/llevents.cpp index e10e555f8b..5a6e13cb7d 100644 --- a/indra/llcommon/llevents.cpp +++ b/indra/llcommon/llevents.cpp @@ -359,8 +359,7 @@ const std::string LLEventPump::ANONYMOUS = std::string(); 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)), + mName(LLEventPumps::instance().registerNew(*this, name, tweak)), mSignal(std::make_shared()), mEnabled(true) {} @@ -373,10 +372,9 @@ LLEventPump::~LLEventPump() { // Unregister this doomed instance from LLEventPumps -- but only if // LLEventPumps is still around! - LLEventPumps* registry = mRegistry.get(); - if (registry) + if (LLEventPumps::instanceExists()) { - registry->unregister(*this); + LLEventPumps::instance().unregister(*this); } } diff --git a/indra/llcommon/llevents.h b/indra/llcommon/llevents.h index 1fc0f23ecd..15d1d5035c 100644 --- a/indra/llcommon/llevents.h +++ b/indra/llcommon/llevents.h @@ -53,7 +53,6 @@ #include "llsingleton.h" #include "lldependencies.h" #include "llexception.h" -#include "llhandle.h" // hack for testing #ifndef testable @@ -213,15 +212,7 @@ class LLEventPump; * LLEventPumps is a Singleton manager through which one typically accesses * this subsystem. */ -// LLEventPumps isa LLHandleProvider only for (hopefully rare) long-lived -// class objects that must refer to this class late in their lifespan, say in -// the destructor. Specifically, the case that matters is a possible reference -// after LLEventPumps::deleteSingleton(). (Lingering LLEventPump instances are -// capable of this.) In that case, instead of calling LLEventPumps::instance() -// again -- resurrecting the deleted LLSingleton -- store an -// LLHandle and test it before use. -class LL_COMMON_API LLEventPumps: public LLSingleton, - public LLHandleProvider +class LL_COMMON_API LLEventPumps: public LLSingleton { LLSINGLETON(LLEventPumps); public: @@ -582,12 +573,7 @@ private: virtual void clear(); virtual void reset(); - - private: - // must precede mName; see LLEventPump::LLEventPump() - LLHandle mRegistry; - std::string mName; LLMutex mConnectionListMutex; -- cgit v1.2.3